Skip to content

Commit 6d9b3fa

Browse files
committed
tracing: Move tracing_max_latency into trace_array
In preparation for letting the latency tracers be used by instances, remove the global tracing_max_latency variable and add a max_latency field to the trace_array that the latency tracers will now use. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 4104d32 commit 6d9b3fa

File tree

5 files changed

+33
-36
lines changed

5 files changed

+33
-36
lines changed

kernel/trace/trace.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,6 @@ static arch_spinlock_t ftrace_max_lock =
982982
unsigned long __read_mostly tracing_thresh;
983983

984984
#ifdef CONFIG_TRACER_MAX_TRACE
985-
unsigned long __read_mostly tracing_max_latency;
986-
987985
/*
988986
* Copy the new maximum trace into the separate maximum-trace
989987
* structure. (this way the maximum trace is permanently saved,
@@ -1000,7 +998,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
1000998
max_buf->cpu = cpu;
1001999
max_buf->time_start = data->preempt_timestamp;
10021000

1003-
max_data->saved_latency = tracing_max_latency;
1001+
max_data->saved_latency = tr->max_latency;
10041002
max_data->critical_start = data->critical_start;
10051003
max_data->critical_end = data->critical_end;
10061004

@@ -6328,6 +6326,11 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
63286326
trace_create_file("tracing_on", 0644, d_tracer,
63296327
tr, &rb_simple_fops);
63306328

6329+
#ifdef CONFIG_TRACER_MAX_TRACE
6330+
trace_create_file("tracing_max_latency", 0644, d_tracer,
6331+
&tr->max_latency, &tracing_max_lat_fops);
6332+
#endif
6333+
63316334
if (ftrace_create_function_files(tr, d_tracer))
63326335
WARN(1, "Could not allocate function filter files");
63336336

@@ -6353,11 +6356,6 @@ static __init int tracer_init_debugfs(void)
63536356

63546357
init_tracer_debugfs(&global_trace, d_tracer);
63556358

6356-
#ifdef CONFIG_TRACER_MAX_TRACE
6357-
trace_create_file("tracing_max_latency", 0644, d_tracer,
6358-
&tracing_max_latency, &tracing_max_lat_fops);
6359-
#endif
6360-
63616359
trace_create_file("tracing_thresh", 0644, d_tracer,
63626360
&tracing_thresh, &tracing_max_lat_fops);
63636361

kernel/trace/trace.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ struct trace_array {
190190
*/
191191
struct trace_buffer max_buffer;
192192
bool allocated_snapshot;
193+
unsigned long max_latency;
193194
#endif
194195
int buffer_disabled;
195196
#ifdef CONFIG_FTRACE_SYSCALLS
@@ -599,8 +600,6 @@ extern unsigned long nsecs_to_usecs(unsigned long nsecs);
599600
extern unsigned long tracing_thresh;
600601

601602
#ifdef CONFIG_TRACER_MAX_TRACE
602-
extern unsigned long tracing_max_latency;
603-
604603
void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu);
605604
void update_max_tr_single(struct trace_array *tr,
606605
struct task_struct *tsk, int cpu);

kernel/trace/trace_irqsoff.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ irqsoff_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
170170
for_each_possible_cpu(cpu)
171171
per_cpu(tracing_cpu, cpu) = 0;
172172

173-
tracing_max_latency = 0;
173+
tr->max_latency = 0;
174174
tracing_reset_online_cpus(&irqsoff_trace->trace_buffer);
175175

