hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/kernel/trace/trace_irqsoff.c
....@@ -143,14 +143,11 @@
143143 struct trace_array *tr = irqsoff_trace;
144144 struct trace_array_cpu *data;
145145 unsigned long flags;
146
- unsigned int trace_ctx;
147146
148147 if (!func_prolog_dec(tr, &data, &flags))
149148 return;
150149
151
- trace_ctx = tracing_gen_ctx_flags(flags);
152
-
153
- trace_function(tr, ip, parent_ip, trace_ctx);
150
+ trace_function(tr, ip, parent_ip, flags, preempt_count());
154151
155152 atomic_dec(&data->disabled);
156153 }
....@@ -180,8 +177,8 @@
180177 struct trace_array *tr = irqsoff_trace;
181178 struct trace_array_cpu *data;
182179 unsigned long flags;
183
- unsigned int trace_ctx;
184180 int ret;
181
+ int pc;
185182
186183 if (ftrace_graph_ignore_func(trace))
187184 return 0;
....@@ -198,8 +195,8 @@
198195 if (!func_prolog_dec(tr, &data, &flags))
199196 return 0;
200197
201
- trace_ctx = tracing_gen_ctx_flags(flags);
202
- ret = __trace_graph_entry(tr, trace, trace_ctx);
198
+ pc = preempt_count();
199
+ ret = __trace_graph_entry(tr, trace, flags, pc);
203200 atomic_dec(&data->disabled);
204201
205202 return ret;
....@@ -210,15 +207,15 @@
210207 struct trace_array *tr = irqsoff_trace;
211208 struct trace_array_cpu *data;
212209 unsigned long flags;
213
- unsigned int trace_ctx;
210
+ int pc;
214211
215212 ftrace_graph_addr_finish(trace);
216213
217214 if (!func_prolog_dec(tr, &data, &flags))
218215 return;
219216
220
- trace_ctx = tracing_gen_ctx_flags(flags);
221
- __trace_graph_return(tr, trace, trace_ctx);
217
+ pc = preempt_count();
218
+ __trace_graph_return(tr, trace, flags, pc);
222219 atomic_dec(&data->disabled);
223220 }
224221
....@@ -231,7 +228,8 @@
231228 {
232229 if (is_graph(iter->tr))
233230 graph_trace_open(iter);
234
-
231
+ else
232
+ iter->private = NULL;
235233 }
236234
237235 static void irqsoff_trace_close(struct trace_iterator *iter)
....@@ -270,12 +268,12 @@
270268 static void
271269 __trace_function(struct trace_array *tr,
272270 unsigned long ip, unsigned long parent_ip,
273
- unsigned int trace_ctx)
271
+ unsigned long flags, int pc)
274272 {
275273 if (is_graph(tr))
276
- trace_graph_function(tr, ip, parent_ip, trace_ctx);
274
+ trace_graph_function(tr, ip, parent_ip, flags, pc);
277275 else
278
- trace_function(tr, ip, parent_ip, trace_ctx);
276
+ trace_function(tr, ip, parent_ip, flags, pc);
279277 }
280278
281279 #else
....@@ -325,13 +323,15 @@
325323 {
326324 u64 T0, T1, delta;
327325 unsigned long flags;
328
- unsigned int trace_ctx;
326
+ int pc;
329327
330328 T0 = data->preempt_timestamp;
331329 T1 = ftrace_now(cpu);
332330 delta = T1-T0;
333331
334
- trace_ctx = tracing_gen_ctx();
332
+ local_save_flags(flags);
333
+
334
+ pc = preempt_count();
335335
336336 if (!report_latency(tr, delta))
337337 goto out;
....@@ -342,9 +342,9 @@
342342 if (!report_latency(tr, delta))
343343 goto out_unlock;
344344
345
- __trace_function(tr, CALLER_ADDR0, parent_ip, trace_ctx);
345
+ __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
346346 /* Skip 5 functions to get to the irq/preempt enable function */
347
- __trace_stack(tr, trace_ctx, 5);
347
+ __trace_stack(tr, flags, 5, pc);
348348
349349 if (data->critical_sequence != max_sequence)
350350 goto out_unlock;
....@@ -364,15 +364,16 @@
364364 out:
365365 data->critical_sequence = max_sequence;
366366 data->preempt_timestamp = ftrace_now(cpu);
367
- __trace_function(tr, CALLER_ADDR0, parent_ip, trace_ctx);
367
+ __trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
368368 }
369369
370370 static nokprobe_inline void
371
-start_critical_timing(unsigned long ip, unsigned long parent_ip)
371
+start_critical_timing(unsigned long ip, unsigned long parent_ip, int pc)
372372 {
373373 int cpu;
374374 struct trace_array *tr = irqsoff_trace;
375375 struct trace_array_cpu *data;
376
+ unsigned long flags;
376377
377378 if (!tracer_enabled || !tracing_is_enabled())
378379 return;
....@@ -393,7 +394,9 @@
393394 data->preempt_timestamp = ftrace_now(cpu);
394395 data->critical_start = parent_ip ? : ip;
395396
396
- __trace_function(tr, ip, parent_ip, tracing_gen_ctx());
397
+ local_save_flags(flags);
398
+
399
+ __trace_function(tr, ip, parent_ip, flags, pc);
397400
398401 per_cpu(tracing_cpu, cpu) = 1;
399402
....@@ -401,12 +404,12 @@
401404 }
402405
403406 static nokprobe_inline void
404
-stop_critical_timing(unsigned long ip, unsigned long parent_ip)
407
+stop_critical_timing(unsigned long ip, unsigned long parent_ip, int pc)
405408 {
406409 int cpu;
407410 struct trace_array *tr = irqsoff_trace;
408411 struct trace_array_cpu *data;
409
- unsigned int trace_ctx;
412
+ unsigned long flags;
410413
411414 cpu = raw_smp_processor_id();
412415 /* Always clear the tracing cpu on stopping the trace */
....@@ -426,8 +429,8 @@
426429
427430 atomic_inc(&data->disabled);
428431
429
- trace_ctx = tracing_gen_ctx();
430
- __trace_function(tr, ip, parent_ip, trace_ctx);
432
+ local_save_flags(flags);
433
+ __trace_function(tr, ip, parent_ip, flags, pc);
431434 check_critical_timing(tr, data, parent_ip ? : ip, cpu);
432435 data->critical_start = 0;
433436 atomic_dec(&data->disabled);
....@@ -436,16 +439,20 @@
436439 /* start and stop critical timings used to for stoppage (in idle) */
437440 void start_critical_timings(void)
438441 {
439
- if (preempt_trace(preempt_count()) || irq_trace())
440
- start_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
442
+ int pc = preempt_count();
443
+
444
+ if (preempt_trace(pc) || irq_trace())
445
+ start_critical_timing(CALLER_ADDR0, CALLER_ADDR1, pc);
441446 }
442447 EXPORT_SYMBOL_GPL(start_critical_timings);
443448 NOKPROBE_SYMBOL(start_critical_timings);
444449
445450 void stop_critical_timings(void)
446451 {
447
- if (preempt_trace(preempt_count()) || irq_trace())
448
- stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1);
452
+ int pc = preempt_count();
453
+
454
+ if (preempt_trace(pc) || irq_trace())
455
+ stop_critical_timing(CALLER_ADDR0, CALLER_ADDR1, pc);
449456 }
450457 EXPORT_SYMBOL_GPL(stop_critical_timings);
451458 NOKPROBE_SYMBOL(stop_critical_timings);
....@@ -607,15 +614,19 @@
607614 */
608615 void tracer_hardirqs_on(unsigned long a0, unsigned long a1)
609616 {
610
- if (!preempt_trace(preempt_count()) && irq_trace())
611
- stop_critical_timing(a0, a1);
617
+ unsigned int pc = preempt_count();
618
+
619
+ if (!preempt_trace(pc) && irq_trace())
620
+ stop_critical_timing(a0, a1, pc);
612621 }
613622 NOKPROBE_SYMBOL(tracer_hardirqs_on);
614623
615624 void tracer_hardirqs_off(unsigned long a0, unsigned long a1)
616625 {
617
- if (!preempt_trace(preempt_count()) && irq_trace())
618
- start_critical_timing(a0, a1);
626
+ unsigned int pc = preempt_count();
627
+
628
+ if (!preempt_trace(pc) && irq_trace())
629
+ start_critical_timing(a0, a1, pc);
619630 }
620631 NOKPROBE_SYMBOL(tracer_hardirqs_off);
621632
....@@ -655,14 +666,18 @@
655666 #ifdef CONFIG_PREEMPT_TRACER
656667 void tracer_preempt_on(unsigned long a0, unsigned long a1)
657668 {
658
- if (preempt_trace(preempt_count()) && !irq_trace())
659
- stop_critical_timing(a0, a1);
669
+ int pc = preempt_count();
670
+
671
+ if (preempt_trace(pc) && !irq_trace())
672
+ stop_critical_timing(a0, a1, pc);
660673 }
661674
662675 void tracer_preempt_off(unsigned long a0, unsigned long a1)
663676 {
664
- if (preempt_trace(preempt_count()) && !irq_trace())
665
- start_critical_timing(a0, a1);
677
+ int pc = preempt_count();
678
+
679
+ if (preempt_trace(pc) && !irq_trace())
680
+ start_critical_timing(a0, a1, pc);
666681 }
667682
668683 static int preemptoff_tracer_init(struct trace_array *tr)