Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+19 -6
+1 -2
kernel/trace/Kconfig
··· 265 265 266 266 config FUNCTION_TRACE_ARGS 267 267 bool 268 - depends on HAVE_FUNCTION_ARG_ACCESS_API 269 - depends on DEBUG_INFO_BTF 268 + depends on PROBE_EVENTS_BTF_ARGS 270 269 default y 271 270 help 272 271 If supported with function argument access API and BTF, then
+1
kernel/trace/ftrace.c
··· 6855 6855 } 6856 6856 } 6857 6857 } 6858 + cond_resched(); 6858 6859 } while_for_each_ftrace_rec(); 6859 6860 6860 6861 return fail ? -EINVAL : 0;
+2 -1
kernel/trace/rv/rv.c
··· 809 809 if (p && rv_is_nested_monitor(p)) { 810 810 pr_info("Parent monitor %s is already nested, cannot nest further\n", 811 811 parent->name); 812 - return -EINVAL; 812 + retval = -EINVAL; 813 + goto out_unlock; 813 814 } 814 815 815 816 r = kzalloc(sizeof(struct rv_monitor_def), GFP_KERNEL);
+1
kernel/trace/trace.c
··· 9604 9604 return; 9605 9605 9606 9606 free_trace_buffer(&tr->array_buffer); 9607 + kfree(tr->module_delta); 9607 9608 9608 9609 #ifdef CONFIG_TRACER_MAX_TRACE 9609 9610 free_trace_buffer(&tr->max_buffer);
+7
kernel/trace/trace_events.c
··· 470 470 case '%': 471 471 continue; 472 472 case 'p': 473 + do_pointer: 473 474 /* Find dereferencing fields */ 474 475 switch (fmt[i + 1]) { 475 476 case 'B': case 'R': case 'r': ··· 499 498 continue; 500 499 if (fmt[i + j] == '*') { 501 500 star = true; 501 + /* Handle %*pbl case */ 502 + if (!j && fmt[i + 1] == 'p') { 503 + arg++; 504 + i++; 505 + goto do_pointer; 506 + } 502 507 continue; 503 508 } 504 509 if ((fmt[i + j] == 's')) {
+6 -2
samples/trace_events/trace-events-sample.h
··· 319 319 __assign_cpumask(cpum, cpumask_bits(mask)); 320 320 ), 321 321 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, 323 324 324 325 /* 325 326 * Notice here the use of some helper functions. This includes: ··· 371 370 372 371 __get_str(str), __get_str(lstr), 373 372 __get_bitmask(cpus), __get_cpumask(cpum), 374 - __get_str(vstr)) 373 + __get_str(vstr), 374 + __get_dynamic_array_len(cpus), 375 + __get_dynamic_array_len(cpus), 376 + __get_dynamic_array(cpus)) 375 377 ); 376 378 377 379 /*
+1 -1
scripts/sorttable.c
··· 857 857 for (void *ptr = vals; ptr < vals + size; ptr += long_size) { 858 858 uint64_t key; 859 859 860 - key = long_size == 4 ? r((uint32_t *)ptr) : r8((uint64_t *)ptr); 860 + key = long_size == 4 ? *(uint32_t *)ptr : *(uint64_t *)ptr; 861 861 if (!find_func(key)) { 862 862 if (long_size == 4) 863 863 *(uint32_t *)ptr = 0;