176176
return start_irqsoff_tracer(irqsoff_trace, set);
@@ -297,13 +297,13 @@ static void irqsoff_print_header(struct seq_file *s)
297297
/*
298298
* Should this new latency be reported/recorded?
299299
*/
300-
static int report_latency(cycle_t delta)
300+
static int report_latency(struct trace_array *tr, cycle_t delta)
301301
{
302302
if (tracing_thresh) {
303303
if (delta < tracing_thresh)
304304
return 0;
305305
} else {
306-
if (delta <= tracing_max_latency)
306+
if (delta <= tr->max_latency)
307307
return 0;
308308
}
309309
return 1;
@@ -327,13 +327,13 @@ check_critical_timing(struct trace_array *tr,
327327

328328
pc = preempt_count();
329329

330-
if (!report_latency(delta))
330+
if (!report_latency(tr, delta))
331331
goto out;
332332

333333
raw_spin_lock_irqsave(&max_trace_lock, flags);
334334

335335
/* check if we are still the max latency */
336-
if (!report_latency(delta))
336+
if (!report_latency(tr, delta))
337337
goto out_unlock;
338338

339339
__trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
@@ -346,7 +346,7 @@ check_critical_timing(struct trace_array *tr,
346346
data->critical_end = parent_ip;
347347

348348
if (likely(!is_tracing_stopped())) {
349-
tracing_max_latency = delta;
349+
tr->max_latency = delta;
350350
update_max_tr_single(tr, current, cpu);
351351
}
352352

@@ -605,7 +605,7 @@ static void __irqsoff_tracer_init(struct trace_array *tr)
605605
set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
606606
set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);
607607

608-
tracing_max_latency = 0;
608+
tr->max_latency = 0;
609609
irqsoff_trace = tr;
610610
/* make sure that the tracer is visible */
611611
smp_wmb();

kernel/trace/trace_sched_wakeup.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ wakeup_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
218218
stop_func_tracer(tr, !set);
219219

220220
wakeup_reset(wakeup_trace);
221-
tracing_max_latency = 0;
221+
tr->max_latency = 0;
222222

223223
return start_func_tracer(tr, set);
224224
}
@@ -344,13 +344,13 @@ static void wakeup_print_header(struct seq_file *s)
344344
/*
345345
* Should this new latency be reported/recorded?
346346
*/
347-
static int report_latency(cycle_t delta)
347+
static int report_latency(struct trace_array *tr, cycle_t delta)
348348
{
349349
if (tracing_thresh) {
350350
if (delta < tracing_thresh)
351351
return 0;
352352
} else {
353-
if (delta <= tracing_max_latency)
353+
if (delta <= tr->max_latency)
354354
return 0;
355355
}
356356
return 1;
@@ -418,11 +418,11 @@ probe_wakeup_sched_switch(void *ignore,
418418
T1 = ftrace_now(cpu);
419419
delta = T1-T0;
420420

421-
if (!report_latency(delta))
421+
if (!report_latency(wakeup_trace, delta))
422422
goto out_unlock;
423423

424424
if (likely(!is_tracing_stopped())) {
425-
tracing_max_latency = delta;
425+
wakeup_trace->max_latency = delta;
426426
update_max_tr(wakeup_trace, wakeup_task, wakeup_cpu);
427427
}
428428

@@ -609,7 +609,7 @@ static int __wakeup_tracer_init(struct trace_array *tr)
609609
set_tracer_flag(tr, TRACE_ITER_OVERWRITE, 1);
610610
set_tracer_flag(tr, TRACE_ITER_LATENCY_FMT, 1);
611611

612-
tracing_max_latency = 0;
612+
tr->max_latency = 0;
613613
wakeup_trace = tr;
614614
ftrace_init_array_ops(tr, wakeup_tracer_call);
615615
start_wakeup_tracer(tr);

kernel/trace/trace_selftest.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ trace_selftest_startup_function_graph(struct tracer *trace,
807807
int
808808
trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr)
809809
{
810-
unsigned long save_max = tracing_max_latency;
810+
unsigned long save_max = tr->max_latency;
811811
unsigned long count;
812812
int ret;
813813

@@ -819,7 +819,7 @@ trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr)
819819
}
820820

821821
/* reset the max latency */
822-
tracing_max_latency = 0;
822+
tr->max_latency = 0;
823823
/* disable interrupts for a bit */
824824
local_irq_disable();
825825
udelay(100);
@@ -846,7 +846,7 @@ trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr)
846846
ret = -1;
847847
}
848848

849-
tracing_max_latency = save_max;
849+
tr->max_latency = save_max;
850850

851851
return ret;
852852
}
@@ -856,7 +856,7 @@ trace_selftest_startup_irqsoff(struct tracer *trace, struct trace_array *tr)
856856
int
857857
trace_selftest_startup_preemptoff(struct tracer *trace, struct trace_array *tr)
858858
{
859-
unsigned long save_max = tracing_max_latency;
859+
unsigned long save_max = tr->max_latency;
860860
unsigned long count;
861861
int ret;
862862

@@ -881,7 +881,7 @@ trace_selftest_startup_preemptoff(struct tracer *trace, struct trace_array *tr)
881881
}
882882

883883
/* reset the max latency */
884-
tracing_max_latency = 0;
884+
tr->max_latency = 0;
885885
/* disable preemption for a bit */
886886
preempt_disable();
887887
udelay(100);
@@ -908,7 +908,7 @@ trace_selftest_startup_preemptoff(struct tracer *trace, struct trace_array *tr)
908908
ret = -1;
909909
}
910910

911-
tracing_max_latency = save_max;
911+
tr->max_latency = save_max;
912912

913913
return ret;
914914
}
@@ -918,7 +918,7 @@ trace_selftest_startup_preemptoff(struct tracer *trace, struct trace_array *tr)
918918
int
919919
trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *tr)
920920
{
921-
unsigned long save_max = tracing_max_latency;
921+
unsigned long save_max = tr->max_latency;
922922
unsigned long count;
923923
int ret;
924924

@@ -943,7 +943,7 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
943943
}
944944

945945
/* reset the max latency */
946-
tracing_max_latency = 0;
946+
tr->max_latency = 0;
947947

948948
/* disable preemption and interrupts for a bit */
949949
preempt_disable();
@@ -978,7 +978,7 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
978978
}
979979

980980
/* do the test by disabling interrupts first this time */
981-
tracing_max_latency = 0;
981+
tr->max_latency = 0;
982982
tracing_start();
983983
trace->start(tr);
984984

@@ -1009,7 +1009,7 @@ trace_selftest_startup_preemptirqsoff(struct tracer *trace, struct trace_array *
10091009
tracing_start();
10101010
out_no_start:
10111011
trace->reset(tr);
1012-
tracing_max_latency = save_max;
1012+
tr->max_latency = save_max;
10131013

10141014
return ret;
10151015
}
@@ -1062,7 +1062,7 @@ static int trace_wakeup_test_thread(void *data)
10621062
int
10631063
trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
10641064
{
1065-
unsigned long save_max = tracing_max_latency;
1065+
unsigned long save_max = tr->max_latency;
10661066
struct task_struct *p;
10671067
struct completion is_ready;
10681068
unsigned long count;
@@ -1088,7 +1088,7 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
10881088
}
10891089

10901090
/* reset the max latency */
1091-
tracing_max_latency = 0;
1091+
tr->max_latency = 0;
10921092

10931093
while (p->on_rq) {
10941094
/*
@@ -1118,7 +1118,7 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
11181118
trace->reset(tr);
11191119
tracing_start();
11201120

1121-
tracing_max_latency = save_max;
1121+
tr->max_latency = save_max;
11221122

11231123
/* kill the thread */
11241124
kthread_stop(p);

0 commit comments

Comments
 (0)