tracing: More updates for 5.16
Subsystems (9)
Steven Rostedt
maintainercover tracing: More updates for 5.16
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next
Head SHA1: 384c54408efaa4b3298f42e54b8048b8045f253a
Daniel Bristot de Oliveira (4):
trace/osnoise: Fix an ifdef comment
tracing/doc: Fix typos on the timerlat tracer documentation trace/osnoise: Add migrate-disabled field to the osnoise header trace/timerlat: Add migrate-disabled field to the timerlat header
Masami Hiramatsu (2):
lib/bootconfig: Make xbc_alloc_mem() and xbc_free_mem() as __init function
kprobes: Add a test case for stacktrace from kretprobe handler
Mathieu Desnoyers (1):
tracing: Fix missing trace_boot_init_histograms kstrdup NULL checks
Song Liu (1):
perf/core: allow ftrace for functions in kernel/event/core.c
Viktor Rosendahl (1):
tools/latency-collector: Use correct size when writing queue_full_warning
Wang ShaoBo (1):
tracing/hwlat: Make some internal symbols static
chongjiapeng (1):
ftrace: Make ftrace_profile_pages_init static
[email protected] (1):
ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
----
Documentation/trace/timerlat-tracer.rst | 24 ++--- arch/Kconfig | 8 ++ arch/sh/boot/compressed/misc.c | 3 + arch/x86/Kconfig | 1 + arch/x86/kernel/trace.c | 2 +- kernel/events/Makefile | 5 - kernel/test_kprobes.c | 162 ++++++++++++++++++++++++++++++ kernel/trace/ftrace.c | 2 +- kernel/trace/trace_boot.c | 4 + kernel/trace/trace_hwlat.c | 4 +- kernel/trace/trace_osnoise.c | 25 ++--- lib/bootconfig.c | 4 +- tools/tracing/latency/latency-collector.c | 2 +- 13 files changed, 210 insertions(+), 36 deletions(-)
Steven Rostedt
maintainerPATCH 1/12 ftrace: Make ftrace_profile_pages_init static
From: chongjiapeng <[email protected]>
This symbol is not used outside of ftrace.c, so marks it static.
Fixes the following sparse warning:
kernel/trace/ftrace.c:579:5: warning: symbol 'ftrace_profile_pages_init' was not declared. Should it be static?
--- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
@@ -576,7 +576,7 @@ static void ftrace_profile_reset(struct ftrace_profile_stat *stat) FTRACE_PROFILE_HASH_SIZE * sizeof(struct hlist_head)); } -int ftrace_profile_pages_init (struct ftrace_profile_stat *stat) +static int ftrace_profile_pages_init (struct ftrace_profile_stat *stat) {struct ftrace_profile_page *pg;int functions;
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 2/12 tools/latency-collector: Use correct size when writing queue_full_warning
In reply to Steven RostedtFrom: Viktor Rosendahl <[email protected]>
queue_full_warning is a pointer, so it is wrong to use sizeof to calculate the number of characters of the string it points to. The effect is that we only print out the first few characters of the warning string.
The correct way is to use strlen(). We don't need to add 1 to the strlen() because we don't want to write the terminating null character to stdout.
--- tools/tracing/latency/latency-collector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/latency/latency-collector.c +1 -1
@@ -1538,7 +1538,7 @@ static void tracing_loop(void)mutex_lock (&print_mtx);check_signals ();write_or_die (fd_stdout, queue_full_warning, -sizeof (queue_full_warning)); +strlen (queue_full_warning));mutex_unlock (&print_mtx); } modified--;
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 3/12 perf/core: allow ftrace for functions in kernel/event/core.c
In reply to Steven RostedtFrom: Song Liu <[email protected]>
It is useful to trace functions in kernel/event/core.c. Allow ftrace for them by removing $(CC_FLAGS_FTRACE) from Makefile.
--- kernel/events/Makefile | 5 ----- 1 file changed, 5 deletions(-)
kernel/events/Makefile +0 -5
@@ -1,10 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ifdef CONFIG_FUNCTION_TRACER -CFLAGS_REMOVE_core.o = $(CC_FLAGS_FTRACE) -endif - obj-y := core.o ring_buffer.o callchain.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_UPROBES) += uprobes.o -
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 4/12 trace/osnoise: Fix an ifdef comment
In reply to Steven RostedtFrom: Daniel Bristot de Oliveira <[email protected]>
s/CONFIG_OSNOISE_TRAECR/CONFIG_OSNOISE_TRACER/
No functional changes.
--- arch/x86/kernel/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/trace.c +1 -1
@@ -231,4 +231,4 @@ void osnoise_arch_unregister(void)unregister_trace_local_timer_exit (trace_intel_irq_exit,"local_timer" ); unregister_trace_local_timer_entry(trace_intel_irq_entry, NULL); } -#endif /* CONFIG_OSNOISE_TRAECR && CONFIG_X86_LOCAL_APIC */ +#endif /* CONFIG_OSNOISE_TRACER && CONFIG_X86_LOCAL_APIC */
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 5/12 tracing/doc: Fix typos on the timerlat tracer documentation
In reply to Steven RostedtFrom: Daniel Bristot de Oliveira <[email protected]>
Fixes a series of typos in the timerlat doc.
--- Documentation/trace/timerlat-tracer.rst | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
Documentation/trace/timerlat-tracer.rst +12 -12
@@ -3,7 +3,7 @@ Timerlat tracer ############### The timerlat tracer aims to help the preemptive kernel developers to -find souces of wakeup latencies of real-time threads. Like cyclictest, +find sources of wakeup latencies of real-time threads. Like cyclictest, the tracer sets a periodic timer that wakes up a thread. The thread then computes a *wakeup latency* value as the difference between the *current time* and the *absolute time* that the timer was set to expire. The main
@@ -50,14 +50,14 @@ The second is the *timer latency* observed by the thread. The ACTIVATION ID field serves to relate the *irq* execution to its respective *thread* execution. -The *irq*/*thread* splitting is important to clarify at which context +The *irq*/*thread* splitting is important to clarify in which context the unexpected high value is coming from. The *irq* context can be -delayed by hardware related actions, such as SMIs, NMIs, IRQs -or by a thread masking interrupts. Once the timer happens, the delay +delayed by hardware-related actions, such as SMIs, NMIs, IRQs, +or by thread masking interrupts. Once the timer happens, the delay can also be influenced by blocking caused by threads. For example, by -postponing the scheduler execution via preempt_disable(), by the -scheduler execution, or by masking interrupts. Threads can -also be delayed by the interference from other threads and IRQs. +postponing the scheduler execution via preempt_disable(), scheduler +execution, or masking interrupts. Threads can also be delayed by the +interference from other threads and IRQs. Tracer options ---------------------
@@ -68,14 +68,14 @@ directory. The timerlat configs are: - cpus: CPUs at which a timerlat thread will execute. - timerlat_period_us: the period of the timerlat thread. - - osnoise/stop_tracing_us: stop the system tracing if a + - stop_tracing_us: stop the system tracing if a timer latency at the *irq* context higher than the configured value happens. Writing 0 disables this option. - stop_tracing_total_us: stop the system tracing if a - timer latency at the *thread* context higher than the configured + timer latency at the *thread* context is higher than the configured value happens. Writing 0 disables this option. - - print_stack: save the stack of the IRQ ocurrence, and print - it afte the *thread context* event". + - print_stack: save the stack of the IRQ occurrence, and print + it after the *thread context* event". timerlat and osnoise ----------------------------
@@ -95,7 +95,7 @@ For example:: timerlat/5-1035 [005] ....... 548.771104: #402268 context thread timer_latency 39960 ns In this case, the root cause of the timer latency does not point to a -single cause, but to multiple ones. Firstly, the timer IRQ was delayed +single cause but to multiple ones. Firstly, the timer IRQ was delayed for 13 us, which may point to a long IRQ disabled section (see IRQ stacktrace section). Then the timer interrupt that wakes up the timerlat thread took 7597 ns, and the qxl:21 device IRQ took 7139 ns. Finally,
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 6/12 trace/osnoise: Add migrate-disabled field to the osnoise header
In reply to Steven RostedtFrom: Daniel Bristot de Oliveira <[email protected]>
Since "54357f0c9149 tracing: Add migrate-disabled counter to tracing output," the migrate disabled field is also printed in the !PREEMPR_RT kernel config. While this information was added to the vast majority of tracers, osnoise and timerlat were not updated (because they are new tracers).
Fix osnoise header by adding the information about migrate disabled.
--- kernel/trace/trace_osnoise.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
kernel/trace/trace_osnoise.c +7 -7
@@ -294,19 +294,19 @@ static void print_osnoise_headers(struct seq_file *s)seq_puts (s,"# _-----=> irqs-off\n" );seq_puts (s,"# / _----=> need-resched\n" );seq_puts (s,"# | / _---=> hardirq/softirq\n" ); -seq_puts (s,"# || / _--=> preempt-depth " ); -seq_puts (s," MAX\n" ); - -seq_puts (s,"# || / " ); +seq_puts (s,"# || / _--=> preempt-depth\n" ); +seq_puts (s,"# ||| / _-=> migrate-disable " ); +seq_puts (s," MAX\n" ); +seq_puts (s,"# |||| / delay " );seq_puts (s," SINGLE Interference counters:\n" ); -seq_puts (s,"# |||| RUNTIME " ); +seq_puts (s,"# ||||| RUNTIME " );seq_puts (s," NOISE %% OF CPU NOISE +-----------------------------+\n" ); -seq_puts (s,"# TASK-PID CPU# |||| TIMESTAMP IN US " ); +seq_puts (s,"# TASK-PID CPU# ||||| TIMESTAMP IN US " );seq_puts (s," IN US AVAILABLE IN US HW NMI IRQ SIRQ THREAD\n" ); -seq_puts (s,"# | | | |||| | | " ); +seq_puts (s,"# | | | ||||| | | " ); seq_puts(s, " | | | | | | | |\n"); }#endif /* CONFIG_PREEMPT_RT */
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 7/12 trace/timerlat: Add migrate-disabled field to the timerlat header
In reply to Steven RostedtFrom: Daniel Bristot de Oliveira <[email protected]>
Since "54357f0c9149 tracing: Add migrate-disabled counter to tracing output," the migrate disabled field is also printed in the !PREEMPR_RT kernel config. While this information was added to the vast majority of tracers, osnoise and timerlat were not updated (because they are new tracers).
Fix timerlat header by adding the information about migrate disabled.
--- kernel/trace/trace_osnoise.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
kernel/trace/trace_osnoise.c +6 -5
@@ -378,11 +378,12 @@ static void print_timerlat_headers(struct seq_file *s)seq_puts (s,"# / _----=> need-resched\n" );seq_puts (s,"# | / _---=> hardirq/softirq\n" );seq_puts (s,"# || / _--=> preempt-depth\n" ); -seq_puts (s,"# || /\n" ); -seq_puts (s,"# |||| ACTIVATION\n" ); -seq_puts (s,"# TASK-PID CPU# |||| TIMESTAMP ID " ); -seq_puts (s," CONTEXT LATENCY\n" ); -seq_puts (s,"# | | | |||| | | " ); +seq_puts (s,"# ||| / _-=> migrate-disable\n" ); +seq_puts (s,"# |||| / delay\n" ); +seq_puts (s,"# ||||| ACTIVATION\n" ); +seq_puts (s,"# TASK-PID CPU# ||||| TIMESTAMP ID " ); +seq_puts (s," CONTEXT LATENCY\n" ); +seq_puts (s,"# | | | ||||| | | " ); seq_puts(s, " | |\n"); }#endif /* CONFIG_PREEMPT_RT */
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 8/12 tracing: Fix missing trace_boot_init_histograms kstrdup NULL checks
In reply to Steven RostedtFrom: Mathieu Desnoyers <[email protected]>
trace_boot_init_histograms misses NULL pointer checks for kstrdup failure.
--- kernel/trace/trace_boot.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/trace/trace_boot.c +4 -0
@@ -430,6 +430,8 @@ trace_boot_init_histograms(struct trace_event_file *file,/* All digit started node should be instances. */ if (trace_boot_compose_hist_cmd (node, buf, size) ==0 ) { tmp =kstrdup (buf,GFP_KERNEL ); +if (!tmp) +return ;if (trigger_process_regex (file, buf) <0 )pr_err ("Failed to apply hist trigger: %s\n" , tmp);kfree (tmp);
@@ -439,6 +441,8 @@ trace_boot_init_histograms(struct trace_event_file *file,if (xbc_node_find_subkey (hnode,"keys" )) {if (trace_boot_compose_hist_cmd (hnode, buf, size) ==0 ) { tmp =kstrdup (buf,GFP_KERNEL ); +if (!tmp) +return ;if (trigger_process_regex (file, buf) <0 )pr_err ("Failed to apply hist trigger: %s\n" , tmp);kfree (tmp);
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 9/12 tracing/hwlat: Make some internal symbols static
In reply to Steven RostedtFrom: Wang ShaoBo <[email protected]>
The sparse tool complains as follows:
kernel/trace/trace_hwlat.c:82:27: warning: symbol 'hwlat_single_cpu_data' was not declared. Should it be static? kernel/trace/trace_hwlat.c:83:1: warning: symbol '__pcpu_scope_hwlat_per_cpu_data' was not declared. Should it be static?
This symbol is not used outside of trace_hwlat.c, so this commit marks it static.
--- kernel/trace/trace_hwlat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_hwlat.c +2 -2
@@ -79,8 +79,8 @@ struct hwlat_kthread_data {int nmi_cpu; }; -struct hwlat_kthread_data hwlat_single_cpu_data; -DEFINE_PER_CPU(struct hwlat_kthread_data, hwlat_per_cpu_data); +static struct hwlat_kthread_data hwlat_single_cpu_data; +static DEFINE_PER_CPU(struct hwlat_kthread_data, hwlat_per_cpu_data);/* Tells NMIs to call back to the hwlat tracer to record timestamps */ bool trace_hwlat_callback_enabled;
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 10/12 ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
In reply to Steven RostedtFrom: "[email protected]" <[email protected]>
Using the linker script to fix an issue where some archs call the function tracer with just the ip (instruction pointer) and pip (parent instruction pointer) where as more up to date archs also pass in the associated ftrace_ops and the ftrace_regs pointer, the generic code will be called either with two parameters or four. To avoid any C undefined behavior of calling two parameters to four or four to two parameter function, two functions are created, where a preprocessor macro uses the one that matches the architecture. As the function pointers for them may be different, a typecast is used. But this triggers issues with newer compilers that will fail due to -Werror.
A linker trick is now used to map the generic function to the function that is used (note the generic function is only used to set the default function callback). The linker trick defines ftrace_ops_list_func (the generic function) to arch_ftrace_ops_list_func (the arch defined one).
But this fails sh arch because their linker script is included in their compressed image that does not define arch_ftrace_ops_list_func at all
sh4-linux-ld:arch/sh/boot/compressed/../../kernel/vmlinux.lds:32: undefined symbol `arch_ftrace_ops_list_func' referenced in expression
Included a stub by that name in the misc.c to allow the code to compile and link, even though it's not used.
This is similar to what was done for ftrace_stub:
b83b43ffc6e4b ("fgraph: Fix function type mismatches of ftrace_graph_return using ftrace_stub")
--- arch/sh/boot/compressed/misc.c | 3 +++ 1 file changed, 3 insertions(+)
arch/sh/boot/compressed/misc.c +3 -0
@@ -115,6 +115,9 @@ void __stack_chk_fail(void)void ftrace_stub (void ) { } +void arch_ftrace_ops_list_func (void ) +{ +}#define stackalign 4
Signature · 1 line
2.33.0
Re: [for-next][PATCH 10/12] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
Quoted 1 line · Steven Rostedt
From: "[email protected]" <[email protected]>
Collective author, really? :-)
Quoted 31 lines
Using the linker script to fix an issue where some archs call the function tracer with just the ip (instruction pointer) and pip (parent instruction pointer) where as more up to date archs also pass in the associated
ftrace_opsand theftrace_regspointer, the generic code will be called either with two parameters or four. To avoid any C undefined behavior of calling two parameters to four or four to two parameter function, two functions are created, where a preprocessor macro uses the one that matches the architecture. As the function pointers for them may be different, a typecast is used. But this triggers issues with newer compilers that will fail due to -Werror.A linker trick is now used to map the generic function to the function that is used (note the generic function is only used to set the default function callback). The linker trick defines
ftrace_ops_list_func(the generic function) toarch_ftrace_ops_list_func(the arch defined one).But this fails sh arch because their linker script is included in their compressed image that does not define
arch_ftrace_ops_list_funcat allsh4-linux-ld:arch/sh/boot/compressed/../../kernel/vmlinux.lds:32: undefined symbol `arch_ftrace_ops_list_func' referenced in expression
Included a stub by that name in the
misc.cto allow the code to compile and link, even though it's not used.This is similar to what was done for
ftrace_stub:
b83b43ffc6e4b("fgraph: Fix function type mismatches offtrace_graph_returnusingftrace_stub")
Quoted 6 lines
Cc Yoshinori Sato <[email protected]>Cc Rich Felker <[email protected]>Signed-off-by Steven Rostedt (VMware) <[email protected]>
[...]
MBR, Sergey
Steven Rostedt
maintainerRe: [for-next][PATCH 10/12] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
Quoted 3 lines · On Wed, 27 Oct 2021 11:58:31 +0300 Sergey Shtylyov <[email protected]> wrote:
Quoted 1 line
From: "[email protected]" <[email protected]>
Collective author, really? :-)
Yeah, Stephen already pointed this that the author didn't have a "signed-off-by", when in reality my patchwork (which I send my own patches through) somehow add that as the author and not me :-p
-- Steve
Steven Rostedt
maintainerPATCH 11/12 lib/bootconfig: Make xbc_alloc_mem() and xbc_free_mem() as __init function
In reply to Steven RostedtFrom: Masami Hiramatsu <[email protected]>
Since the xbc_alloc_mem() and xbc_free_mem() are used from the __init functions and memblock_alloc() is __init function, make them __init functions too.
--- lib/bootconfig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bootconfig.c +2 -2
@@ -43,12 +43,12 @@ static int open_brace[XBC_DEPTH_MAX] __initdata;static int brace_index__initdata ;#ifdef __KERNEL__ -static inline void *xbc_alloc_mem (size_t size) +static inline void *__init xbc_alloc_mem (size_t size) {return memblock_alloc (size,SMP_CACHE_BYTES ); } -static inline void xbc_free_mem (void *addr,size_t size) +static inline void __init xbc_free_mem (void *addr,size_t size) {memblock_free_ptr (addr, size); }
Signature · 1 line
2.33.0
Steven Rostedt
maintainerPATCH 12/12 kprobes: Add a test case for stacktrace from kretprobe handler
In reply to Steven RostedtFrom: Masami Hiramatsu <[email protected]>
Add a test case for stacktrace from kretprobe handler and nested kretprobe handlers.
This test checks both of stack trace inside kretprobe handler and stack trace from pt_regs. Those stack trace must include actual function return address instead of kretprobe trampoline. The nested kretprobe stacktrace test checks whether the unwinder can correctly unwind the call frame on the stack which has been modified by the kretprobe.
Since the stacktrace on kretprobe is correctly fixed only on x86, this introduces a meta kconfig ARCH_CORRECT_STACKTRACE_ON_KRETPROBE which tells user that the stacktrace on kretprobe is correct or not.
The test results will be shown like below;
TAP version 14
1..1
# Subtest: kprobes_test
1..6
ok 1 - test_kprobe
ok 2 - test_kprobes
ok 3 - test_kretprobe
ok 4 - test_kretprobes
ok 5 - test_stacktrace_on_kretprobe
ok 6 - test_stacktrace_on_nested_kretprobe
# kprobes_test: pass:6 fail:0 skip:0 total:6
# Totals: pass:6 fail:0 skip:0 total:6
ok 1 - kprobes_test
--- arch/Kconfig | 8 +++ arch/x86/Kconfig | 1 + kernel/test_kprobes.c | 162 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+)
arch/Kconfig +8 -0
@@ -191,6 +191,14 @@ config HAVE_OPTPROBES config HAVE_KPROBES_ON_FTRACE bool +config ARCH_CORRECT_STACKTRACE_ON_KRETPROBE + bool + help + Since kretprobes modifies return address on the stack, the + stacktrace may see the kretprobe trampoline address instead + of correct one. If the architecture stacktrace code and + unwinder can adjust such entries, select this configuration. + config HAVE_FUNCTION_ERROR_INJECTION bool
arch/x86/Kconfig +1 -0
@@ -61,6 +61,7 @@ config X86 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI select ARCH_32BIT_OFF_T if X86_32 select ARCH_CLOCKSOURCE_INIT + select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE select ARCH_ENABLE_HUGEPAGE_MIGRATION if X86_64 && HUGETLB_PAGE && MIGRATION select ARCH_ENABLE_MEMORY_HOTPLUG if X86_64 || (X86_32 && HIGHMEM) select ARCH_ENABLE_MEMORY_HOTREMOVE if MEMORY_HOTPLUG
kernel/test_kprobes.c +162 -0
192 lines not on this page · raw message
Signature · 1 line
2.33.0