All of lore.kernel.org
 help / color / mirror / Atom feed
* [for-next][PATCH 00/12] tracing: More updates for 5.16
@ 2021-10-26 16:23 Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 01/12] ftrace: Make ftrace_profile_pages_init static Steven Rostedt
                   ` (11 more replies)
  0 siblings, 12 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton

  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

linux-sh@vger.kernel.org (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(-)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [for-next][PATCH 01/12] ftrace: Make ftrace_profile_pages_init static
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 02/12] tools/latency-collector: Use correct size when writing queue_full_warning Steven Rostedt
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Abaci Robot, chongjiapeng

From: chongjiapeng <jiapeng.chong@linux.alibaba.com>

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?

Link: https://lkml.kernel.org/r/1634640534-18280-1-git-send-email-jiapeng.chong@linux.alibaba.com

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Fixes: cafb168a1c92 ("tracing: make the function profiler per cpu")
Signed-off-by: chongjiapeng <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f90ed00a6d5b..2057ad363772 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -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;
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 02/12] tools/latency-collector: Use correct size when writing queue_full_warning
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 01/12] ftrace: Make ftrace_profile_pages_init static Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 03/12] perf/core: allow ftrace for functions in kernel/event/core.c Steven Rostedt
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Zeal Robot, Viktor Rosendahl

From: Viktor Rosendahl <Viktor.Rosendahl@bmw.de>

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.

Link: https://lkml.kernel.org/r/20211019160701.15587-1-Viktor.Rosendahl@bmw.de

Link: https://lore.kernel.org/r/8fd4bb65ef3da67feac9ce3258cdbe9824752cf1.1629198502.git.jing.yangyang@zte.com.cn
Link: https://lore.kernel.org/r/20211012025424.180781-1-davidcomponentone@gmail.com
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Viktor Rosendahl <Viktor.Rosendahl@bmw.de>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 tools/tracing/latency/latency-collector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/tracing/latency/latency-collector.c b/tools/tracing/latency/latency-collector.c
index 3a2e6bb781a8..59a7f2346eab 100644
--- a/tools/tracing/latency/latency-collector.c
+++ b/tools/tracing/latency/latency-collector.c
@@ -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--;
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 03/12] perf/core: allow ftrace for functions in kernel/event/core.c
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 01/12] ftrace: Make ftrace_profile_pages_init static Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 02/12] tools/latency-collector: Use correct size when writing queue_full_warning Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 04/12] trace/osnoise: Fix an ifdef comment Steven Rostedt
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Peter Zijlstra, Andrii Nakryiko,
	KP Singh, Song Liu

From: Song Liu <songliubraving@fb.com>

It is useful to trace functions in kernel/event/core.c. Allow ftrace for
them by removing $(CC_FLAGS_FTRACE) from Makefile.

Link: https://lkml.kernel.org/r/20211006210732.2826289-1-songliubraving@fb.com

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: KP Singh <kpsingh@kernel.org>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/events/Makefile | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/kernel/events/Makefile b/kernel/events/Makefile
index 3c022e33c109..8591c180b52b 100644
--- a/kernel/events/Makefile
+++ b/kernel/events/Makefile
@@ -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
-
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 04/12] trace/osnoise: Fix an ifdef comment
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
                   ` (2 preceding siblings ...)
  2021-10-26 16:23 ` [for-next][PATCH 03/12] perf/core: allow ftrace for functions in kernel/event/core.c Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 05/12] tracing/doc: Fix typos on the timerlat tracer documentation Steven Rostedt
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Daniel Bristot de Oliveira,
	Jonathan Corbet, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, Sebastian Andrzej Siewior, x86, linux-doc

From: Daniel Bristot de Oliveira <bristot@kernel.org>

s/CONFIG_OSNOISE_TRAECR/CONFIG_OSNOISE_TRACER/

No functional changes.

Link: https://lkml.kernel.org/r/33924a16f6e5559ce24952ca7d62561604bfd94a.1634308385.git.bristot@kernel.org

Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: x86@kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 arch/x86/kernel/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/trace.c b/arch/x86/kernel/trace.c
index 6b73b6f92ad3..8322e8352777 100644
--- a/arch/x86/kernel/trace.c
+++ b/arch/x86/kernel/trace.c
@@ -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 */
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 05/12] tracing/doc: Fix typos on the timerlat tracer documentation
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
                   ` (3 preceding siblings ...)
  2021-10-26 16:23 ` [for-next][PATCH 04/12] trace/osnoise: Fix an ifdef comment Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 06/12] trace/osnoise: Add migrate-disabled field to the osnoise header Steven Rostedt
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Daniel Bristot de Oliveira,
	Jonathan Corbet, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, Sebastian Andrzej Siewior, x86, linux-doc

From: Daniel Bristot de Oliveira <bristot@kernel.org>

Fixes a series of typos in the timerlat doc.

Link: https://lkml.kernel.org/r/d3763eb376603890baab908141de6660ba18fff8.1634308385.git.bristot@kernel.org

Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: x86@kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Fixes: a955d7eac177 ("trace: Add timerlat tracer")
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Documentation/trace/timerlat-tracer.rst | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Documentation/trace/timerlat-tracer.rst b/Documentation/trace/timerlat-tracer.rst
index c7cbb557aee7..64d1fe6e9b93 100644
--- a/Documentation/trace/timerlat-tracer.rst
+++ b/Documentation/trace/timerlat-tracer.rst
@@ -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,
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 06/12] trace/osnoise: Add migrate-disabled field to the osnoise header
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
                   ` (4 preceding siblings ...)
  2021-10-26 16:23 ` [for-next][PATCH 05/12] tracing/doc: Fix typos on the timerlat tracer documentation Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 07/12] trace/timerlat: Add migrate-disabled field to the timerlat header Steven Rostedt
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Daniel Bristot de Oliveira,
	Jonathan Corbet, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, Sebastian Andrzej Siewior, x86, linux-doc

From: Daniel Bristot de Oliveira <bristot@kernel.org>

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.

Link: https://lkml.kernel.org/r/9cb3d54e29e0588dbba12e81486bd8a09adcd8ca.1634308385.git.bristot@kernel.org

Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: x86@kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Fixes: 54357f0c9149 ("tracing: Add migrate-disabled counter to tracing output.")
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_osnoise.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index c4f14fb98aaa..34f26c632442 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -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 */
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 07/12] trace/timerlat: Add migrate-disabled field to the timerlat header
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
                   ` (5 preceding siblings ...)
  2021-10-26 16:23 ` [for-next][PATCH 06/12] trace/osnoise: Add migrate-disabled field to the osnoise header Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 08/12] tracing: Fix missing trace_boot_init_histograms kstrdup NULL checks Steven Rostedt
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Daniel Bristot de Oliveira,
	Jonathan Corbet, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	H. Peter Anvin, Sebastian Andrzej Siewior, x86, linux-doc

From: Daniel Bristot de Oliveira <bristot@kernel.org>

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.

Link: https://lkml.kernel.org/r/bc0c234ab49946cdd63effa6584e1d5e8662cb44.1634308385.git.bristot@kernel.org

Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: x86@kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Fixes: 54357f0c9149 ("tracing: Add migrate-disabled counter to tracing output.")
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_osnoise.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 34f26c632442..d11b41784fac 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -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 */
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 08/12] tracing: Fix missing trace_boot_init_histograms kstrdup NULL checks
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
                   ` (6 preceding siblings ...)
  2021-10-26 16:23 ` [for-next][PATCH 07/12] trace/timerlat: Add migrate-disabled field to the timerlat header Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 09/12] tracing/hwlat: Make some internal symbols static Steven Rostedt
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Masami Hiramatsu, Mathieu Desnoyers

From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

trace_boot_init_histograms misses NULL pointer checks for kstrdup
failure.

Link: https://lkml.kernel.org/r/20211015195550.22742-1-mathieu.desnoyers@efficios.com

Fixes: 64dc7f6958ef5 ("tracing/boot: Show correct histogram error command")
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_boot.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/trace/trace_boot.c b/kernel/trace/trace_boot.c
index 8d252f63cd78..0580287d7a0d 100644
--- a/kernel/trace/trace_boot.c
+++ b/kernel/trace/trace_boot.c
@@ -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);
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 09/12] tracing/hwlat: Make some internal symbols static
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
                   ` (7 preceding siblings ...)
  2021-10-26 16:23 ` [for-next][PATCH 08/12] tracing: Fix missing trace_boot_init_histograms kstrdup NULL checks Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 10/12] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link Steven Rostedt
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Wang ShaoBo

From: Wang ShaoBo <bobo.shaobowang@huawei.com>

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.

Link: https://lkml.kernel.org/r/20211021035225.1050685-1-bobo.shaobowang@huawei.com

Signed-off-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_hwlat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index d0a730d99a33..56bb7b890578 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -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;
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 10/12] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
                   ` (8 preceding siblings ...)
  2021-10-26 16:23 ` [for-next][PATCH 09/12] tracing/hwlat: Make some internal symbols static Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-27  8:58   ` Sergey Shtylyov
  2021-10-26 16:23 ` [for-next][PATCH 11/12] lib/bootconfig: Make xbc_alloc_mem() and xbc_free_mem() as __init function Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 12/12] kprobes: Add a test case for stacktrace from kretprobe handler Steven Rostedt
  11 siblings, 1 reply; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Yoshinori Sato, Rich Felker, linux-sh

From: "linux-sh@vger.kernel.org" <linux-sh@vger.kernel.org>

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).

Link: https://lore.kernel.org/all/20200617165616.52241bde@oasis.local.home/

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")

Link: https://lkml.kernel.org/r/20211021221627.5d7270de@rorschach.local.home

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: linux-sh@vger.kernel.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 arch/sh/boot/compressed/misc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/sh/boot/compressed/misc.c b/arch/sh/boot/compressed/misc.c
index a03b6680a9d9..ca05c99a3d5b 100644
--- a/arch/sh/boot/compressed/misc.c
+++ b/arch/sh/boot/compressed/misc.c
@@ -115,6 +115,9 @@ void __stack_chk_fail(void)
 void ftrace_stub(void)
 {
 }
+void arch_ftrace_ops_list_func(void)
+{
+}
 
 #define stackalign	4
 
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 11/12] lib/bootconfig: Make xbc_alloc_mem() and xbc_free_mem() as __init function
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
                   ` (9 preceding siblings ...)
  2021-10-26 16:23 ` [for-next][PATCH 10/12] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  2021-10-26 16:23 ` [for-next][PATCH 12/12] kprobes: Add a test case for stacktrace from kretprobe handler Steven Rostedt
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Masami Hiramatsu, Stephen Rothwell

