hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/kernel/trace/trace_functions.c
....@@ -133,14 +133,15 @@
133133 {
134134 struct trace_array *tr = op->private;
135135 struct trace_array_cpu *data;
136
- unsigned int trace_ctx;
136
+ unsigned long flags;
137137 int bit;
138138 int cpu;
139
+ int pc;
139140
140141 if (unlikely(!tr->function_enabled))
141142 return;
142143
143
- trace_ctx = tracing_gen_ctx();
144
+ pc = preempt_count();
144145 preempt_disable_notrace();
145146
146147 bit = trace_test_and_set_recursion(TRACE_FTRACE_START);
....@@ -149,9 +150,10 @@
149150
150151 cpu = smp_processor_id();
151152 data = per_cpu_ptr(tr->array_buffer.data, cpu);
152
- if (!atomic_read(&data->disabled))
153
- trace_function(tr, ip, parent_ip, trace_ctx);
154
-
153
+ if (!atomic_read(&data->disabled)) {
154
+ local_save_flags(flags);
155
+ trace_function(tr, ip, parent_ip, flags, pc);
156
+ }
155157 trace_clear_recursion(bit);
156158
157159 out:
....@@ -185,7 +187,7 @@
185187 unsigned long flags;
186188 long disabled;
187189 int cpu;
188
- unsigned int trace_ctx;
190
+ int pc;
189191
190192 if (unlikely(!tr->function_enabled))
191193 return;
....@@ -200,9 +202,9 @@
200202 disabled = atomic_inc_return(&data->disabled);
201203
202204 if (likely(disabled == 1)) {
203
- trace_ctx = tracing_gen_ctx_flags(flags);
204
- trace_function(tr, ip, parent_ip, trace_ctx);
205
- __trace_stack(tr, trace_ctx, STACK_SKIP);
205
+ pc = preempt_count();
206
+ trace_function(tr, ip, parent_ip, flags, pc);
207
+ __trace_stack(tr, flags, STACK_SKIP, pc);
206208 }
207209
208210 atomic_dec(&data->disabled);
....@@ -405,11 +407,13 @@
405407
406408 static __always_inline void trace_stack(struct trace_array *tr)
407409 {
408
- unsigned int trace_ctx;
410
+ unsigned long flags;
411
+ int pc;
409412
410
- trace_ctx = tracing_gen_ctx();
413
+ local_save_flags(flags);
414
+ pc = preempt_count();
411415
412
- __trace_stack(tr, trace_ctx, FTRACE_STACK_SKIP);
416
+ __trace_stack(tr, flags, FTRACE_STACK_SKIP, pc);
413417 }
414418
415419 static void