Skip to content

Commit 4167797

Browse files
committed
Merge tag 'trace-v6.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing fixes from Steven Rostedt: - Fix build error when CONFIG_PROBE_EVENTS_BTF_ARGS is not enabled The tracing of arguments in the function tracer depends on some functions that are only defined when PROBE_EVENTS_BTF_ARGS is enabled. In fact, PROBE_EVENTS_BTF_ARGS also depends on all the same configs as the function argument tracing requires. Just have the function argument tracing depend on PROBE_EVENTS_BTF_ARGS. - Free module_delta for persistent ring buffer instance When an instance holds the persistent ring buffer, it allocates a helper array to hold the deltas between where modules are loaded on the last boot and the current boot. This array needs to be freed when the instance is freed. - Add cond_resched() to loop in ftrace_graph_set_hash() The hash functions in ftrace loop over every function that can be enabled by ftrace. This can be 50,000 functions or more. This loop is known to trigger soft lockup warnings and requires a cond_resched(). The loop in ftrace_graph_set_hash() was missing it. - Fix the event format verifier to include "%*p.." arguments To prevent events from dereferencing stale pointers that can happen if a trace event uses a dereferece pointer to something that was not copied into the ring buffer and can be freed by the time the trace is read, a verifier is called. At boot or module load, the verifier scans the print format string for pointers that can be dereferenced and it checks the arguments to make sure they do not contain something that can be freed. The "%*p" was not handled, which would add another argument and cause the verifier to not only not verify this pointer, but it will look at the wrong argument for every pointer after that. - Fix mcount sorttable building for different endian type target When modifying the ELF file to sort the mcount_loc table in the sorttable.c code, the endianess of the file and the host is used to determine if the bytes need to be swapped when calculations are done. A change was made to the sorting of the mcount_loc that read the values from the ELF file into an array and the swap happened on the filling of the array. But one of the calculations of the array still did the swap when it did not need to. This caused building on a little endian machine for a big endian target to not find the mcount function in the 'nm' table and it zeroed it out, causing there to be no functions available to trace. - Add goto out_unlock jump to rv_register_monitor() on error path One of the error paths in rv_register_monitor() just returned the error when it should have jumped to the out_unlock label to release the mutex. * tag 'trace-v6.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: rv: Fix missing unlock on double nested monitors return path scripts/sorttable: Fix endianness handling in build-time mcount sort tracing: Verify event formats that have "%*p.." ftrace: Add cond_resched() to ftrace_graph_set_hash() tracing: Free module_delta on freeing of persistent ring buffer ftrace: Have tracing function args depend on PROBE_EVENTS_BTF_ARGS
2 parents a2cc6ff + fc0585c commit 4167797

File tree

7 files changed

+19
-6
lines changed

7 files changed

+19
-6
lines changed

kernel/trace/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ config FUNCTION_GRAPH_RETADDR
265265

266266
config FUNCTION_TRACE_ARGS
267267
bool
268-
depends on HAVE_FUNCTION_ARG_ACCESS_API
269-
depends on DEBUG_INFO_BTF
268+
depends on PROBE_EVENTS_BTF_ARGS
270269
default y
271270
help
272271
If supported with function argument access API and BTF, then

kernel/trace/ftrace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6855,6 +6855,7 @@ ftrace_graph_set_hash(struct ftrace_hash *hash, char *buffer)
68556855
}
68566856
}
68576857
}
6858+
cond_resched();
68586859
} while_for_each_ftrace_rec();
68596860

68606861
return fail ? -EINVAL : 0;

kernel/trace/rv/rv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,8 @@ int rv_register_monitor(struct rv_monitor *monitor, struct rv_monitor *parent)
809809
if (p && rv_is_nested_monitor(p)) {
810810
pr_info("Parent monitor %s is already nested, cannot nest further\n",
811811
parent->name);
812-
return -EINVAL;
812+
retval = -EINVAL;
813+
goto out_unlock;
813814
}
814815

815816
r = kzalloc(sizeof(struct rv_monitor_def), GFP_KERNEL);

kernel/trace/trace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9604,6 +9604,7 @@ static void free_trace_buffers(struct trace_array *tr)
96049604
return;
96059605

96069606
free_trace_buffer(&tr->array_buffer);
9607+
kfree(tr->module_delta);
96079608

96089609
#ifdef CONFIG_TRACER_MAX_TRACE
96099610
free_trace_buffer(&tr->max_buffer);

kernel/trace/trace_events.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ static void test_event_printk(struct trace_event_call *call)
470470
case '%':
471471
continue;
472472
case 'p':
473+
do_pointer:
473474
/* Find dereferencing fields */
474475
switch (fmt[i + 1]) {
475476
case 'B': case 'R': case 'r':
@@ -498,6 +499,12 @@ static void test_event_printk(struct trace_event_call *call)
498499
continue;
499500
if (fmt[i + j] == '*') {
500501
star = true;
502+
/* Handle %*pbl case */
503+
if (!j && fmt[i + 1] == 'p') {
504+
arg++;
505+
i++;
506+
goto do_pointer;
507+
}
501508
continue;
502509
}
503510
if ((fmt[i + j] == 's')) {

samples/trace_events/trace-events-sample.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ TRACE_EVENT(foo_bar,
319319
__assign_cpumask(cpum, cpumask_bits(mask));
320320
),
321321

322-
TP_printk("foo %s %d %s %s %s %s %s %s (%s) (%s) %s", __entry->foo, __entry->bar,
322+
TP_printk("foo %s %d %s %s %s %s %s %s (%s) (%s) %s [%d] %*pbl",
323+
__entry->foo, __entry->bar,
323324

324325
/*
325326
* Notice here the use of some helper functions. This includes:
@@ -370,7 +371,10 @@ TRACE_EVENT(foo_bar,
370371

371372
__get_str(str), __get_str(lstr),
372373
__get_bitmask(cpus), __get_cpumask(cpum),
373-
__get_str(vstr))
374+
__get_str(vstr),
375+
__get_dynamic_array_len(cpus),
376+
__get_dynamic_array_len(cpus),
377+
__get_dynamic_array(cpus))
374378
);
375379

376380
/*

scripts/sorttable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ static void *sort_mcount_loc(void *arg)
857857
for (void *ptr = vals; ptr < vals + size; ptr += long_size) {
858858
uint64_t key;
859859

860-
key = long_size == 4 ? r((uint32_t *)ptr) : r8((uint64_t *)ptr);
860+
key = long_size == 4 ? *(uint32_t *)ptr : *(uint64_t *)ptr;
861861
if (!find_func(key)) {
862862
if (long_size == 4)
863863
*(uint32_t *)ptr = 0;

0 commit comments

Comments
 (0)