From: Masami Hiramatsu <mhiramat@kernel.org>

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.

Link: https://lkml.kernel.org/r/163515075747.547467.5746167540626712819.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: 4ee1b4cac236 ("bootconfig: Cleanup dummy headers in tools/bootconfig")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/bootconfig.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bootconfig.c b/lib/bootconfig.c
index a056ae137750..3276675b25e1 100644
--- a/lib/bootconfig.c
+++ b/lib/bootconfig.c
@@ -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);
 }
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [for-next][PATCH 12/12] kprobes: Add a test case for stacktrace from kretprobe handler
  2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
                   ` (10 preceding siblings ...)
  2021-10-26 16:23 ` [for-next][PATCH 11/12] lib/bootconfig: Make xbc_alloc_mem() and xbc_free_mem() as __init function Steven Rostedt
@ 2021-10-26 16:23 ` Steven Rostedt
  11 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-26 16:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Masami Hiramatsu

From: Masami Hiramatsu <mhiramat@kernel.org>

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

Link: https://lkml.kernel.org/r/163516211244.604541.18350507860972214415.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 arch/Kconfig          |   8 +++
 arch/x86/Kconfig      |   1 +
 kernel/test_kprobes.c | 162 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index 8df1c7102643..8378f83b462c 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -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
 
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e39e2bd6acc5..cc9ba6798848 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -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
diff --git a/kernel/test_kprobes.c b/kernel/test_kprobes.c
index e78f18144145..a5edc2ebc947 100644
--- a/kernel/test_kprobes.c
+++ b/kernel/test_kprobes.c
@@ -17,6 +17,11 @@ static u32 (*target)(u32 value);
 static u32 (*target2)(u32 value);
 static struct kunit *current_test;
 
+static unsigned long (*internal_target)(void);
+static unsigned long (*stacktrace_target)(void);
+static unsigned long (*stacktrace_driver)(void);
+static unsigned long target_return_address[2];
+
 static noinline u32 kprobe_target(u32 value)
 {
 	return (value / div_factor);
@@ -58,6 +63,33 @@ static noinline u32 kprobe_target2(u32 value)
 	return (value / div_factor) + 1;
 }
 
+static noinline unsigned long kprobe_stacktrace_internal_target(void)
+{
+	if (!target_return_address[0])
+		target_return_address[0] = (unsigned long)__builtin_return_address(0);
+	return target_return_address[0];
+}
+
+static noinline unsigned long kprobe_stacktrace_target(void)
+{
+	if (!target_return_address[1])
+		target_return_address[1] = (unsigned long)__builtin_return_address(0);
+
+	if (internal_target)
+		internal_target();
+
+	return target_return_address[1];
+}
+
+static noinline unsigned long kprobe_stacktrace_driver(void)
+{
+	if (stacktrace_target)
+		stacktrace_target();
+
+	/* This is for preventing inlining the function */
+	return (unsigned long)__builtin_return_address(0);
+}
+
 static int kp_pre_handler2(struct kprobe *p, struct pt_regs *regs)
 {
 	preh_val = (rand1 / div_factor) + 1;
@@ -175,12 +207,138 @@ static void test_kretprobes(struct kunit *test)
 	KUNIT_EXPECT_EQ(test, krph_val, rand1);
 	unregister_kretprobes(rps, 2);
 }
+
+#ifdef CONFIG_ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
+#define STACK_BUF_SIZE 16
+static unsigned long stack_buf[STACK_BUF_SIZE];
+
+static int stacktrace_return_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
+{
+	unsigned long retval = regs_return_value(regs);
+	int i, ret;
+
+	KUNIT_EXPECT_FALSE(current_test, preemptible());
+	KUNIT_EXPECT_EQ(current_test, retval, target_return_address[1]);
+
+	/*
+	 * Test stacktrace inside the kretprobe handler, this will involves
+	 * kretprobe trampoline, but must include correct return address
+	 * of the target function.
+	 */
+	ret = stack_trace_save(stack_buf, STACK_BUF_SIZE, 0);
+	KUNIT_EXPECT_NE(current_test, ret, 0);
+
+	for (i = 0; i < ret; i++) {
+		if (stack_buf[i] == target_return_address[1])
+			break;
+	}
+	KUNIT_EXPECT_NE(current_test, i, ret);
+
+#if !IS_MODULE(CONFIG_KPROBES_SANITY_TEST)
+	/*
+	 * Test stacktrace from pt_regs at the return address. Thus the stack
+	 * trace must start from the target return address.
+	 */
+	ret = stack_trace_save_regs(regs, stack_buf, STACK_BUF_SIZE, 0);
+	KUNIT_EXPECT_NE(current_test, ret, 0);
+	KUNIT_EXPECT_EQ(current_test, stack_buf[0], target_return_address[1]);
+#endif
+
+	return 0;
+}
+
+static struct kretprobe rp3 = {
+	.handler	= stacktrace_return_handler,
+	.kp.symbol_name = "kprobe_stacktrace_target"
+};
+
+static void test_stacktrace_on_kretprobe(struct kunit *test)
+{
+	unsigned long myretaddr = (unsigned long)__builtin_return_address(0);
+
+	current_test = test;
+	rp3.kp.addr = NULL;
+	rp3.kp.flags = 0;
+
+	/*
+	 * Run the stacktrace_driver() to record correct return address in
+	 * stacktrace_target() and ensure stacktrace_driver() call is not
+	 * inlined by checking the return address of stacktrace_driver()
+	 * and the return address of this function is different.
+	 */
+	KUNIT_ASSERT_NE(test, myretaddr, stacktrace_driver());
+
+	KUNIT_ASSERT_EQ(test, 0, register_kretprobe(&rp3));
+	KUNIT_ASSERT_NE(test, myretaddr, stacktrace_driver());
+	unregister_kretprobe(&rp3);
+}
+
+static int stacktrace_internal_return_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
+{
+	unsigned long retval = regs_return_value(regs);
+	int i, ret;
+
+	KUNIT_EXPECT_FALSE(current_test, preemptible());
+	KUNIT_EXPECT_EQ(current_test, retval, target_return_address[0]);
+
+	/*
+	 * Test stacktrace inside the kretprobe handler for nested case.
+	 * The unwinder will find the kretprobe_trampoline address on the
+	 * return address, and kretprobe must solve that.
+	 */
+	ret = stack_trace_save(stack_buf, STACK_BUF_SIZE, 0);
+	KUNIT_EXPECT_NE(current_test, ret, 0);
+
+	for (i = 0; i < ret - 1; i++) {
+		if (stack_buf[i] == target_return_address[0]) {
+			KUNIT_EXPECT_EQ(current_test, stack_buf[i + 1], target_return_address[1]);
+			break;
+		}
+	}
+	KUNIT_EXPECT_NE(current_test, i, ret);
+
+#if !IS_MODULE(CONFIG_KPROBES_SANITY_TEST)
+	/* Ditto for the regs version. */
+	ret = stack_trace_save_regs(regs, stack_buf, STACK_BUF_SIZE, 0);
+	KUNIT_EXPECT_NE(current_test, ret, 0);
+	KUNIT_EXPECT_EQ(current_test, stack_buf[0], target_return_address[0]);
+	KUNIT_EXPECT_EQ(current_test, stack_buf[1], target_return_address[1]);
+#endif
+
+	return 0;
+}
+
+static struct kretprobe rp4 = {
+	.handler	= stacktrace_internal_return_handler,
+	.kp.symbol_name = "kprobe_stacktrace_internal_target"
+};
+
+static void test_stacktrace_on_nested_kretprobe(struct kunit *test)
+{
+	unsigned long myretaddr = (unsigned long)__builtin_return_address(0);
+	struct kretprobe *rps[2] = {&rp3, &rp4};
+
+	current_test = test;
+	rp3.kp.addr = NULL;
+	rp3.kp.flags = 0;
+
+	//KUNIT_ASSERT_NE(test, myretaddr, stacktrace_driver());
+
+	KUNIT_ASSERT_EQ(test, 0, register_kretprobes(rps, 2));
+	KUNIT_ASSERT_NE(test, myretaddr, stacktrace_driver());
+	unregister_kretprobes(rps, 2);
+}
+#endif /* CONFIG_ARCH_CORRECT_STACKTRACE_ON_KRETPROBE */
+
 #endif /* CONFIG_KRETPROBES */
 
 static int kprobes_test_init(struct kunit *test)
 {
 	target = kprobe_target;
 	target2 = kprobe_target2;
+	stacktrace_target = kprobe_stacktrace_target;
+	internal_target = kprobe_stacktrace_internal_target;
+	stacktrace_driver = kprobe_stacktrace_driver;
 
 	do {
 		rand1 = prandom_u32();
@@ -194,6 +352,10 @@ static struct kunit_case kprobes_testcases[] = {
 #ifdef CONFIG_KRETPROBES
 	KUNIT_CASE(test_kretprobe),
 	KUNIT_CASE(test_kretprobes),
+#ifdef CONFIG_ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
+	KUNIT_CASE(test_stacktrace_on_kretprobe),
+	KUNIT_CASE(test_stacktrace_on_nested_kretprobe),
+#endif
 #endif
 	{}
 };
-- 
2.33.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [for-next][PATCH 10/12] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
  2021-10-26 16:23 ` [for-next][PATCH 10/12] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link Steven Rostedt
@ 2021-10-27  8:58   ` Sergey Shtylyov
  2021-10-27 12:01     ` Steven Rostedt
  0 siblings, 1 reply; 15+ messages in thread
From: Sergey Shtylyov @ 2021-10-27  8:58 UTC (permalink / raw)
  To: Steven Rostedt, linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Yoshinori Sato, Rich Felker, linux-sh

On 26.10.2021 19:23, Steven Rostedt wrote:

> From: "linux-sh@vger.kernel.org" <linux-sh@vger.kernel.org>

    Collective author, really? :-)

> 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).
> 
> Link: https://lore.kernel.org/all/20200617165616.52241bde@oasis.local.home/
> 
> 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")
> 
> Link: https://lkml.kernel.org/r/20211021221627.5d7270de@rorschach.local.home
> 
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: linux-sh@vger.kernel.org
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
[...]

MBR, Sergey

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [for-next][PATCH 10/12] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
  2021-10-27  8:58   ` Sergey Shtylyov
@ 2021-10-27 12:01     ` Steven Rostedt
  0 siblings, 0 replies; 15+ messages in thread
From: Steven Rostedt @ 2021-10-27 12:01 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: linux-kernel, Ingo Molnar, Andrew Morton, Yoshinori Sato,
	Rich Felker, linux-sh

On Wed, 27 Oct 2021 11:58:31 +0300
Sergey Shtylyov <s.shtylyov@omp.ru> wrote:

> > From: "linux-sh@vger.kernel.org" <linux-sh@vger.kernel.org>  
> 
>     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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-10-27 12:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 16:23 [for-next][PATCH 00/12] tracing: More updates for 5.16 Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 01/12] ftrace: Make ftrace_profile_pages_init static Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 02/12] tools/latency-collector: Use correct size when writing queue_full_warning Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 03/12] perf/core: allow ftrace for functions in kernel/event/core.c Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 04/12] trace/osnoise: Fix an ifdef comment Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 05/12] tracing/doc: Fix typos on the timerlat tracer documentation Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 06/12] trace/osnoise: Add migrate-disabled field to the osnoise header Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 07/12] trace/timerlat: Add migrate-disabled field to the timerlat header Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 08/12] tracing: Fix missing trace_boot_init_histograms kstrdup NULL checks Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 09/12] tracing/hwlat: Make some internal symbols static Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 10/12] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link Steven Rostedt
2021-10-27  8:58   ` Sergey Shtylyov
2021-10-27 12:01     ` Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 11/12] lib/bootconfig: Make xbc_alloc_mem() and xbc_free_mem() as __init function Steven Rostedt
2021-10-26 16:23 ` [for-next][PATCH 12/12] kprobes: Add a test case for stacktrace from kretprobe handler Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.