* Re: [PATCH v2 1/2] fgraph: Use BTF to trim and filter return values
From: Donglin Peng @ 2025-12-09 1:42 UTC (permalink / raw)
To: Masami Hiramatsu
Cc: rostedt, linux-trace-kernel, linux-kernel, pengdonglin,
Xiaoqin Zhang
In-Reply-To: <20251209094810.fb53ac6296656d361754d593@kernel.org>
On Tue, Dec 9, 2025 at 8:48 AM Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> On Mon, 8 Dec 2025 21:19:16 +0800
> Donglin Peng <dolinux.peng@gmail.com> wrote:
>
> > From: pengdonglin <pengdonglin@xiaomi.com>
> >
> > The current funcgraph-retval implementation has two limitations:
> >
> > 1. It prints a return value even when the traced function returns void.
> > 2. When the return type is narrower than a register, the printed value may
> > be incorrect because high bits can contain undefined data.
> >
> > Both issues are addressed by using BTF to obtain the precise return type
> > of each traced function:
> >
> > - Return values are now printed only for functions whose return type is
> > not void.
> > - The value is truncated to the actual width of the return type, ensuring
> > correct representation.
> >
> > These changes make the funcgraph-retval output more accurate and remove
> > noise from void functions.
> >
> > Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
> > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com>
> > Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
> > ---
> > kernel/trace/trace_functions_graph.c | 64 +++++++++++++++++++++++-----
> > 1 file changed, 54 insertions(+), 10 deletions(-)
> >
> > diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
> > index 17c75cf2348e..9e63665c81e2 100644
> > --- a/kernel/trace/trace_functions_graph.c
> > +++ b/kernel/trace/trace_functions_graph.c
> > @@ -15,6 +15,7 @@
> >
> > #include "trace.h"
> > #include "trace_output.h"
> > +#include "trace_btf.h"
> >
> > /* When set, irq functions might be ignored */
> > static int ftrace_graph_skip_irqs;
> > @@ -865,6 +866,46 @@ static void print_graph_retaddr(struct trace_seq *s, struct fgraph_retaddr_ent_e
> >
> > #if defined(CONFIG_FUNCTION_GRAPH_RETVAL) || defined(CONFIG_FUNCTION_GRAPH_RETADDR)
> >
> > +static void trim_retval(unsigned long func, unsigned long *retval, bool *print_retval)
> > +{
> > + const struct btf_type *t;
> > + char name[KSYM_NAME_LEN];
> > + struct btf *btf;
> > + u32 v, msb;
> > +
> > + if (!IS_ENABLED(CONFIG_DEBUG_INFO_BTF))
> > + return;
> > +
> > + if (lookup_symbol_name(func, name))
> > + return;
> > +
> > + t = btf_find_func_proto(name, &btf);
> > + if (IS_ERR_OR_NULL(t))
> > + return;
> > +
> > + t = btf_type_skip_modifiers(btf, t->type, NULL);
> > + switch (t ? BTF_INFO_KIND(t->info) : BTF_KIND_UNKN) {
> > + case BTF_KIND_UNKN:
> > + *print_retval = false;
> > + break;
> > + case BTF_KIND_ENUM:
> > + case BTF_KIND_ENUM64:
> > + msb = BITS_PER_BYTE * t->size - 1;
> > + *retval &= GENMASK(msb, 0);
> > + break;
> > + case BTF_KIND_INT:
> > + v = *(u32 *)(t + 1);
> > + if (BTF_INT_ENCODING(v) == BTF_INT_BOOL)
> > + msb = 0;
> > + else
> > + msb = BTF_INT_BITS(v) - 1;
> > + *retval &= GENMASK(msb, 0);
> > + break;
> > + default:
> > + break;
> > + }
> > +}
>
> Hmm, I think we should have another flag which directly tells the print
> format of retval from BTF.
Thanks, I thought about it and the format flag could have the following values:
1. HEX - hexadecimal (%lx for pointers/unsigned)
2. DEC - decimal (%ld for signed/error_code)
3. BOOL - boolean strings ("true"/"false")
WDYT?
Thanks,
Donglin
>
> > +
> > static void print_graph_retval(struct trace_seq *s, struct ftrace_graph_ent_entry *entry,
> > struct ftrace_graph_ret *graph_ret, void *func,
> > u32 opt_flags, u32 trace_flags, int args_size)
> > @@ -884,17 +925,20 @@ static void print_graph_retval(struct trace_seq *s, struct ftrace_graph_ent_entr
> > print_retaddr = !!(opt_flags & TRACE_GRAPH_PRINT_RETADDR);
> > #endif
> >
> > - if (print_retval && retval && !hex_format) {
> > - /* Check if the return value matches the negative format */
> > - if (IS_ENABLED(CONFIG_64BIT) && (retval & BIT(31)) &&
> > - (((u64)retval) >> 32) == 0) {
> > - err_code = sign_extend64(retval, 31);
> > - } else {
> > - err_code = retval;
>
> The original code just guesses the type (signed/unsigned) from
> the retval, but we don't need to do that with BTF.
Thanks. I will fix it in the next version.
Thanks,
Donglin
>
> Thank you,
>
> > + if (print_retval) {
> > + trim_retval((unsigned long)func, &retval, &print_retval);
> > + if (print_retval && retval && !hex_format) {
> > + /* Check if the return value matches the negative format */
> > + if (IS_ENABLED(CONFIG_64BIT) && (retval & BIT(31)) &&
> > + (((u64)retval) >> 32) == 0) {
> > + err_code = sign_extend64(retval, 31);
> > + } else {
> > + err_code = retval;
> > + }
> > +
> > + if (!IS_ERR_VALUE(err_code))
> > + err_code = 0;
> > }
> > -
> > - if (!IS_ERR_VALUE(err_code))
> > - err_code = 0;
> > }
> >
> > if (entry) {
> > --
> > 2.34.1
> >
>
>
> --
> Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply
* Re: [PATCH v2 1/2] fgraph: Use BTF to trim and filter return values
From: Donglin Peng @ 2025-12-09 3:14 UTC (permalink / raw)
To: Masami Hiramatsu
Cc: rostedt, linux-trace-kernel, linux-kernel, pengdonglin,
Xiaoqin Zhang
In-Reply-To: <CAErzpms+qYntOEqbRtvVah_khBTG_ObU6keJyz8zbD9rF8BRLQ@mail.gmail.com>
On Tue, Dec 9, 2025 at 9:42 AM Donglin Peng <dolinux.peng@gmail.com> wrote:
>
> On Tue, Dec 9, 2025 at 8:48 AM Masami Hiramatsu <mhiramat@kernel.org> wrote:
> >
> > On Mon, 8 Dec 2025 21:19:16 +0800
> > Donglin Peng <dolinux.peng@gmail.com> wrote:
> >
> > > From: pengdonglin <pengdonglin@xiaomi.com>
> > >
> > > The current funcgraph-retval implementation has two limitations:
> > >
> > > 1. It prints a return value even when the traced function returns void.
> > > 2. When the return type is narrower than a register, the printed value may
> > > be incorrect because high bits can contain undefined data.
> > >
> > > Both issues are addressed by using BTF to obtain the precise return type
> > > of each traced function:
> > >
> > > - Return values are now printed only for functions whose return type is
> > > not void.
> > > - The value is truncated to the actual width of the return type, ensuring
> > > correct representation.
> > >
> > > These changes make the funcgraph-retval output more accurate and remove
> > > noise from void functions.
> > >
> > > Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
> > > Cc: Masami Hiramatsu <mhiramat@kernel.org>
> > > Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com>
> > > Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
> > > ---
> > > kernel/trace/trace_functions_graph.c | 64 +++++++++++++++++++++++-----
> > > 1 file changed, 54 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
> > > index 17c75cf2348e..9e63665c81e2 100644
> > > --- a/kernel/trace/trace_functions_graph.c
> > > +++ b/kernel/trace/trace_functions_graph.c
> > > @@ -15,6 +15,7 @@
> > >
> > > #include "trace.h"
> > > #include "trace_output.h"
> > > +#include "trace_btf.h"
> > >
> > > /* When set, irq functions might be ignored */
> > > static int ftrace_graph_skip_irqs;
> > > @@ -865,6 +866,46 @@ static void print_graph_retaddr(struct trace_seq *s, struct fgraph_retaddr_ent_e
> > >
> > > #if defined(CONFIG_FUNCTION_GRAPH_RETVAL) || defined(CONFIG_FUNCTION_GRAPH_RETADDR)
> > >
> > > +static void trim_retval(unsigned long func, unsigned long *retval, bool *print_retval)
> > > +{
> > > + const struct btf_type *t;
> > > + char name[KSYM_NAME_LEN];
> > > + struct btf *btf;
> > > + u32 v, msb;
> > > +
> > > + if (!IS_ENABLED(CONFIG_DEBUG_INFO_BTF))
> > > + return;
> > > +
> > > + if (lookup_symbol_name(func, name))
> > > + return;
> > > +
> > > + t = btf_find_func_proto(name, &btf);
> > > + if (IS_ERR_OR_NULL(t))
> > > + return;
> > > +
> > > + t = btf_type_skip_modifiers(btf, t->type, NULL);
> > > + switch (t ? BTF_INFO_KIND(t->info) : BTF_KIND_UNKN) {
> > > + case BTF_KIND_UNKN:
> > > + *print_retval = false;
> > > + break;
> > > + case BTF_KIND_ENUM:
> > > + case BTF_KIND_ENUM64:
> > > + msb = BITS_PER_BYTE * t->size - 1;
> > > + *retval &= GENMASK(msb, 0);
> > > + break;
> > > + case BTF_KIND_INT:
> > > + v = *(u32 *)(t + 1);
> > > + if (BTF_INT_ENCODING(v) == BTF_INT_BOOL)
> > > + msb = 0;
> > > + else
> > > + msb = BTF_INT_BITS(v) - 1;
> > > + *retval &= GENMASK(msb, 0);
> > > + break;
> > > + default:
> > > + break;
> > > + }
> > > +}
> >
> > Hmm, I think we should have another flag which directly tells the print
> > format of retval from BTF.
>
> Thanks, I thought about it and the format flag could have the following values:
>
> 1. HEX - hexadecimal (%lx for pointers/unsigned)
> 2. DEC - decimal (%ld for signed/error_code)
> 3. BOOL - boolean strings ("true"/"false")
>
> WDYT?
>
> Thanks,
> Donglin
> >
> > > +
> > > static void print_graph_retval(struct trace_seq *s, struct ftrace_graph_ent_entry *entry,
> > > struct ftrace_graph_ret *graph_ret, void *func,
> > > u32 opt_flags, u32 trace_flags, int args_size)
> > > @@ -884,17 +925,20 @@ static void print_graph_retval(struct trace_seq *s, struct ftrace_graph_ent_entr
> > > print_retaddr = !!(opt_flags & TRACE_GRAPH_PRINT_RETADDR);
> > > #endif
> > >
> > > - if (print_retval && retval && !hex_format) {
> > > - /* Check if the return value matches the negative format */
> > > - if (IS_ENABLED(CONFIG_64BIT) && (retval & BIT(31)) &&
> > > - (((u64)retval) >> 32) == 0) {
> > > - err_code = sign_extend64(retval, 31);
> > > - } else {
> > > - err_code = retval;
> >
> > The original code just guesses the type (signed/unsigned) from
> > the retval, but we don't need to do that with BTF.
Sorry, I think the above guessing process is necessary to display an error
code. In most cases, the return type is int, but retval is of size
sizeof(unsigned long).
We should perform sign extension to check whether it represents an error code.
Thanks,
Donglin
>
> Thanks. I will fix it in the next version.
>
> Thanks,
> Donglin
> >
> > Thank you,
> >
> > > + if (print_retval) {
> > > + trim_retval((unsigned long)func, &retval, &print_retval);
> > > + if (print_retval && retval && !hex_format) {
> > > + /* Check if the return value matches the negative format */
> > > + if (IS_ENABLED(CONFIG_64BIT) && (retval & BIT(31)) &&
> > > + (((u64)retval) >> 32) == 0) {
> > > + err_code = sign_extend64(retval, 31);
> > > + } else {
> > > + err_code = retval;
> > > + }
> > > +
> > > + if (!IS_ERR_VALUE(err_code))
> > > + err_code = 0;
> > > }
> > > -
> > > - if (!IS_ERR_VALUE(err_code))
> > > - err_code = 0;
> > > }
> > >
> > > if (entry) {
> > > --
> > > 2.34.1
> > >
> >
> >
> > --
> > Masami Hiramatsu (Google) <mhiramat@kernel.org>
^ permalink raw reply
* Re: [PATCH] btrfs: fix NULL dereference on root when tracing inode eviction
From: David Sterba @ 2025-12-09 3:32 UTC (permalink / raw)
To: Miquel Sabaté Solà
Cc: linux-btrfs, clm, dsterba, rostedt, mhiramat, mathieu.desnoyers,
linux-kernel, linux-trace-kernel, syzbot+d991fea1b4b23b1f6bf8
In-Reply-To: <20251021091125.259500-1-mssola@mssola.com>
On Tue, Oct 21, 2025 at 11:11:25AM +0200, Miquel Sabaté Solà wrote:
> When evicting an inode the first thing we do is to setup tracing for it,
> which implies fetching the root's id. But in btrfs_evict_inode() the
> root might be NULL, as implied in the next check that we do in
> btrfs_evict_inode().
>
> Hence, we either should set the ->root_objectid to 0 in case the root is
> NULL, or we move tracing setup after checking that the root is not
> NULL. Setting the rootid to 0 at least gives us the possibility to trace
> this call even in the case when the root is NULL, so that's the solution
> taken here.
>
> Fixes: 1abe9b8a138c ("Btrfs: add initial tracepoint support for btrfs")
> Reported-by: syzbot+d991fea1b4b23b1f6bf8@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=d991fea1b4b23b1f6bf8
> Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Added to for-next, thanks.
^ permalink raw reply
* Re: [PATCH v4 0/4] unwind_user: Cleanups
From: Jens Remus @ 2025-12-09 9:10 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, linux-trace-kernel, x86, Steven Rostedt,
Josh Poimboeuf, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Mathieu Desnoyers, Indu Bhagat,
Jose E. Marchesi, Heiko Carstens, Vasily Gorbik, Ilya Leoshkevich,
Linus Torvalds
In-Reply-To: <20251208193605.GG3707891@noisy.programming.kicks-ass.net>
Hello Peter!
On 12/8/2025 8:36 PM, Peter Zijlstra wrote:
> On Mon, Dec 08, 2025 at 05:03:48PM +0100, Jens Remus wrote:
>> Jens Remus (4):
>> unwind_user: Enhance comments on get CFA, FP, and RA
>> unwind_user/fp: Use dummies instead of ifdef
>> x86/unwind_user: Guard unwind_user_word_size() by UNWIND_USER
>> x86/unwind_user: Simplify unwind_user_word_size()
>>
>> arch/x86/include/asm/unwind_user.h | 27 ++++++++++++++-------------
>> include/linux/unwind_user.h | 18 ++++++++++++++++--
>> kernel/unwind/user.c | 12 ++++--------
>> 3 files changed, 34 insertions(+), 23 deletions(-)
>
> I'll go stick these patches in tip/perf/core after rc1 or so, no real
> hurry with these, right?
Perfect, that is fine with me.
Thanks and regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@de.ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
^ permalink raw reply
* Re: [PATCH v1 1/1] bpf: Mark BPF printing functions with __printf() attribute
From: Alexei Starovoitov @ 2025-12-09 9:12 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Alexei Starovoitov, bpf, LKML, linux-trace-kernel,
Daniel Borkmann, John Fastabend, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Matt Bobrowski,
Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Alan Maguire,
kernel test robot
In-Reply-To: <20251208161800.2902699-2-andriy.shevchenko@linux.intel.com>
On Tue, Dec 9, 2025 at 1:21 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> The printing functions in BPF code are using printf() type of format,
> and compiler is not happy about them as is:
>
> kernel/bpf/helpers.c:1069:9: error: function ‘____bpf_snprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> 1069 | err = bstr_printf(str, str_size, fmt, data.bin_args);
> | ^~~
>
> kernel/trace/bpf_trace.c:377:9: error: function ‘____bpf_trace_printk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> 377 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
> | ^~~
>
> kernel/trace/bpf_trace.c:433:9: error: function ‘____bpf_trace_vprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> 433 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
> | ^~~
>
> kernel/trace/bpf_trace.c:475:9: error: function ‘____bpf_seq_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> 475 | seq_bprintf(m, fmt, data.bin_args);
> | ^~~~~~~~~~~
>
> Fix the compilation errors by adding __printf() attribute. For that
> we need to pass it down to the BPF_CALL_x() and wrap into PRINTF_BPF_CALL_*()
> to make code neater.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202512061425.x0qTt9ww-lkp@intel.com/
> Closes: https://lore.kernel.org/oe-kbuild-all/202512061640.9hKTnB8p-lkp@intel.com/
> Closes: https://lore.kernel.org/oe-kbuild-all/202512081321.2h9ThWTg-lkp@intel.com/
> Fixes: 10aceb629e19 ("bpf: Add bpf_trace_vprintk helper")
> Fixes: 7b15523a989b ("bpf: Add a bpf_snprintf helper")
> Fixes: 492e639f0c22 ("bpf: Add bpf_seq_printf and bpf_seq_write helpers")
> Fixes: f3694e001238 ("bpf: add BPF_CALL_x macros for declaring helpers")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>
> This is combined change and I think there is no need to split it, but if required
> I can do it in a four changes. Note, the culprits are older than 4 years and stable
> kernels anyway don't go that deep nowadays.
This is pointless churn to shut up a warning.
Teach syzbot to stop this spam instead.
At the end this patch doesn't make any visible difference,
since user declarations of these helpers are auto generated
from uapi/bpf.h file and __printf attribute is not there.
pw-bot: cr
^ permalink raw reply
* [PATCH v2 1/8] tools/rtla: Add common_parse_options()
From: Costa Shulyupin @ 2025-12-09 10:00 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Costa Shulyupin, Crystal Wood,
Wander Lairson Costa, John Kacur, Ivan Pravdin,
linux-trace-kernel, linux-kernel
Each rtla tool duplicates parsing of many common options. This creates
maintenance overhead and risks inconsistencies when updating these
options.
Add common_parse_options() to centralize parsing of options used across
all tools.
Common options to be migrated in future patches.
Changes since v1:
- restore opterr
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
tools/tracing/rtla/src/common.c | 35 ++++++++++++++++++++++++++
tools/tracing/rtla/src/common.h | 1 +
tools/tracing/rtla/src/osnoise_hist.c | 3 +++
tools/tracing/rtla/src/osnoise_top.c | 3 +++
tools/tracing/rtla/src/timerlat_hist.c | 3 +++
tools/tracing/rtla/src/timerlat_top.c | 3 +++
6 files changed, 48 insertions(+)
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index b197037fc58b..a78f9883521e 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -5,6 +5,7 @@
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
+#include <getopt.h>
#include "common.h"
struct trace_instance *trace_inst;
@@ -37,6 +38,40 @@ static void set_signals(struct common_params *params)
}
}
+/*
+ * common_parse_options - parse common command line options
+ *
+ * @argc: argument count
+ * @argv: argument vector
+ * @common: common parameters structure
+ *
+ * Parse command line options that are common to all rtla tools.
+ *
+ * Returns: non zero if a common option was parsed, or 0
+ * if the option should be handled by tool-specific parsing.
+ */
+int common_parse_options(int argc, char **argv, struct common_params *common)
+{
+ int saved_state = optind;
+ int c;
+
+ static struct option long_options[] = {
+ {0, 0, 0, 0}
+ };
+
+ opterr = 0;
+ c = getopt_long(argc, argv, "", long_options, NULL);
+ opterr = 1;
+
+ switch (c) {
+ default:
+ optind = saved_state;
+ return 0;
+ }
+
+ return c;
+}
+
/*
* common_apply_config - apply common configs to the initialized tool
*/
diff --git a/tools/tracing/rtla/src/common.h b/tools/tracing/rtla/src/common.h
index 9ec2b7632c37..1066d777a823 100644
--- a/tools/tracing/rtla/src/common.h
+++ b/tools/tracing/rtla/src/common.h
@@ -153,6 +153,7 @@ struct osnoise_tool *osnoise_init_tool(char *tool_name);
struct osnoise_tool *osnoise_init_trace_tool(const char *tracer);
bool osnoise_trace_is_off(struct osnoise_tool *tool, struct osnoise_tool *record);
+int common_parse_options(int argc, char **argv, struct common_params *common);
int common_apply_config(struct osnoise_tool *tool, struct common_params *params);
int top_main_loop(struct osnoise_tool *tool);
int hist_main_loop(struct osnoise_tool *tool);
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index ff8c231e47c4..35f4a068af95 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -518,6 +518,9 @@ static struct common_params
{0, 0, 0, 0}
};
+ if (common_parse_options(argc, argv, ¶ms->common))
+ continue;
+
c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 04c699bdd736..550731c7addd 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -370,6 +370,9 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
{0, 0, 0, 0}
};
+ if (common_parse_options(argc, argv, ¶ms->common))
+ continue;
+
c = getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 1fb471a787b7..ffcfcabb9964 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -834,6 +834,9 @@ static struct common_params
{0, 0, 0, 0}
};
+ if (common_parse_options(argc, argv, ¶ms->common))
+ continue;
+
c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 29c2c1f717ed..d18d48671ccd 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -598,6 +598,9 @@ static struct common_params
{0, 0, 0, 0}
};
+ if (common_parse_options(argc, argv, ¶ms->common))
+ continue;
+
c = getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
--
2.52.0
^ permalink raw reply related
* [PATCH v2 2/8] tools/rtla: Consolidate -c/--cpus option parsing
From: Costa Shulyupin @ 2025-12-09 10:00 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Costa Shulyupin, Crystal Wood,
Wander Lairson Costa, John Kacur, Ivan Pravdin,
linux-trace-kernel, linux-kernel
In-Reply-To: <20251209100047.2692515-1-costa.shul@redhat.com>
Each rtla tool duplicates parsing of -c/--cpus.
Migrate the option parsing from individual tools to the
common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
tools/tracing/rtla/src/common.c | 8 +++++++-
tools/tracing/rtla/src/osnoise_hist.c | 9 +--------
tools/tracing/rtla/src/osnoise_top.c | 9 +--------
tools/tracing/rtla/src/timerlat_hist.c | 9 +--------
tools/tracing/rtla/src/timerlat_top.c | 9 +--------
5 files changed, 11 insertions(+), 33 deletions(-)
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index a78f9883521e..e5aa8c30cd7d 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -56,14 +56,20 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
int c;
static struct option long_options[] = {
+ {"cpus", required_argument, 0, 'c'},
{0, 0, 0, 0}
};
opterr = 0;
- c = getopt_long(argc, argv, "", long_options, NULL);
+ c = getopt_long(argc, argv, "c:", long_options, NULL);
opterr = 1;
switch (c) {
+ case 'c':
+ if (parse_cpu_set(optarg, &common->monitored_cpus))
+ fatal("Invalid -c cpu list");
+ common->cpus = optarg;
+ break;
default:
optind = saved_state;
return 0;
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 35f4a068af95..9e721362989a 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -491,7 +491,6 @@ static struct common_params
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
- {"cpus", required_argument, 0, 'c'},
{"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
@@ -521,7 +520,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:",
+ c = getopt_long(argc, argv, "a:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -547,12 +546,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'c':
- retval = parse_cpu_set(optarg, ¶ms->common.monitored_cpus);
- if (retval)
- fatal("Invalid -c cpu list");
- params->common.cpus = optarg;
- break;
case 'C':
params->common.cgroup = 1;
params->common.cgroup_name = parse_optional_arg(argc, argv);
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 550731c7addd..73736cefd992 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -346,7 +346,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"cpus", required_argument, 0, 'c'},
{"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
@@ -373,7 +372,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+ c = getopt_long(argc, argv, "a:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
/* Detect the end of the options. */
@@ -392,12 +391,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (!trace_output)
trace_output = "osnoise_trace.txt";
- break;
- case 'c':
- retval = parse_cpu_set(optarg, ¶ms->common.monitored_cpus);
- if (retval)
- fatal("Invalid -c cpu list");
- params->common.cpus = optarg;
break;
case 'C':
params->common.cgroup = 1;
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index ffcfcabb9964..4ae77145adea 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -796,7 +796,6 @@ static struct common_params
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"cpus", required_argument, 0, 'c'},
{"cgroup", optional_argument, 0, 'C'},
{"bucket-size", required_argument, 0, 'b'},
{"debug", no_argument, 0, 'D'},
@@ -837,7 +836,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
+ c = getopt_long(argc, argv, "a:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
/* detect the end of the options. */
@@ -859,12 +858,6 @@ static struct common_params
if (!trace_output)
trace_output = "timerlat_trace.txt";
- break;
- case 'c':
- retval = parse_cpu_set(optarg, ¶ms->common.monitored_cpus);
- if (retval)
- fatal("Invalid -c cpu list");
- params->common.cpus = optarg;
break;
case 'C':
params->common.cgroup = 1;
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index d18d48671ccd..9774c26b27ff 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -566,7 +566,6 @@ static struct common_params
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"cpus", required_argument, 0, 'c'},
{"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
@@ -601,7 +600,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+ c = getopt_long(argc, argv, "a:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -638,12 +637,6 @@ static struct common_params
/* set aa_only to avoid parsing the trace */
params->common.aa_only = 1;
break;
- case 'c':
- retval = parse_cpu_set(optarg, ¶ms->common.monitored_cpus);
- if (retval)
- fatal("Invalid -c cpu list");
- params->common.cpus = optarg;
- break;
case 'C':
params->common.cgroup = 1;
params->common.cgroup_name = optarg;
--
2.52.0
^ permalink raw reply related
* [PATCH v2 3/8] tools/rtla: Consolidate -C/--cgroup option parsing
From: Costa Shulyupin @ 2025-12-09 10:00 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Costa Shulyupin, Crystal Wood,
Wander Lairson Costa, John Kacur, Ivan Pravdin,
linux-trace-kernel, linux-kernel
In-Reply-To: <20251209100047.2692515-1-costa.shul@redhat.com>
Each rtla tool duplicates parsing of -C/--cgroup.
Migrate the option parsing from individual tools to the
common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
tools/tracing/rtla/src/common.c | 7 ++++++-
tools/tracing/rtla/src/osnoise_hist.c | 7 +------
tools/tracing/rtla/src/osnoise_top.c | 7 +------
tools/tracing/rtla/src/timerlat_hist.c | 7 +------
tools/tracing/rtla/src/timerlat_top.c | 7 +------
5 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index e5aa8c30cd7d..33428fa77f9f 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -57,11 +57,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
static struct option long_options[] = {
{"cpus", required_argument, 0, 'c'},
+ {"cgroup", optional_argument, 0, 'C'},
{0, 0, 0, 0}
};
opterr = 0;
- c = getopt_long(argc, argv, "c:", long_options, NULL);
+ c = getopt_long(argc, argv, "c:C::", long_options, NULL);
opterr = 1;
switch (c) {
@@ -70,6 +71,10 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
fatal("Invalid -c cpu list");
common->cpus = optarg;
break;
+ case 'C':
+ common->cgroup = 1;
+ common->cgroup_name = parse_optional_arg(argc, argv);
+ break;
default:
optind = saved_state;
return 0;
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 9e721362989a..5cbe5e1f1b07 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -491,7 +491,6 @@ static struct common_params
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
- {"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
{"house-keeping", required_argument, 0, 'H'},
@@ -520,7 +519,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:",
+ c = getopt_long(argc, argv, "a:b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -546,10 +545,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'C':
- params->common.cgroup = 1;
- params->common.cgroup_name = parse_optional_arg(argc, argv);
- break;
case 'D':
config_debug = 1;
break;
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 73736cefd992..35db5b73c0d7 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -346,7 +346,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
@@ -372,7 +371,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+ c = getopt_long(argc, argv, "a:d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
/* Detect the end of the options. */
@@ -391,10 +390,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (!trace_output)
trace_output = "osnoise_trace.txt";
- break;
- case 'C':
- params->common.cgroup = 1;
- params->common.cgroup_name = parse_optional_arg(argc, argv);
break;
case 'D':
config_debug = 1;
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 4ae77145adea..9ecab2bb0f1e 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -796,7 +796,6 @@ static struct common_params
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"cgroup", optional_argument, 0, 'C'},
{"bucket-size", required_argument, 0, 'b'},
{"debug", no_argument, 0, 'D'},
{"entries", required_argument, 0, 'E'},
@@ -836,7 +835,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
+ c = getopt_long(argc, argv, "a:b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
/* detect the end of the options. */
@@ -858,10 +857,6 @@ static struct common_params
if (!trace_output)
trace_output = "timerlat_trace.txt";
- break;
- case 'C':
- params->common.cgroup = 1;
- params->common.cgroup_name = parse_optional_arg(argc, argv);
break;
case 'b':
params->common.hist.bucket_size = get_llong_from_str(optarg);
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 9774c26b27ff..6329c3a489aa 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -566,7 +566,6 @@ static struct common_params
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
@@ -600,7 +599,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+ c = getopt_long(argc, argv, "a:d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -637,10 +636,6 @@ static struct common_params
/* set aa_only to avoid parsing the trace */
params->common.aa_only = 1;
break;
- case 'C':
- params->common.cgroup = 1;
- params->common.cgroup_name = optarg;
- break;
case 'D':
config_debug = 1;
break;
--
2.52.0
^ permalink raw reply related
* [PATCH v2 4/8] tools/rtla: Consolidate -D/--debug option parsing
From: Costa Shulyupin @ 2025-12-09 10:00 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Costa Shulyupin, Crystal Wood,
Wander Lairson Costa, John Kacur, Ivan Pravdin,
linux-trace-kernel, linux-kernel
In-Reply-To: <20251209100047.2692515-1-costa.shul@redhat.com>
Each rtla tool duplicates parsing of -D/--debug.
Migrate the option parsing from individual tools to the
common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
tools/tracing/rtla/src/common.c | 6 +++++-
tools/tracing/rtla/src/osnoise_hist.c | 6 +-----
tools/tracing/rtla/src/osnoise_top.c | 6 +-----
tools/tracing/rtla/src/timerlat_hist.c | 6 +-----
tools/tracing/rtla/src/timerlat_top.c | 6 +-----
5 files changed, 9 insertions(+), 21 deletions(-)
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index 33428fa77f9f..5bf79a9bb152 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -58,11 +58,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
static struct option long_options[] = {
{"cpus", required_argument, 0, 'c'},
{"cgroup", optional_argument, 0, 'C'},
+ {"debug", no_argument, 0, 'D'},
{0, 0, 0, 0}
};
opterr = 0;
- c = getopt_long(argc, argv, "c:C::", long_options, NULL);
+ c = getopt_long(argc, argv, "c:C::D", long_options, NULL);
opterr = 1;
switch (c) {
@@ -75,6 +76,9 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
common->cgroup = 1;
common->cgroup_name = parse_optional_arg(argc, argv);
break;
+ case 'D':
+ config_debug = 1;
+ break;
default:
optind = saved_state;
return 0;
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 5cbe5e1f1b07..6902486fb144 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -491,7 +491,6 @@ static struct common_params
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
- {"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
@@ -519,7 +518,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:",
+ c = getopt_long(argc, argv, "a:b:d:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -545,9 +544,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'D':
- config_debug = 1;
- break;
case 'd':
params->common.duration = parse_seconds_duration(optarg);
if (!params->common.duration)
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 35db5b73c0d7..4a61fd50b990 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -346,7 +346,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
{"house-keeping", required_argument, 0, 'H'},
@@ -371,7 +370,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+ c = getopt_long(argc, argv, "a:d:e:hH:p:P:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
/* Detect the end of the options. */
@@ -390,9 +389,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (!trace_output)
trace_output = "osnoise_trace.txt";
- break;
- case 'D':
- config_debug = 1;
break;
case 'd':
params->common.duration = parse_seconds_duration(optarg);
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 9ecab2bb0f1e..97d20e272583 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -797,7 +797,6 @@ static struct common_params
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
- {"debug", no_argument, 0, 'D'},
{"entries", required_argument, 0, 'E'},
{"duration", required_argument, 0, 'd'},
{"house-keeping", required_argument, 0, 'H'},
@@ -835,7 +834,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
+ c = getopt_long(argc, argv, "a:b:d:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
/* detect the end of the options. */
@@ -864,9 +863,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'D':
- config_debug = 1;
- break;
case 'd':
params->common.duration = parse_seconds_duration(optarg);
if (!params->common.duration)
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 6329c3a489aa..96bca67d419f 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -566,7 +566,6 @@ static struct common_params
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
@@ -599,7 +598,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+ c = getopt_long(argc, argv, "a:d:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -636,9 +635,6 @@ static struct common_params
/* set aa_only to avoid parsing the trace */
params->common.aa_only = 1;
break;
- case 'D':
- config_debug = 1;
- break;
case 'd':
params->common.duration = parse_seconds_duration(optarg);
if (!params->common.duration)
--
2.52.0
^ permalink raw reply related
* [PATCH v2 5/8] tools/rtla: Consolidate -d/--duration option parsing
From: Costa Shulyupin @ 2025-12-09 10:00 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Costa Shulyupin, Crystal Wood,
Wander Lairson Costa, John Kacur, Ivan Pravdin,
linux-trace-kernel, linux-kernel
In-Reply-To: <20251209100047.2692515-1-costa.shul@redhat.com>
Each rtla tool duplicates parsing of -d/--duration.
Migrate the option parsing from individual tools to the
common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
tools/tracing/rtla/src/common.c | 8 +++++++-
tools/tracing/rtla/src/osnoise_hist.c | 8 +-------
tools/tracing/rtla/src/osnoise_top.c | 8 +-------
tools/tracing/rtla/src/timerlat_hist.c | 8 +-------
tools/tracing/rtla/src/timerlat_top.c | 8 +-------
5 files changed, 11 insertions(+), 29 deletions(-)
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index 5bf79a9bb152..e6ff011d2cd2 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -59,11 +59,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
{"cpus", required_argument, 0, 'c'},
{"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
+ {"duration", required_argument, 0, 'd'},
{0, 0, 0, 0}
};
opterr = 0;
- c = getopt_long(argc, argv, "c:C::D", long_options, NULL);
+ c = getopt_long(argc, argv, "c:C::Dd:", long_options, NULL);
opterr = 1;
switch (c) {
@@ -79,6 +80,11 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
case 'D':
config_debug = 1;
break;
+ case 'd':
+ common->duration = parse_seconds_duration(optarg);
+ if (!common->duration)
+ fatal("Invalid -d duration");
+ break;
default:
optind = saved_state;
return 0;
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 6902486fb144..1b79bfefc214 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -491,7 +491,6 @@ static struct common_params
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
- {"duration", required_argument, 0, 'd'},
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"period", required_argument, 0, 'p'},
@@ -518,7 +517,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:d:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
+ c = getopt_long(argc, argv, "a:b:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -544,11 +543,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'd':
- params->common.duration = parse_seconds_duration(optarg);
- if (!params->common.duration)
- fatal("Invalid -D duration");
- break;
case 'e':
tevent = trace_event_alloc(optarg);
if (!tevent)
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 4a61fd50b990..619c5bcf8f35 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -346,7 +346,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
@@ -370,7 +369,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:d:e:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+ c = getopt_long(argc, argv, "a:e:hH:p:P:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
/* Detect the end of the options. */
@@ -390,11 +389,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
trace_output = "osnoise_trace.txt";
break;
- case 'd':
- params->common.duration = parse_seconds_duration(optarg);
- if (!params->common.duration)
- fatal("Invalid -d duration");
- break;
case 'e':
tevent = trace_event_alloc(optarg);
if (!tevent)
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 97d20e272583..0a7e5dcce121 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -798,7 +798,6 @@ static struct common_params
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
- {"duration", required_argument, 0, 'd'},
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"irq", required_argument, 0, 'i'},
@@ -834,7 +833,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:d:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
+ c = getopt_long(argc, argv, "a:b:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
/* detect the end of the options. */
@@ -863,11 +862,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'd':
- params->common.duration = parse_seconds_duration(optarg);
- if (!params->common.duration)
- fatal("Invalid -D duration");
- break;
case 'e':
tevent = trace_event_alloc(optarg);
if (!tevent)
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 96bca67d419f..4340fbf3f879 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -566,7 +566,6 @@ static struct common_params
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
{"house-keeping", required_argument, 0, 'H'},
@@ -598,7 +597,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:d:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+ c = getopt_long(argc, argv, "a:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -635,11 +634,6 @@ static struct common_params
/* set aa_only to avoid parsing the trace */
params->common.aa_only = 1;
break;
- case 'd':
- params->common.duration = parse_seconds_duration(optarg);
- if (!params->common.duration)
- fatal("Invalid -d duration");
- break;
case 'e':
tevent = trace_event_alloc(optarg);
if (!tevent)
--
2.52.0
^ permalink raw reply related
* [PATCH v2 6/8] tools/rtla: Consolidate -e/--event option parsing
From: Costa Shulyupin @ 2025-12-09 10:00 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Costa Shulyupin, Crystal Wood,
Wander Lairson Costa, John Kacur, Ivan Pravdin,
linux-trace-kernel, linux-kernel
In-Reply-To: <20251209100047.2692515-1-costa.shul@redhat.com>
Each rtla tool duplicates parsing of -e/--event.
Migrate the option parsing from individual tools to the
common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
tools/tracing/rtla/src/common.c | 13 ++++++++++++-
tools/tracing/rtla/src/osnoise_hist.c | 14 +-------------
tools/tracing/rtla/src/osnoise_top.c | 14 +-------------
tools/tracing/rtla/src/timerlat_hist.c | 14 +-------------
tools/tracing/rtla/src/timerlat_top.c | 13 +------------
5 files changed, 16 insertions(+), 52 deletions(-)
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index e6ff011d2cd2..684ff49f0a4c 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -52,6 +52,7 @@ static void set_signals(struct common_params *params)
*/
int common_parse_options(int argc, char **argv, struct common_params *common)
{
+ struct trace_events *tevent;
int saved_state = optind;
int c;
@@ -60,11 +61,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
{"cgroup", optional_argument, 0, 'C'},
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
+ {"event", required_argument, 0, 'e'},
{0, 0, 0, 0}
};
opterr = 0;
- c = getopt_long(argc, argv, "c:C::Dd:", long_options, NULL);
+ c = getopt_long(argc, argv, "c:C::Dd:e:", long_options, NULL);
opterr = 1;
switch (c) {
@@ -85,6 +87,15 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
if (!common->duration)
fatal("Invalid -d duration");
break;
+ case 'e':
+ tevent = trace_event_alloc(optarg);
+ if (!tevent)
+ fatal("Error alloc trace event");
+
+ if (common->events)
+ tevent->next = common->events;
+ common->events = tevent;
+ break;
default:
optind = saved_state;
return 0;
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 1b79bfefc214..c4013f50e803 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -469,7 +469,6 @@ static struct common_params
*osnoise_hist_parse_args(int argc, char *argv[])
{
struct osnoise_params *params;
- struct trace_events *tevent;
int retval;
int c;
char *trace_output = NULL;
@@ -499,7 +498,6 @@ static struct common_params
{"stop", required_argument, 0, 's'},
{"stop-total", required_argument, 0, 'S'},
{"trace", optional_argument, 0, 't'},
- {"event", required_argument, 0, 'e'},
{"threshold", required_argument, 0, 'T'},
{"no-header", no_argument, 0, '0'},
{"no-summary", no_argument, 0, '1'},
@@ -517,7 +515,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
+ c = getopt_long(argc, argv, "a:b:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -543,16 +541,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'e':
- tevent = trace_event_alloc(optarg);
- if (!tevent)
- fatal("Error alloc trace event");
-
- if (params->common.events)
- tevent->next = params->common.events;
-
- params->common.events = tevent;
- break;
case 'E':
params->common.hist.entries = get_llong_from_str(optarg);
if (params->common.hist.entries < 10 ||
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 619c5bcf8f35..846d25ee4885 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -322,7 +322,6 @@ static void osnoise_top_usage(struct osnoise_params *params)
struct common_params *osnoise_top_parse_args(int argc, char **argv)
{
struct osnoise_params *params;
- struct trace_events *tevent;
int retval;
int c;
char *trace_output = NULL;
@@ -346,7 +345,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"event", required_argument, 0, 'e'},
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"period", required_argument, 0, 'p'},
@@ -369,7 +367,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:e:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+ c = getopt_long(argc, argv, "a:hH:p:P:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
/* Detect the end of the options. */
@@ -388,16 +386,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (!trace_output)
trace_output = "osnoise_trace.txt";
- break;
- case 'e':
- tevent = trace_event_alloc(optarg);
- if (!tevent)
- fatal("Error alloc trace event");
-
- if (params->common.events)
- tevent->next = params->common.events;
- params->common.events = tevent;
-
break;
case 'h':
case '?':
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 0a7e5dcce121..4744f84a452e 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -766,7 +766,6 @@ static struct common_params
*timerlat_hist_parse_args(int argc, char *argv[])
{
struct timerlat_params *params;
- struct trace_events *tevent;
int auto_thresh;
int retval;
int c;
@@ -810,7 +809,6 @@ static struct common_params
{"user-threads", no_argument, 0, 'u'},
{"kernel-threads", no_argument, 0, 'k'},
{"user-load", no_argument, 0, 'U'},
- {"event", required_argument, 0, 'e'},
{"no-irq", no_argument, 0, '0'},
{"no-thread", no_argument, 0, '1'},
{"no-header", no_argument, 0, '2'},
@@ -833,7 +831,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
+ c = getopt_long(argc, argv, "a:b:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
/* detect the end of the options. */
@@ -862,16 +860,6 @@ static struct common_params
params->common.hist.bucket_size >= 1000000)
fatal("Bucket size needs to be > 0 and <= 1000000");
break;
- case 'e':
- tevent = trace_event_alloc(optarg);
- if (!tevent)
- fatal("Error alloc trace event");
-
- if (params->common.events)
- tevent->next = params->common.events;
-
- params->common.events = tevent;
- break;
case 'E':
params->common.hist.entries = get_llong_from_str(optarg);
if (params->common.hist.entries < 10 ||
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 4340fbf3f879..b77e5b6550a1 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -538,7 +538,6 @@ static struct common_params
*timerlat_top_parse_args(int argc, char **argv)
{
struct timerlat_params *params;
- struct trace_events *tevent;
long long auto_thresh;
int retval;
int c;
@@ -566,7 +565,6 @@ static struct common_params
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"event", required_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
{"house-keeping", required_argument, 0, 'H'},
{"irq", required_argument, 0, 'i'},
@@ -597,7 +595,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+ c = getopt_long(argc, argv, "a:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -634,15 +632,6 @@ static struct common_params
/* set aa_only to avoid parsing the trace */
params->common.aa_only = 1;
break;
- case 'e':
- tevent = trace_event_alloc(optarg);
- if (!tevent)
- fatal("Error alloc trace event");
-
- if (params->common.events)
- tevent->next = params->common.events;
- params->common.events = tevent;
- break;
case 'h':
case '?':
timerlat_top_usage();
--
2.52.0
^ permalink raw reply related
* [PATCH v2 7/8] tools/rtla: Consolidate -P/--priority option parsing
From: Costa Shulyupin @ 2025-12-09 10:00 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Costa Shulyupin, Crystal Wood,
Wander Lairson Costa, John Kacur, Ivan Pravdin,
linux-trace-kernel, linux-kernel
In-Reply-To: <20251209100047.2692515-1-costa.shul@redhat.com>
Each rtla tool duplicates parsing of -P/--priority.
Migrate the option parsing from individual tools to the
common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
tools/tracing/rtla/src/common.c | 8 +++++++-
tools/tracing/rtla/src/osnoise_hist.c | 9 +--------
tools/tracing/rtla/src/osnoise_top.c | 9 +--------
tools/tracing/rtla/src/timerlat_hist.c | 9 +--------
tools/tracing/rtla/src/timerlat_top.c | 9 +--------
5 files changed, 11 insertions(+), 33 deletions(-)
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index 684ff49f0a4c..e042b2d9dbf5 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -62,11 +62,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
+ {"priority", required_argument, 0, 'P'},
{0, 0, 0, 0}
};
opterr = 0;
- c = getopt_long(argc, argv, "c:C::Dd:e:", long_options, NULL);
+ c = getopt_long(argc, argv, "c:C::Dd:e:P:", long_options, NULL);
opterr = 1;
switch (c) {
@@ -96,6 +97,11 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
tevent->next = common->events;
common->events = tevent;
break;
+ case 'P':
+ if (parse_prio(optarg, &common->sched_param) == -1)
+ fatal("Invalid -P priority");
+ common->set_sched = 1;
+ break;
default:
optind = saved_state;
return 0;
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index c4013f50e803..6ed5f5594960 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -493,7 +493,6 @@ static struct common_params
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"period", required_argument, 0, 'p'},
- {"priority", required_argument, 0, 'P'},
{"runtime", required_argument, 0, 'r'},
{"stop", required_argument, 0, 's'},
{"stop-total", required_argument, 0, 'S'},
@@ -515,7 +514,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
+ c = getopt_long(argc, argv, "a:b:E:hH:p:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -562,12 +561,6 @@ static struct common_params
if (params->period > 10000000)
fatal("Period longer than 10 s");
break;
- case 'P':
- retval = parse_prio(optarg, ¶ms->common.sched_param);
- if (retval == -1)
- fatal("Invalid -P priority");
- params->common.set_sched = 1;
- break;
case 'r':
params->runtime = get_llong_from_str(optarg);
if (params->runtime < 100)
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 846d25ee4885..d2dfad960440 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -348,7 +348,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
{"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"period", required_argument, 0, 'p'},
- {"priority", required_argument, 0, 'P'},
{"quiet", no_argument, 0, 'q'},
{"runtime", required_argument, 0, 'r'},
{"stop", required_argument, 0, 's'},
@@ -367,7 +366,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:hH:p:P:qr:s:S:t::T:0:1:2:3:",
+ c = getopt_long(argc, argv, "a:hH:p:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
/* Detect the end of the options. */
@@ -402,12 +401,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (params->period > 10000000)
fatal("Period longer than 10 s");
break;
- case 'P':
- retval = parse_prio(optarg, ¶ms->common.sched_param);
- if (retval == -1)
- fatal("Invalid -P priority");
- params->common.set_sched = 1;
- break;
case 'q':
params->common.quiet = 1;
break;
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index 4744f84a452e..e7ba083b5eb4 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -802,7 +802,6 @@ static struct common_params
{"irq", required_argument, 0, 'i'},
{"nano", no_argument, 0, 'n'},
{"period", required_argument, 0, 'p'},
- {"priority", required_argument, 0, 'P'},
{"stack", required_argument, 0, 's'},
{"thread", required_argument, 0, 'T'},
{"trace", optional_argument, 0, 't'},
@@ -831,7 +830,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
+ c = getopt_long(argc, argv, "a:b:E:hH:i:knp:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
/* detect the end of the options. */
@@ -890,12 +889,6 @@ static struct common_params
if (params->timerlat_period_us > 1000000)
fatal("Period longer than 1 s");
break;
- case 'P':
- retval = parse_prio(optarg, ¶ms->common.sched_param);
- if (retval == -1)
- fatal("Invalid -P priority");
- params->common.set_sched = 1;
- break;
case 's':
params->print_stack = get_llong_from_str(optarg);
break;
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index b77e5b6550a1..8250bea4b2fd 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -570,7 +570,6 @@ static struct common_params
{"irq", required_argument, 0, 'i'},
{"nano", no_argument, 0, 'n'},
{"period", required_argument, 0, 'p'},
- {"priority", required_argument, 0, 'P'},
{"quiet", no_argument, 0, 'q'},
{"stack", required_argument, 0, 's'},
{"thread", required_argument, 0, 'T'},
@@ -595,7 +594,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
+ c = getopt_long(argc, argv, "a:hH:i:knp:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -656,12 +655,6 @@ static struct common_params
if (params->timerlat_period_us > 1000000)
fatal("Period longer than 1 s");
break;
- case 'P':
- retval = parse_prio(optarg, ¶ms->common.sched_param);
- if (retval == -1)
- fatal("Invalid -P priority");
- params->common.set_sched = 1;
- break;
case 'q':
params->common.quiet = 1;
break;
--
2.52.0
^ permalink raw reply related
* [PATCH v2 8/8] tools/rtla: Consolidate -H/--house-keeping option parsing
From: Costa Shulyupin @ 2025-12-09 10:00 UTC (permalink / raw)
To: Steven Rostedt, Tomas Glozar, Costa Shulyupin, Crystal Wood,
Wander Lairson Costa, John Kacur, Ivan Pravdin,
linux-trace-kernel, linux-kernel
In-Reply-To: <20251209100047.2692515-1-costa.shul@redhat.com>
Each rtla tool duplicates parsing of -H/--house-keeping.
Migrate the option parsing from individual tools to the
common_parse_options().
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
tools/tracing/rtla/src/common.c | 8 +++++++-
tools/tracing/rtla/src/osnoise_hist.c | 9 +--------
tools/tracing/rtla/src/osnoise_top.c | 9 +--------
tools/tracing/rtla/src/timerlat_hist.c | 9 +--------
tools/tracing/rtla/src/timerlat_top.c | 9 +--------
5 files changed, 11 insertions(+), 33 deletions(-)
diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/common.c
index e042b2d9dbf5..8e90bb4a76f9 100644
--- a/tools/tracing/rtla/src/common.c
+++ b/tools/tracing/rtla/src/common.c
@@ -62,12 +62,13 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
{"debug", no_argument, 0, 'D'},
{"duration", required_argument, 0, 'd'},
{"event", required_argument, 0, 'e'},
+ {"house-keeping", required_argument, 0, 'H'},
{"priority", required_argument, 0, 'P'},
{0, 0, 0, 0}
};
opterr = 0;
- c = getopt_long(argc, argv, "c:C::Dd:e:P:", long_options, NULL);
+ c = getopt_long(argc, argv, "c:C::Dd:e:H:P:", long_options, NULL);
opterr = 1;
switch (c) {
@@ -97,6 +98,11 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
tevent->next = common->events;
common->events = tevent;
break;
+ case 'H':
+ common->hk_cpus = 1;
+ if (parse_cpu_set(optarg, &common->hk_cpu_set))
+ fatal("Error parsing house keeping CPUs");
+ break;
case 'P':
if (parse_prio(optarg, &common->sched_param) == -1)
fatal("Invalid -P priority");
diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
index 6ed5f5594960..1ebd3b48b2d3 100644
--- a/tools/tracing/rtla/src/osnoise_hist.c
+++ b/tools/tracing/rtla/src/osnoise_hist.c
@@ -490,7 +490,6 @@ static struct common_params
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
- {"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"period", required_argument, 0, 'p'},
{"runtime", required_argument, 0, 'r'},
@@ -514,7 +513,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:E:hH:p:r:s:S:t::T:01234:5:6:7:",
+ c = getopt_long(argc, argv, "a:b:E:hp:r:s:S:t::T:01234:5:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -550,12 +549,6 @@ static struct common_params
case '?':
osnoise_hist_usage();
break;
- case 'H':
- params->common.hk_cpus = 1;
- retval = parse_cpu_set(optarg, ¶ms->common.hk_cpu_set);
- if (retval)
- fatal("Error parsing house keeping CPUs");
- break;
case 'p':
params->period = get_llong_from_str(optarg);
if (params->period > 10000000)
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index d2dfad960440..02e5e6e18e8d 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -345,7 +345,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
- {"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"period", required_argument, 0, 'p'},
{"quiet", no_argument, 0, 'q'},
@@ -366,7 +365,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:hH:p:qr:s:S:t::T:0:1:2:3:",
+ c = getopt_long(argc, argv, "a:hp:qr:s:S:t::T:0:1:2:3:",
long_options, NULL);
/* Detect the end of the options. */
@@ -390,12 +389,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
case '?':
osnoise_top_usage(params);
break;
- case 'H':
- params->common.hk_cpus = 1;
- retval = parse_cpu_set(optarg, ¶ms->common.hk_cpu_set);
- if (retval)
- fatal("Error parsing house keeping CPUs");
- break;
case 'p':
params->period = get_llong_from_str(optarg);
if (params->period > 10000000)
diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
index e7ba083b5eb4..d1a6cf0c2e0d 100644
--- a/tools/tracing/rtla/src/timerlat_hist.c
+++ b/tools/tracing/rtla/src/timerlat_hist.c
@@ -797,7 +797,6 @@ static struct common_params
{"auto", required_argument, 0, 'a'},
{"bucket-size", required_argument, 0, 'b'},
{"entries", required_argument, 0, 'E'},
- {"house-keeping", required_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"irq", required_argument, 0, 'i'},
{"nano", no_argument, 0, 'n'},
@@ -830,7 +829,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:b:E:hH:i:knp:s:t::T:uU0123456:7:8:9\1\2:\3:",
+ c = getopt_long(argc, argv, "a:b:E:hi:knp:s:t::T:uU0123456:7:8:9\1\2:\3:",
long_options, NULL);
/* detect the end of the options. */
@@ -869,12 +868,6 @@ static struct common_params
case '?':
timerlat_hist_usage();
break;
- case 'H':
- params->common.hk_cpus = 1;
- retval = parse_cpu_set(optarg, ¶ms->common.hk_cpu_set);
- if (retval)
- fatal("Error parsing house keeping CPUs");
- break;
case 'i':
params->common.stop_us = get_llong_from_str(optarg);
break;
diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
index 8250bea4b2fd..12e3d8c6f850 100644
--- a/tools/tracing/rtla/src/timerlat_top.c
+++ b/tools/tracing/rtla/src/timerlat_top.c
@@ -566,7 +566,6 @@ static struct common_params
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
{"help", no_argument, 0, 'h'},
- {"house-keeping", required_argument, 0, 'H'},
{"irq", required_argument, 0, 'i'},
{"nano", no_argument, 0, 'n'},
{"period", required_argument, 0, 'p'},
@@ -594,7 +593,7 @@ static struct common_params
if (common_parse_options(argc, argv, ¶ms->common))
continue;
- c = getopt_long(argc, argv, "a:hH:i:knp:qs:t::T:uU0:1:2:345:6:7:",
+ c = getopt_long(argc, argv, "a:hi:knp:qs:t::T:uU0:1:2:345:6:7:",
long_options, NULL);
/* detect the end of the options. */
@@ -635,12 +634,6 @@ static struct common_params
case '?':
timerlat_top_usage();
break;
- case 'H':
- params->common.hk_cpus = 1;
- retval = parse_cpu_set(optarg, ¶ms->common.hk_cpu_set);
- if (retval)
- fatal("Error parsing house keeping CPUs");
- break;
case 'i':
params->common.stop_us = get_llong_from_str(optarg);
break;
--
2.52.0
^ permalink raw reply related
* [PATCH v3 0/2] Use BTF to trim return values
From: Donglin Peng @ 2025-12-09 12:13 UTC (permalink / raw)
To: rostedt; +Cc: mhiramat, linux-trace-kernel, bpf, linux-kernel, pengdonglin
From: pengdonglin <pengdonglin@xiaomi.com>
This patch series addresses two limitations of the funcgraph-retval feature:
1. Void-returning functions still print a return value, creating misleading
noise in the trace output.
2. For functions returning narrower types (e.g., char, short), the displayed
value can be incorrect because high bits of the register may contain
undefined data.
By leveraging BTF to obtain precise return type information, we now:
1. Void function filtering: Functions with void return type no longer
display any return value in the trace output, eliminating unnecessary
clutter.
2. Type-aware value formatting: The return value is now properly truncated to
match the actual width of the return type before being displayed.
Additionally, the value is formatted according to its type for better human
readability.
Here is an output comparison:
Before:
# perf ftrace -G vfs_read --graph-opts retval
...
1) | touch_atime() {
1) | atime_needs_update() {
1) 0.069 us | make_vfsuid(); /* ret=0x0 */
1) 0.067 us | make_vfsgid(); /* ret=0x0 */
1) | current_time() {
1) 0.197 us | ktime_get_coarse_real_ts64_mg(); /* ret=0x187f886aec3ed6f5 */
1) 0.352 us | } /* current_time ret=0x69380753 */
1) 0.792 us | } /* atime_needs_update ret=0x0 */
1) 0.937 us | } /* touch_atime ret=0x0 */
After:
# perf ftrace -G vfs_read --graph-opts retval
...
2) | touch_atime() {
2) | atime_needs_update() {
2) 0.070 us | make_vfsuid(); /* ret=0x0 */
2) 0.070 us | make_vfsgid(); /* ret=0x0 */
2) | current_time() {
2) 0.162 us | ktime_get_coarse_real_ts64_mg();
2) 0.312 us | } /* current_time ret=0x69380649(trunc) */
2) 0.753 us | } /* atime_needs_update ret=false */
2) 0.899 us | } /* touch_atime */
Note: enabling funcgraph-retval now adds overhead due to repeated btf_find_by_name_kind()
calls during trace output. A separate series [1] optimizes this function with
binary search (O(log n) vs current O(n)), which will greatly reduce the impact.
Here is a performance comparison:
1. Original funcgraph-retval:
# time cat trace | wc -l
101024
real 0m0.682s
user 0m0.000s
sys 0m0.695s
2. Enhanced funcgraph-retval:
# time cat trace | wc -l
99326
real 0m12.886s
user 0m0.010s
sys 0m12.680s
3. Enhanced funcgraph-retval + optimizined btf_find_by_name_kind:
# time cat trace | wc -l
102922
real 0m0.794s
user 0m0.000s
sys 0m0.810s
Changelog:
v3:
- Print the return value based on its type for human readability, thanks Masami
- Update documentation and cover letter
v2:
- Link: https://lore.kernel.org/all/20251208131917.2444620-1-dolinux.peng@gmail.com/
- Update the funcgraph-retval documentation
- Revise the cover letter
v1:
- Link: https://lore.kernel.org/all/20251207142742.229924-1-dolinux.peng@gmail.com/
[1] https://lore.kernel.org/all/20251208062353.1702672-1-dolinux.peng@gmail.com/
pengdonglin (2):
fgraph: Enhance funcgraph-retval with BTF-based type-aware output
tracing: Update funcgraph-retval documentation
Documentation/trace/ftrace.rst | 78 ++++++++++-------
kernel/trace/trace_functions_graph.c | 124 ++++++++++++++++++++++++---
2 files changed, 156 insertions(+), 46 deletions(-)
--
2.34.1
^ permalink raw reply
* [PATCH v3 1/2] fgraph: Enhance funcgraph-retval with BTF-based type-aware output
From: Donglin Peng @ 2025-12-09 12:13 UTC (permalink / raw)
To: rostedt
Cc: mhiramat, linux-trace-kernel, bpf, linux-kernel, pengdonglin,
Xiaoqin Zhang
In-Reply-To: <20251209121349.525641-1-dolinux.peng@gmail.com>
From: pengdonglin <pengdonglin@xiaomi.com>
The current funcgraph-retval implementation suffers from two accuracy
issues:
1. Void-returning functions still print a return value, creating
misleading noise in the trace output.
2. For functions returning narrower types (e.g., char, short), the
displayed value can be incorrect because high bits of the register
may contain undefined data.
This patch addresses both problems by leveraging BTF to obtain the exact
return type of each traced kernel function. The key changes are:
1. Void function filtering: Functions with void return type no longer
display any return value in the trace output, eliminating unnecessary
clutter.
2. Type-aware value formatting: The return value is now properly truncated
to match the actual width of the return type before being displayed.
Additionally, the value is formatted according to its type for better
human readability.
Here is an output comparison:
Before:
# perf ftrace -G vfs_read --graph-opts retval
...
1) | touch_atime() {
1) | atime_needs_update() {
1) 0.069 us | make_vfsuid(); /* ret=0x0 */
1) 0.067 us | make_vfsgid(); /* ret=0x0 */
1) | current_time() {
1) 0.197 us | ktime_get_coarse_real_ts64_mg(); /* ret=0x187f886aec3ed6f5 */
1) 0.352 us | } /* current_time ret=0x69380753 */
1) 0.792 us | } /* atime_needs_update ret=0x0 */
1) 0.937 us | } /* touch_atime ret=0x0 */
After:
# perf ftrace -G vfs_read --graph-opts retval
...
2) | touch_atime() {
2) | atime_needs_update() {
2) 0.070 us | make_vfsuid(); /* ret=0x0 */
2) 0.070 us | make_vfsgid(); /* ret=0x0 */
2) | current_time() {
2) 0.162 us | ktime_get_coarse_real_ts64_mg();
2) 0.312 us | } /* current_time ret=0x69380649(trunc) */
2) 0.753 us | } /* atime_needs_update ret=false */
2) 0.899 us | } /* touch_atime */
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com>
Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
---
kernel/trace/trace_functions_graph.c | 124 ++++++++++++++++++++++++---
1 file changed, 111 insertions(+), 13 deletions(-)
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 17c75cf2348e..46b66b1cfc16 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -15,6 +15,7 @@
#include "trace.h"
#include "trace_output.h"
+#include "trace_btf.h"
/* When set, irq functions might be ignored */
static int ftrace_graph_skip_irqs;
@@ -120,6 +121,13 @@ enum {
FLAGS_FILL_END = 3 << TRACE_GRAPH_PRINT_FILL_SHIFT,
};
+enum {
+ RETVAL_FMT_HEX = BIT(0),
+ RETVAL_FMT_DEC = BIT(1),
+ RETVAL_FMT_BOOL = BIT(2),
+ RETVAL_FMT_TRUNC = BIT(3),
+};
+
static void
print_graph_duration(struct trace_array *tr, unsigned long long duration,
struct trace_seq *s, u32 flags);
@@ -865,6 +873,73 @@ static void print_graph_retaddr(struct trace_seq *s, struct fgraph_retaddr_ent_e
#if defined(CONFIG_FUNCTION_GRAPH_RETVAL) || defined(CONFIG_FUNCTION_GRAPH_RETADDR)
+static void trim_retval(unsigned long func, unsigned long *retval, bool *print_retval,
+ int *fmt)
+{
+ const struct btf_type *t;
+ char name[KSYM_NAME_LEN];
+ struct btf *btf;
+ u32 v, msb;
+ int kind;
+
+ if (!IS_ENABLED(CONFIG_DEBUG_INFO_BTF))
+ return;
+
+ if (lookup_symbol_name(func, name))
+ return;
+
+ t = btf_find_func_proto(name, &btf);
+ if (IS_ERR_OR_NULL(t))
+ return;
+
+ t = btf_type_skip_modifiers(btf, t->type, NULL);
+ kind = t ? BTF_INFO_KIND(t->info) : BTF_KIND_UNKN;
+ switch (kind) {
+ case BTF_KIND_UNKN:
+ *print_retval = false;
+ break;
+ case BTF_KIND_STRUCT:
+ case BTF_KIND_UNION:
+ case BTF_KIND_ENUM:
+ case BTF_KIND_ENUM64:
+ if (kind == BTF_KIND_STRUCT || kind == BTF_KIND_UNION)
+ *fmt = RETVAL_FMT_HEX;
+ else
+ *fmt = RETVAL_FMT_DEC;
+
+ if (t->size > sizeof(unsigned long)) {
+ *fmt |= RETVAL_FMT_TRUNC;
+ } else {
+ msb = BITS_PER_BYTE * t->size - 1;
+ *retval &= GENMASK(msb, 0);
+ }
+ break;
+ case BTF_KIND_INT:
+ v = *(u32 *)(t + 1);
+ if (BTF_INT_ENCODING(v) == BTF_INT_BOOL) {
+ *fmt = RETVAL_FMT_BOOL;
+ msb = 0;
+ } else {
+ if (BTF_INT_ENCODING(v) == BTF_INT_SIGNED)
+ *fmt = RETVAL_FMT_DEC;
+ else
+ *fmt = RETVAL_FMT_HEX;
+
+ if (t->size > sizeof(unsigned long)) {
+ *fmt |= RETVAL_FMT_TRUNC;
+ msb = BITS_PER_LONG - 1;
+ } else {
+ msb = BTF_INT_BITS(v) - 1;
+ }
+ }
+ *retval &= GENMASK(msb, 0);
+ break;
+ default:
+ *fmt = RETVAL_FMT_HEX;
+ break;
+ }
+}
+
static void print_graph_retval(struct trace_seq *s, struct ftrace_graph_ent_entry *entry,
struct ftrace_graph_ret *graph_ret, void *func,
u32 opt_flags, u32 trace_flags, int args_size)
@@ -873,7 +948,7 @@ static void print_graph_retval(struct trace_seq *s, struct ftrace_graph_ent_entr
unsigned long retval = 0;
bool print_retaddr = false;
bool print_retval = false;
- bool hex_format = !!(opt_flags & TRACE_GRAPH_PRINT_RETVAL_HEX);
+ int retval_fmt = 0;
#ifdef CONFIG_FUNCTION_GRAPH_RETVAL
retval = graph_ret->retval;
@@ -884,17 +959,35 @@ static void print_graph_retval(struct trace_seq *s, struct ftrace_graph_ent_entr
print_retaddr = !!(opt_flags & TRACE_GRAPH_PRINT_RETADDR);
#endif
- if (print_retval && retval && !hex_format) {
- /* Check if the return value matches the negative format */
- if (IS_ENABLED(CONFIG_64BIT) && (retval & BIT(31)) &&
- (((u64)retval) >> 32) == 0) {
- err_code = sign_extend64(retval, 31);
- } else {
- err_code = retval;
+ if (print_retval) {
+ int fmt = RETVAL_FMT_HEX;
+
+ trim_retval((unsigned long)func, &retval, &print_retval, &fmt);
+ if (print_retval) {
+ if (opt_flags & TRACE_GRAPH_PRINT_RETVAL_HEX)
+ retval_fmt = RETVAL_FMT_HEX;
+
+ if (retval && retval_fmt != RETVAL_FMT_HEX) {
+ /* Check if the return value matches the negative format */
+ if (IS_ENABLED(CONFIG_64BIT) && (retval & BIT(31)) &&
+ (((u64)retval) >> 32) == 0) {
+ err_code = sign_extend64(retval, 31);
+ } else {
+ err_code = retval;
+ }
+
+ if (!IS_ERR_VALUE(err_code))
+ err_code = 0;
+ }
+
+ if (retval_fmt == RETVAL_FMT_HEX) {
+ retval_fmt |= (fmt & RETVAL_FMT_TRUNC);
+ } else {
+ if (err_code && fmt & RETVAL_FMT_HEX)
+ fmt = (fmt & ~RETVAL_FMT_HEX) | RETVAL_FMT_DEC;
+ retval_fmt = fmt;
+ }
}
-
- if (!IS_ERR_VALUE(err_code))
- err_code = 0;
}
if (entry) {
@@ -921,10 +1014,15 @@ static void print_graph_retval(struct trace_seq *s, struct ftrace_graph_ent_entr
trace_flags, false);
if (print_retval) {
- if (hex_format || (err_code == 0))
+ if (retval_fmt & RETVAL_FMT_HEX)
trace_seq_printf(s, " ret=0x%lx", retval);
+ else if (retval_fmt & RETVAL_FMT_BOOL)
+ trace_seq_printf(s, " ret=%s", retval ? "true" : "false");
else
- trace_seq_printf(s, " ret=%ld", err_code);
+ trace_seq_printf(s, " ret=%ld", err_code ?: retval);
+
+ if (retval_fmt & RETVAL_FMT_TRUNC)
+ trace_seq_printf(s, "(trunc)");
}
if (!entry || print_retval || print_retaddr)
--
2.34.1
^ permalink raw reply related
* [PATCH v3 2/2] tracing: Update funcgraph-retval documentation
From: Donglin Peng @ 2025-12-09 12:13 UTC (permalink / raw)
To: rostedt
Cc: mhiramat, linux-trace-kernel, bpf, linux-kernel, pengdonglin,
Xiaoqin Zhang
In-Reply-To: <20251209121349.525641-1-dolinux.peng@gmail.com>
From: pengdonglin <pengdonglin@xiaomi.com>
The existing documentation for funcgraph-retval is outdated and partially
incorrect, as it describes limitations that have now been resolved.
Recent changes (e.g., using BTF to obtain function return types) have
addressed key issues:
1. Return values are now printed only for non-void functions.
2. Values are trimmed to the correct width of the return type, avoiding
garbage data from high bits.
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Xiaoqin Zhang <zhangxiaoqin@xiaomi.com>
Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
---
Documentation/trace/ftrace.rst | 78 ++++++++++++++++++++--------------
1 file changed, 45 insertions(+), 33 deletions(-)
diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst
index d1f313a5f4ad..03c8c433c803 100644
--- a/Documentation/trace/ftrace.rst
+++ b/Documentation/trace/ftrace.rst
@@ -1454,6 +1454,10 @@ Options for function_graph tracer:
printed in hexadecimal format. By default, this option
is off.
+ funcgraph-retaddr
+ When set, the return address will always be printed.
+ By default, this option is off.
+
sleep-time
When running function graph tracer, to include
the time a task schedules out in its function.
@@ -2800,7 +2804,7 @@ It is default disabled.
0) 2.861 us | } /* putname() */
The return value of each traced function can be displayed after
-an equal sign "=". When encountering system call failures, it
+an equal sign "ret =". When encountering system call failures, it
can be very helpful to quickly locate the function that first
returns an error code.
@@ -2810,16 +2814,16 @@ returns an error code.
Example with funcgraph-retval::
1) | cgroup_migrate() {
- 1) 0.651 us | cgroup_migrate_add_task(); /* = 0xffff93fcfd346c00 */
+ 1) 0.651 us | cgroup_migrate_add_task(); /* ret=0xffff93fcfd346c00 */
1) | cgroup_migrate_execute() {
1) | cpu_cgroup_can_attach() {
1) | cgroup_taskset_first() {
- 1) 0.732 us | cgroup_taskset_next(); /* = 0xffff93fc8fb20000 */
- 1) 1.232 us | } /* cgroup_taskset_first = 0xffff93fc8fb20000 */
- 1) 0.380 us | sched_rt_can_attach(); /* = 0x0 */
- 1) 2.335 us | } /* cpu_cgroup_can_attach = -22 */
- 1) 4.369 us | } /* cgroup_migrate_execute = -22 */
- 1) 7.143 us | } /* cgroup_migrate = -22 */
+ 1) 0.732 us | cgroup_taskset_next(); /* ret=0xffff93fc8fb20000 */
+ 1) 1.232 us | } /* cgroup_taskset_first ret=0xffff93fc8fb20000 */
+ 1) 0.380 us | sched_rt_can_attach(); /* ret=0x0 */
+ 1) 2.335 us | } /* cpu_cgroup_can_attach ret=-22 */
+ 1) 4.369 us | } /* cgroup_migrate_execute ret=-22 */
+ 1) 7.143 us | } /* cgroup_migrate ret=-22 */
The above example shows that the function cpu_cgroup_can_attach
returned the error code -22 firstly, then we can read the code
@@ -2836,37 +2840,41 @@ printed in hexadecimal format.
Example with funcgraph-retval-hex::
1) | cgroup_migrate() {
- 1) 0.651 us | cgroup_migrate_add_task(); /* = 0xffff93fcfd346c00 */
+ 1) 0.651 us | cgroup_migrate_add_task(); /* ret=0xffff93fcfd346c00 */
1) | cgroup_migrate_execute() {
1) | cpu_cgroup_can_attach() {
1) | cgroup_taskset_first() {
- 1) 0.732 us | cgroup_taskset_next(); /* = 0xffff93fc8fb20000 */
- 1) 1.232 us | } /* cgroup_taskset_first = 0xffff93fc8fb20000 */
- 1) 0.380 us | sched_rt_can_attach(); /* = 0x0 */
- 1) 2.335 us | } /* cpu_cgroup_can_attach = 0xffffffea */
- 1) 4.369 us | } /* cgroup_migrate_execute = 0xffffffea */
+ 1) 0.732 us | cgroup_taskset_next(); /* ret=0xffff93fc8fb20000 */
+ 1) 1.232 us | } /* cgroup_taskset_first ret=0xffff93fc8fb20000 */
+ 1) 0.380 us | sched_rt_can_attach(); /* ret=0x0 */
+ 1) 2.335 us | } /* cpu_cgroup_can_attach ret=0xffffffea */
+ 1) 4.369 us | } /* cgroup_migrate_execute ret=0xffffffea */
1) 7.143 us | } /* cgroup_migrate = 0xffffffea */
-At present, there are some limitations when using the funcgraph-retval
-option, and these limitations will be eliminated in the future:
+Note that there are some limitations when using the funcgraph-retval
+option:
+
+- If CONFIG_DEBUG_INFO_BTF is disabled (n), a return value is printed even for
+ functions with a void return type. When CONFIG_DEBUG_INFO_BTF is enabled (y),
+ the return value is printed only for non-void functions.
-- Even if the function return type is void, a return value will still
- be printed, and you can just ignore it.
+- If a return value occupies multiple registers, only the value in the first
+ register is recorded and printed. For example, on the x86 architecture, a
+ 64-bit return value is stored across eax (lower 32 bits) and edx (upper 32 bits),
+ but only the contents of eax are captured. If CONFIG_DEBUG_INFO_BTF is enabled,
+ the suffix "(trunc)" is appended to the printed value to indicate that the
+ output may be truncated because high-order register contents are omitted.
-- Even if return values are stored in multiple registers, only the
- value contained in the first register will be recorded and printed.
- To illustrate, in the x86 architecture, eax and edx are used to store
- a 64-bit return value, with the lower 32 bits saved in eax and the
- upper 32 bits saved in edx. However, only the value stored in eax
- will be recorded and printed.
+- Under certain procedure-call standards (e.g., arm64's AAPCS64), when the return
+ type is smaller than a general-purpose register (GPR), the caller is responsible
+ for narrowing the value; the upper bits of the register may contain undefined data.
+ For instance, when a u8 is returned in 64-bit GPR, bits [63:8] can hold arbitrary
+ values, especially when larger types are truncated (explicitly or implicitly). It
+ is therefore advisable to inspect the code in such cases. If CONFIG_DEBUG_INFO_BTF
+ is enabled (y), the return value is automatically trimmed to the width of the return
+ type.
-- In certain procedure call standards, such as arm64's AAPCS64, when a
- type is smaller than a GPR, it is the responsibility of the consumer
- to perform the narrowing, and the upper bits may contain UNKNOWN values.
- Therefore, it is advisable to check the code for such cases. For instance,
- when using a u8 in a 64-bit GPR, bits [63:8] may contain arbitrary values,
- especially when larger types are truncated, whether explicitly or implicitly.
- Here are some specific cases to illustrate this point:
+ The following examples illustrate the behavior:
**Case One**:
@@ -2885,7 +2893,9 @@ option, and these limitations will be eliminated in the future:
RET
If you pass 0x123456789abcdef to this function and want to narrow it,
- it may be recorded as 0x123456789abcdef instead of 0xef.
+ it may be recorded as 0x123456789abcdef instead of 0xef. When
+ CONFIG_DEBUG_INFO_BTF is enabled, the value will be correctly truncated
+ to 0xef based on the size constraints of the u8 type.
**Case Two**:
@@ -2910,7 +2920,9 @@ option, and these limitations will be eliminated in the future:
RET
When passing 0x2_0000_0000 to it, the return value may be recorded as
- 0x2_0000_0000 instead of 0.
+ 0x2_0000_0000 instead of 0. When CONFIG_DEBUG_INFO_BTF is enabled, the
+ value will be correctly truncated to 0 based on the size constraints of
+ the int type.
You can put some comments on specific functions by using
trace_printk() For example, if you want to put a comment inside
--
2.34.1
^ permalink raw reply related
* Re: [RFC LPC2025 PATCH 0/4] Deprecate zone_reclaim_mode
From: mawupeng @ 2025-12-09 12:43 UTC (permalink / raw)
To: joshua.hahnjy, willy, david
Cc: mawupeng1, linux-doc, linux-kernel, linux-mm, linux-trace-kernel,
linuxppc-dev, kernel-team
In-Reply-To: <20251205233217.3344186-1-joshua.hahnjy@gmail.com>
On 2025/12/6 7:32, Joshua Hahn wrote:
> Hello folks,
> This is a code RFC for my upcoming discussion at LPC 2025 in Tokyo [1].
>
> <preface>
> You might notice that the RFC that I'm sending out is different from the
> proposed abstract. Initially when I submitted my proposal, I was interested
> in addressing how fallback allocations work under pressure for
> NUMA-restricted allocations. Soon after, Johannes proposed a patch [2] which
> addressed the problem I was investigating, so I wanted to explore a different
> direction in the same area of fallback allocations.
>
> At the same time, I was also thinking about zone_reclaim_mode [3]. I thought
> that LPC would be a good opportunity to discuss deprecating zone_reclaim_mode,
> so I hope to discuss this topic at LPC during my presentation slot.
>
> Sorry for the patch submission so close to the conference as well. I thought
> it would still be better to send this RFC out late, instead of just presenting
> the topic at the conference without giving folks some time to think about it.
> </preface>
>
> zone_reclaim_mode was introduced in 2005 to prevent the kernel from facing
> the high remote access latency associated with NUMA systems. With it enabled,
> when the kernel sees that the local node is full, it will stall allocations and
> trigger direct reclaim locally, instead of making a remote allocation, even
> when there may still be free memory. Thsi is the preferred way to consume memory
> if remote memory access is more expensive than performing direct reclaim.
> The choice is made on a system-wide basis, but can be toggled at runtime.
>
> This series deprecates the zone_reclaim_mode sysctl in favor of other NUMA
> aware mechanisms, such as NUMA balancing, memory.reclaim, membind, and
> tiering / promotion / demotion. Let's break down what differences there are
> in these mechanisms, based on workload characteristics.
>
> Scenario 1) Workload fits in a single NUMA node
> In this case, if the rest of the NUMA node is unused, the zone_reclaim_mode
> does nothing. On the other hand, if there are several workloads competing
> for memory in the same NUMA node, with sum(workload_mem) > mem_capacity(node),
> then zone_reclaim_mode is actively harmful. Direct reclaim is aggressively
> triggered whenever one workload makes an allocation that goes over the limit,
> and there is no fairness mechanism to prevent one workload from completely
> blocking the other workload from making progress.
>
> Scenario 2) Workload does not fit in a single NUMA node
> Again, in this case, zone_reclaim_mode is actively harmful. Direct reclaim
> will constantly be triggered whenever memory goes above the limit, leading
> to memory thrashing. Moreover, even if the user really wants avoid remote
> allocations, membind is a better alternative in this case; zone_reclaim_mode
> forces the user to make the decision for all workloads on the system, whereas
> membind gives per-process granularity.
>
> Scenario 3) Workload size is approximately the same as the NUMA capacity
> This is probably the case for most workloads. When it is uncertain whether
> memory consumption will exceed the capacity, it doesn't really make a lot
> of sense to make a system-wide bet on whether direct reclaim is better or
> worse than remote allocations. In other words, it might make more sense to
> allow memory to spill over to remote nodes, and let the kernel handle the
> NUMA balancing depending on how cold or hot the newly allocated memory is.
>
> These examples might make it seem like zone_reclaim_mode is harmful for
> all scenarios. But that is not the case:
>
> Scenario 4) Newly allocated memory is going to be hot
> This is probably the scenario that makes zone_reclaim_mode shine the most.
> If the newly allocated memory is going to be hot, then it makes much more
> sense to try and reclaim locally, which would kick out cold(er) memory and
> prevent eating any remote memory access latency frequently.
>
> Scenario 5) Tiered NUMA system makes remote access latency higher
> In some tiered memory scenarios, remote access latency can be higher for
> lower memory tiers. In these scenarios, the cost of direct reclaim may be
> cheaper, relative to placing hot memory on a remote node with high access
> latency.
>
> Now, let me try and present a case for deprecating zone_reclaim_mode, despite
> these two scenarios where it performs as intended.
> In scenario 4, the catch is that the system is not an oracle that can predict
> that newly allocated memory is going to be hot. In fact, a lot of the kernel
> assumes that newly allocated memory is cold, and it has to "prove" that it
> is hot through accesses. In a perfect world, the kernel would be able to
> selectively trigger direct reclaim or allocate remotely, based on whehter the
> current allocation will be cold or hot in the future.
>
> But without these insights, it is difficult to make a system-wide bet and
> always trigger direct reclaim locally, when we might be reclaiming or
> evicting relatively hotter memory from the local node in order to make room.
>
> In scenario 5, remote access latency is higher, which means the cost of
> placing hot memory in remote nodes is higher. But today, we have many
> strategies that can help us overcome the higher cost of placing hot memory in
> remote nodes. If the system has tiered memory with different memory
> access characteristics per-node, then the user is probably already enabling
> promotion and demotion mechanisms that can quickly correct the placement of
> hot pages in lower tiers. In these systems, it might make more sense to allow
> the kernel to naturally consume all of the memory it can (whether it is local
> or on a lower tier remote node), then allow the kernel to then take corrective
> action based on what it finds as hot or cold memory.
>
> Of course, demonstrating that there are alternatives is not enough to warrant
> a deprecation. I think that the real benefit of this patch comes in reduced
> sysctl maintenance and what I think is much easier code to read.
>
> This series which has 466 deletions and 9 insertions:
> - Deprecates the zone_reclaim_mode sysctl (patch 4)
> - Deprecates the min_slab_ratio sysctl (patch 3)
> - Deprecates the min_unmapped_ratio sysctl (patch 3)
> - Removes the node_reclaim() function and simplifies the get_page_from_freelist
> watermark checks (which is already a very large function) (patch 2)
> - Simplifies hpage_collapse_scan_{pmd, file} (patch 1).
> - There are also more opportunities for future cleanup, like removing
> __node_reclaim and converting its last caller to use try_to_free_pages
> (suggested by Johannes Weiner)
>
> Here are some discussion points that I hope to discuss at LPC:
> - For workloads that are assumed to fit in a NUMA node, is membind really
> enough to achieve the same effect?
In real-world scenarios, we have observed on a dual-socket (2P) server with multiple
NUMA nodes—each having relatively limited local memory capacity—that page cache
negatively impacts overall performance. The zone_reclaim_node feature is used to
alleviate performance issues.
The main reason is that page cache consumes free memory on the local node, causing
processes without mbind restrictions to fall back to other nodes that still have free
memory. Accessing remote memory comes with a significant latency penalty. In extreme
testing, if a system is fully populated with page cache beforehand, Spark application
performance can drop by 80%. However, with zone_reclaim enabled, the performance
degradation is limited to only about 30%.
Furthermore, for typical HPC applications, memory pressure tends to be balanced
across NUMA nodes. Yet page cache is often generated by background tasks—such as
logging modules—which breaks memory locality and adversely affects overall performance.
At the same time, there are a large number of __GFP_THISNODE memory allocation requests in
the system. Anonymous pages that fall back from other nodes cannot be migrated or easily
reclaimed (especially when swap is disabled), leading to uneven distribution of available
memory within a single node. By enabling zone_reclaim_mode, the kernel preferentially reclaims
file pages within the local NUMA node to satisfy local anonymous-page allocations, which
effectively avoids warn_alloc problems caused by uneven distribution of anonymous pages.
In such scenarios, relying solely on mbind may offer limited flexibility.
We have also experimented with proactively waking kswapd to improve synchronous reclaim
efficiency. Our actual tests show that this can roughly double the memory allocation rate[1].
We could also discuss whether there are better solutions for such HPC scenarios.
[1]: https://lore.kernel.org/all/20251011062043.772549-1-mawupeng1@huawei.com/
> - Is NUMA balancing good enough to correct action when memory spills over to
> remote nodes, and end up being accessed frequently?
> - How widely is zone_reclaim_mode currently being used?
> - Are there usecases for zone_reclaim_mode that cannot be replaced by any
> of the mentioned alternatives?
> - Now that node_reclaim() is deprecated in patch 2, patch 3 deprecates
> min_slab_ratio and min_unmapped_ratio. Does this change make sense?
> IOW, should proactive reclaim via memory.reclaim still care about
> these thresholds before making a decision to reclaim?
> - If we agree that there are better alternatives to zone_reclaim_mode, how
> should we make the transition to deprecate it, along with the other
> sysctls that are deprecated in this series (min_{slab, unmapped}_ratio)?
>
> Please also note that I've excluded all individual email addresses for the
> Cc list. It was ~30 addresses, as I just wanted to avoid spamming
> maintainers and reviewers, so I've just left the mailing list targets.
> The individuals are Cc-ed in the relevant patches, though.
>
> Thank you everyone. I'm looking forward to discussing this idea with you all!
> Joshua
>
> [1] https://lpc.events/event/19/contributions/2142/
> [2] https://lore.kernel.org/linux-mm/20250919162134.1098208-1-hannes@cmpxchg.org/
> [3] https://lore.kernel.org/all/20250805205048.1518453-1-joshua.hahnjy@gmail.com/
>
> Joshua Hahn (4):
> mm/khugepaged: Remove hpage_collapse_scan_abort
> mm/vmscan/page_alloc: Remove node_reclaim
> mm/vmscan/page_alloc: Deprecate min_{slab, unmapped}_ratio
> mm/vmscan: Deprecate zone_reclaim_mode
>
> Documentation/admin-guide/sysctl/vm.rst | 78 ---------
> Documentation/mm/physical_memory.rst | 9 -
> .../translations/zh_CN/mm/physical_memory.rst | 8 -
> arch/powerpc/include/asm/topology.h | 4 -
> include/linux/mmzone.h | 8 -
> include/linux/swap.h | 5 -
> include/linux/topology.h | 6 -
> include/linux/vm_event_item.h | 4 -
> include/trace/events/huge_memory.h | 1 -
> include/uapi/linux/mempolicy.h | 14 --
> mm/internal.h | 22 ---
> mm/khugepaged.c | 34 ----
> mm/page_alloc.c | 120 +------------
> mm/vmscan.c | 158 +-----------------
> mm/vmstat.c | 4 -
> 15 files changed, 9 insertions(+), 466 deletions(-)
>
>
> base-commit: e4c4d9892021888be6d874ec1be307e80382f431
^ permalink raw reply
* Re: [PATCH v13 0/3] PCI: trace: Add a RAS tracepoint to monitor link speed changes
From: Shuai Xue @ 2025-12-09 13:19 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: tony.luck, bp, mhiramat, mathieu.desnoyers, oleg, naveen, davem,
anil.s.keshavamurthy, mark.rutland, peterz, tianruidong, rostedt,
lukas, linux-pci, linux-kernel, linux-edac, linux-trace-kernel,
helgaas, ilpo.jarvinen, mattc, Jonathan.Cameron
In-Reply-To: <1f9ee237-9d62-4c33-83c3-ce4d9ca9497f@linux.alibaba.com>
在 2025/11/4 17:34, Shuai Xue 写道:
>
>
> 在 2025/10/25 19:41, Shuai Xue 写道:
>> changes since v12:
>> - add Reviewed-by tag for PATCH 1 from Steve
>> - add Reviewed-by tag for PATCH 1-3 from Ilpo
>> - add comments for why use string to define tracepoint per Steve
>> - minor doc improvements from Ilpo
>> - remove use pci_speed_string to fix PCI dependends which cause build error on sparc64
>>
>> changes since v11:
>> - rebase to Linux 6.18-rc1 (no functional changes)
>>
>> changes since v10:
>> - explicitly include header file per Ilpo
>> - add comma on any non-terminator entry per Ilpo
>> - compile trace.o under CONFIG_TRACING per Ilpo
>>
>> changes since v9:
>> - add a documentation about PCI tracepoints per Bjorn
>> - create a dedicated drivers/pci/trace.c that always defines the PCI tracepoints per Steve
>> - move tracepoint callite into __pcie_update_link_speed() per Lukas and Bjorn
>>
>> changes since v8:
>> - rewrite commit log from Bjorn
>> - move pci_hp_event to a common place (include/trace/events/pci.h) per Ilpo
>> - rename hotplug event strings per Bjorn and Lukas
>> - add PCIe link tracepoint per Bjorn, Lukas, and Ilpo
>>
>> changes since v7:
>> - replace the TRACE_INCLUDE_PATH to avoid macro conflict per Steven
>> - pick up Reviewed-by from Lukas Wunner
>>
>> Hotplug events are critical indicators for analyzing hardware health, and
>> surprise link downs can significantly impact system performance and reliability.
>> In addition, PCIe link speed degradation directly impacts system performance and
>> often indicates hardware issues such as faulty devices, physical layer problems,
>> or configuration errors.
>>
>> This patch set add PCI hotplug and PCIe link tracepoint to help analyze PCI
>> hotplug events and PCIe link speed degradation.
>>
>> Shuai Xue (3):
>> PCI: trace: Add a generic RAS tracepoint for hotplug event
>> PCI: trace: Add a RAS tracepoint to monitor link speed changes
>> Documentation: tracing: Add documentation about PCI tracepoints
>>
>
> Hi, Bjorn,
>
> Gentle ping.
>
> Do you have any further concerns about this patch set?
>
> Shuai
Hi, all,
Gentle ping.
Thanks.
Shuai
^ permalink raw reply
* Re: [PATCH v1 1/1] bpf: Mark BPF printing functions with __printf() attribute
From: Andy Shevchenko @ 2025-12-09 13:37 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: Alexei Starovoitov, bpf, LKML, linux-trace-kernel,
Daniel Borkmann, John Fastabend, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Matt Bobrowski,
Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, Alan Maguire,
kernel test robot
In-Reply-To: <CAADnVQ+SXe-CsPHnYkB4SOKct6iMN=PkexaKRd-MJFhC3i8M0A@mail.gmail.com>
On Tue, Dec 09, 2025 at 06:12:46PM +0900, Alexei Starovoitov wrote:
> On Tue, Dec 9, 2025 at 1:21 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > The printing functions in BPF code are using printf() type of format,
> > and compiler is not happy about them as is:
> >
> > kernel/bpf/helpers.c:1069:9: error: function ‘____bpf_snprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> > 1069 | err = bstr_printf(str, str_size, fmt, data.bin_args);
> > | ^~~
> >
> > kernel/trace/bpf_trace.c:377:9: error: function ‘____bpf_trace_printk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> > 377 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
> > | ^~~
> >
> > kernel/trace/bpf_trace.c:433:9: error: function ‘____bpf_trace_vprintk’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> > 433 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
> > | ^~~
> >
> > kernel/trace/bpf_trace.c:475:9: error: function ‘____bpf_seq_printf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
> > 475 | seq_bprintf(m, fmt, data.bin_args);
> > | ^~~~~~~~~~~
> >
> > Fix the compilation errors by adding __printf() attribute. For that
> > we need to pass it down to the BPF_CALL_x() and wrap into PRINTF_BPF_CALL_*()
> > to make code neater.
> This is pointless churn to shut up a warning.
In some cases, like mine, it's an error.
> Teach syzbot to stop this spam instead.
It prevents to perform `make W=1` builds with the default CONFIG_WERROR,
which is 'y'.
> At the end this patch doesn't make any visible difference,
> since user declarations of these helpers are auto generated
> from uapi/bpf.h file and __printf attribute is not there.
I see, thanks for the review.
Any recommendations on how to fix this properly?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [External] : [PATCH v13 3/3] Documentation: tracing: Add documentation about PCI tracepoints
From: ALOK TIWARI @ 2025-12-09 13:59 UTC (permalink / raw)
To: Shuai Xue, rostedt, lukas, linux-pci, linux-kernel, linux-edac,
linux-trace-kernel, helgaas, ilpo.jarvinen, mattc,
Jonathan.Cameron
Cc: bhelgaas, tony.luck, bp, mhiramat, mathieu.desnoyers, oleg,
naveen, davem, anil.s.keshavamurthy, mark.rutland, peterz,
tianruidong
In-Reply-To: <20251025114158.71714-4-xueshuai@linux.alibaba.com>
On 10/25/2025 5:11 PM, Shuai Xue wrote:
> The PCI tracing system provides tracepoints to monitor critical hardware
> events that can impact system performance and reliability. Add
> documentation about it.
>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
> ---
> Documentation/trace/events-pci.rst | 74 ++++++++++++++++++++++++++++++
> 1 file changed, 74 insertions(+)
> create mode 100644 Documentation/trace/events-pci.rst
>
> diff --git a/Documentation/trace/events-pci.rst b/Documentation/trace/events-pci.rst
> new file mode 100644
> index 000000000000..88bd38fcc184
> --- /dev/null
> +++ b/Documentation/trace/events-pci.rst
> @@ -0,0 +1,74 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +===========================
> +Subsystem Trace Points: PCI
> +===========================
> +
> +Overview
> +========
> +The PCI tracing system provides tracepoints to monitor critical hardware events
> +that can impact system performance and reliability. These events normally show
> +up here:
> +
> + /sys/kernel/tracing/events/pci
> +
> +Cf. include/trace/events/pci.h for the events definitions.
> +
> +Available Tracepoints
> +=====================
> +
> +pci_hp_event
> +------------
> +
> +Monitors PCI hotplug events including card insertion/removal and link
> +state changes.
> +::
> +
> + pci_hp_event "%s slot:%s, event:%s\n"
> +
> +**Event Types**:
> +
> +* ``LINK_UP`` - PCIe link established
> +* ``LINK_DOWN`` - PCIe link lost
> +* ``CARD_PRESENT`` - Card detected in slot
> +* ``CARD_NOT_PRESENT`` - Card removed from slot
> +
> +**Example Usage**:
> +
> + # Enable the tracepoint
> + echo 1> /sys/kernel/debug/tracing/events/pci/pci_hp_event/enable
missing space echo 1 >"
> +
> + # Monitor events (the following output is generated when a device is hotplugged)
> + cat /sys/kernel/debug/tracing/trace_pipe
> + irq/51-pciehp-88 [001] ..... 1311.177459: pci_hp_event: 0000:00:02.0 slot:10, event:CARD_PRESENT
> +
> + irq/51-pciehp-88 [001] ..... 1311.177566: pci_hp_event: 0000:00:02.0 slot:10, event:LINK_UP
> +
> +pcie_link_event
> +---------------
> +
> +Monitors PCIe link speed changes and provides detailed link status information.
> +::
> +
> + pcie_link_event "%s type:%d, reason:%d, cur_bus_speed:%s, max_bus_speed:%s, width:%u, flit_mode:%u, status:%s\n"
%s -> %d mismatch for cur_bus_speed and max_bus_speed
TP_printk("%s type:%d, reason:%d, cur_bus_speed:%d, max_bus_speed:%d,
width:%u, flit_mode:%u, status:%s\n",
> +
> +**Parameters**:
> +
> +* ``type`` - PCIe device type (4=Root Port, etc.)
> +* ``reason`` - Reason for link change:
> +
> + - ``0`` - Link retrain
> + - ``1`` - Bus enumeration
> + - ``2`` - Bandwidth notification enable
> + - ``3`` - Bandwidth notification IRQ
> + - ``4`` - Hotplug event
> +
> +
> +**Example Usage**:
> +
> + # Enable the tracepoint
> + echo1 > /sys/kernel/debug/tracing/events/pci/pcie_link_event/enable
> +
> + # Monitor events (the following output is generated when a device is hotplugged)
> + cat /sys/kernel/debug/tracing/trace_pipe
> + irq/51-pciehp-88 [001] ..... 381.545386: pcie_link_event: 0000:00:02.0 type:4, reason:4, cur_bus_speed:20, max_bus_speed:23, width:1, flit_mode:0, status:DLLLA
Thanks,
Alok
^ permalink raw reply
* Re: [PATCH v3 1/4] kernel.h: drop STACK_MAGIC macro
From: Andi Shyti @ 2025-12-09 15:58 UTC (permalink / raw)
To: Yury Norov (NVIDIA)
Cc: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers,
Andy Shevchenko, Christophe Leroy, Randy Dunlap, Ingo Molnar,
Jani Nikula, Joonas Lahtinen, David Laight, Petr Pavlu,
Rodrigo Vivi, Tvrtko Ursulin, Daniel Gomez, Greg Kroah-Hartman,
Rafael J. Wysocki, Danilo Krummrich, Andrew Morton, linux-kernel,
intel-gfx, dri-devel, linux-modules, linux-trace-kernel,
Jani Nikula
In-Reply-To: <20251205175237.242022-2-yury.norov@gmail.com>
Hi Yuri,
On Fri, Dec 05, 2025 at 12:52:32PM -0500, Yury Norov (NVIDIA) wrote:
> The macro was introduced in 1994, v1.0.4, for stacks protection. Since
> that, people found better ways to protect stacks, and now the macro is
> only used by i915 selftests. Move it to a local header and drop from
> the kernel.h.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Acked-by: Randy Dunlap <rdunlap@infradead.org>
> Acked-by: Jani Nikula <jani.nikula@intel.com>
> Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Thanks,
Andi
^ permalink raw reply
* [PATCH v1] tracing: Avoid possible signed 64-bit truncation
From: Ian Rogers @ 2025-12-09 22:40 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers, linux-kernel,
linux-trace-kernel
Cc: Ian Rogers
64-bit truncation to 32-bit can result in the sign of the truncated
value changing. The cmp_mod_entry is used in bsearch and so the
truncation could result in an invalid search order. This would only
happen were the addresses more than 2GB apart and so unlikely, but
let's fix the potentially broken compare anyway.
Signed-off-by: Ian Rogers <irogers@google.com>
---
kernel/trace/trace.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d1e527cf2aae..e6a80cbe9326 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6057,8 +6057,10 @@ static int cmp_mod_entry(const void *key, const void *pivot)
if (addr >= ent[0].mod_addr && addr < ent[1].mod_addr)
return 0;
+ else if (addr > ent->mod_addr)
+ return 1;
else
- return addr - ent->mod_addr;
+ return -1;
}
/**
--
2.52.0.223.gf5cc29aaa4-goog
^ permalink raw reply related
* [syzbot] [block?] [trace?] INFO: task hung in relay_open (2)
From: syzbot @ 2025-12-09 23:04 UTC (permalink / raw)
To: axboe, linux-block, linux-kernel, linux-trace-kernel,
mathieu.desnoyers, mhiramat, rostedt, syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: 6987d58a9cbc Add linux-next specific files for 20251205
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=10bf76b4580000
kernel config: https://syzkaller.appspot.com/x/.config?x=a94030c847137a18
dashboard link: https://syzkaller.appspot.com/bug?extid=16ea22f26882d7e46f35
compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13c88992580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/59159f6ab772/disk-6987d58a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f1f1b2a92c01/vmlinux-6987d58a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/ff8485477cfd/bzImage-6987d58a.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+16ea22f26882d7e46f35@syzkaller.appspotmail.com
INFO: task syz.2.19:6056 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.2.19 state:D stack:25248 pid:6056 tgid:6055 ppid:5947 task_flags:0x400140 flags:0x00080002
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5256 [inline]
__schedule+0x14bc/0x5000 kernel/sched/core.c:6863
__schedule_loop kernel/sched/core.c:6945 [inline]
schedule+0x165/0x360 kernel/sched/core.c:6960
schedule_preempt_disabled+0x13/0x30 kernel/sched/core.c:7017
__mutex_lock_common kernel/locking/mutex.c:692 [inline]
__mutex_lock+0x7e6/0x1350 kernel/locking/mutex.c:776
relay_open+0x3b8/0x920 kernel/relay.c:517
blk_trace_setup_prepare+0x425/0x5a0 kernel/trace/blktrace.c:716
blk_trace_setup+0x244/0x3d0 kernel/trace/blktrace.c:789
blk_trace_ioctl+0x2f9/0x6e0 kernel/trace/blktrace.c:935
blkdev_ioctl+0x4a2/0x710 block/ioctl.c:780
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fea2af8f749
RSP: 002b:00007fea2bf0d038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fea2b1e5fa0 RCX: 00007fea2af8f749
RDX: 0000200000000240 RSI: 00000000c0481273 RDI: 0000000000000003
RBP: 00007fea2b013f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fea2b1e6038 R14: 00007fea2b1e5fa0 R15: 00007ffde1a3bc48
</TASK>
INFO: task syz.4.21:6058 blocked for more than 145 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.4.21 state:D stack:26184 pid:6058 tgid:6057 ppid:5957 task_flags:0x400140 flags:0x00080002
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5256 [inline]
__schedule+0x14bc/0x5000 kernel/sched/core.c:6863
__schedule_loop kernel/sched/core.c:6945 [inline]
schedule+0x165/0x360 kernel/sched/core.c:6960
schedule_preempt_disabled+0x13/0x30 kernel/sched/core.c:7017
__mutex_lock_common kernel/locking/mutex.c:692 [inline]
__mutex_lock+0x7e6/0x1350 kernel/locking/mutex.c:776
relay_open+0x3b8/0x920 kernel/relay.c:517
blk_trace_setup_prepare+0x425/0x5a0 kernel/trace/blktrace.c:716
blk_trace_setup+0x244/0x3d0 kernel/trace/blktrace.c:789
blk_trace_ioctl+0x2f9/0x6e0 kernel/trace/blktrace.c:935
blkdev_ioctl+0x4a2/0x710 block/ioctl.c:780
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f046d78f749
RSP: 002b:00007f046e673038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f046d9e5fa0 RCX: 00007f046d78f749
RDX: 0000200000000240 RSI: 00000000c0481273 RDI: 0000000000000003
RBP: 00007f046d813f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f046d9e6038 R14: 00007f046d9e5fa0 R15: 00007fffac8419a8
</TASK>
INFO: task syz.3.20:6060 blocked for more than 146 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.3.20 state:D stack:26776 pid:6060 tgid:6059 ppid:5954 task_flags:0x400140 flags:0x00080002
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5256 [inline]
__schedule+0x14bc/0x5000 kernel/sched/core.c:6863
__schedule_loop kernel/sched/core.c:6945 [inline]
schedule+0x165/0x360 kernel/sched/core.c:6960
schedule_preempt_disabled+0x13/0x30 kernel/sched/core.c:7017
__mutex_lock_common kernel/locking/mutex.c:692 [inline]
__mutex_lock+0x7e6/0x1350 kernel/locking/mutex.c:776
relay_open+0x3b8/0x920 kernel/relay.c:517
blk_trace_setup_prepare+0x425/0x5a0 kernel/trace/blktrace.c:716
blk_trace_setup+0x244/0x3d0 kernel/trace/blktrace.c:789
blk_trace_ioctl+0x2f9/0x6e0 kernel/trace/blktrace.c:935
blkdev_ioctl+0x4a2/0x710 block/ioctl.c:780
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xfa/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f92ec78f749
RSP: 002b:00007f92ed544038 EFLAGS: 00000246
ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f92ec9e5fa0 RCX: 00007f92ec78f749
RDX: 0000200000000240 RSI: 00000000c0481273 RDI: 0000000000000003
RBP: 00007f92ec813f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f92ec9e6038 R14: 00007f92ec9e5fa0 R15: 00007fffaeee7358
</TASK>
Showing all locks held in the system:
1 lock held by khungtaskd/31:
#0: ffffffff8df419e0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:331 [inline]
#0: ffffffff8df419e0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:867 [inline]
#0: ffffffff8df419e0 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x2e/0x180 kernel/locking/lockdep.c:6775
3 locks held by kworker/u8:7/1150:
#0: ffff88814c8c7948 ((wq_completion)ipv6_addrconf){+.+.}-{0:0}, at: process_one_work+0x841/0x15a0 kernel/workqueue.c:3236
#1: ffffc90003ddfb80 ((work_completion)(&(&ifa->dad_work)->work)){+.+.}-{0:0}, at: process_one_work+0x868/0x15a0 kernel/workqueue.c:3237
#2: ffffffff8f310348 (rtnl_mutex){+.+.}-{4:4}, at: rtnl_net_lock include/linux/rtnetlink.h:130 [inline]
#2: ffffffff8f310348 (rtnl_mutex){+.+.}-{4:4}, at: addrconf_dad_work+0x112/0x14b0 net/ipv6/addrconf.c:4194
2 locks held by klogd/5190:
3 locks held by udevd/5201:
2 locks held by dhcpcd/5495:
2 locks held by getty/5585:
#0: ffff88814c2ba0a0 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x25/0x70 drivers/tty/tty_ldisc.c:243
#1: ffffc9000332b2f0 (&ldata->atomic_read_lock){+.+.}-{4:4}, at: n_tty_read+0x449/0x1460 drivers/tty/n_tty.c:2211
3 locks held by syz-execprog/5825:
#0:
ffff88807d8b9bc0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_trylock include/linux/mmap_lock.h:410 [inline]
ffff88807d8b9bc0 (&mm->mmap_lock){++++}-{4:4}, at: get_mmap_lock_carefully mm/mmap_lock.c:390 [inline]
ffff88807d8b9bc0 (&mm->mmap_lock){++++}-{4:4}, at: lock_mm_and_find_vma+0x32/0x300 mm/mmap_lock.c:450
#1: ffff88807ec85280 (mapping.invalidate_lock#2){++++}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:1092 [inline]
#1: ffff88807ec85280 (mapping.invalidate_lock#2){++++}-{4:4}, at: filemap_fault+0x8ff/0x1290 mm/filemap.c:3556
#2: ffffffff8e04f820 (fs_reclaim){+.+.}-{0:0}, at: __perform_reclaim mm/page_alloc.c:4374 [inline]
#2: ffffffff8e04f820 (fs_reclaim){+.+.}-{0:0}, at: __alloc_pages_direct_reclaim+0xb8/0x300 mm/page_alloc.c:4399
6 locks held by syz-execprog/5826:
1 lock held by syz-execprog/5827:
#0: ffff88807ec85280 (mapping.invalidate_lock#2){++++}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:1092 [inline]
#0: ffff88807ec85280 (mapping.invalidate_lock#2){++++}-{4:4}, at: filemap_fault+0x8ff/0x1290 mm/filemap.c:3556
2 locks held by syz-executor/5834:
3 locks held by syz.1.18/6054:
2 locks held by syz.2.19/6056:
#0: ffff88814173d520 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
#1: ffffffff8df98a48 (relay_channels_mutex){+.+.}-{4:4}, at: relay_open+0x3b8/0x920 kernel/relay.c:517
2 locks held by syz.4.21/6058:
#0: ffff888140b91bf0 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
#1: ffffffff8df98a48 (relay_channels_mutex){+.+.}-{4:4}, at: relay_open+0x3b8/0x920 kernel/relay.c:517
2 locks held by syz.3.20/6060:
#0: ffff888140b908e0 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
#1: ffffffff8df98a48 (relay_channels_mutex){+.+.}-{4:4}, at: relay_open+0x3b8/0x920 kernel/relay.c:517
2 locks held by syz.6.23/6210:
#0: ffff888140b94210 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
#1: ffffffff8df98a48 (relay_channels_mutex){+.+.}-{4:4}, at: relay_open+0x3b8/0x920 kernel/relay.c:517
2 locks held by syz.5.22/6211:
#0: ffff888140b92f00
(&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
#1:
ffffffff8df98a48 (relay_channels_mutex){+.+.}-{4:4}, at: relay_open+0x3b8/0x920 kernel/relay.c:517
2 locks held by syz.9.26/6214:
#0: ffff888140b97b40 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
#1: ffffffff8df98a48 (relay_channels_mutex){+.+.}-{4:4}, at: relay_open+0x3b8/0x920 kernel/relay.c:517
2 locks held by syz.7.24/6216:
#0: ffff888140b95520 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
#1: ffffffff8df98a48 (relay_channels_mutex){+.+.}-{4:4}, at: relay_open+0x3b8/0x920 kernel/relay.c:517
2 locks held by syz.8.25/6218:
#0: ffff888140b96830 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
#1: ffffffff8df98a48 (relay_channels_mutex){+.+.}-{4:4}, at: relay_open+0x3b8/0x920 kernel/relay.c:517
2 locks held by syz.0.27/6323:
#0: ffff88814173af00 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
#1: ffffffff8df98a48 (relay_channels_mutex){+.+.}-{4:4}, at: relay_open+0x3b8/0x920 kernel/relay.c:517
1 lock held by syz.2.29/6335:
#0: ffff88814173d520 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
1 lock held by syz.1.28/6340:
#0: ffff88814173c210 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
1 lock held by syz.3.30/6342:
#0: ffff888140b908e0 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
1 lock held by syz.4.31/6344:
#0: ffff888140b91bf0 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
1 lock held by syz.6.32/6466:
#0: ffff888140b94210 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
1 lock held by syz.9.34/6490:
#0: ffff888140b97b40 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
1 lock held by syz.5.33/6494:
#0: ffff888140b92f00 (&q->debugfs_mutex){+.+.}-{4:4}, at: blk_trace_setup+0x21c/0x3d0 kernel/trace/blktrace.c:788
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply
* Re: PATCH] tracing: Fix unused tracepoints when module uses only exported ones
From: Steven Rostedt @ 2025-12-10 1:25 UTC (permalink / raw)
To: Mathieu Desnoyers
Cc: LKML, Linux trace kernel, Masami Hiramatsu, Masahiro Yamada
In-Reply-To: <3612840f-0c05-4797-8e75-872a306da45c@efficios.com>
On Mon, 8 Dec 2025 09:22:48 -0500
Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
> On 2025-12-08 08:53, Steven Rostedt wrote:
> > From: Steven Rostedt <rostedt@goodmis.org>
>
> Missing bracket for [PATCH] in subject.
>
> >
> > Building the KVM intel module failed to build with UT=1:
>
> failed -> fails (present ?)
After the patch is applied it will be in the past ;-)
>
> >
> > no __tracepoint_strings in file: arch/x86/kvm/kvm-intel.o
> > make[3]: *** [/work/git/test-linux.git/scripts/Makefile.modfinal:62: arch/x86/kvm/kvm-intel.ko] Error 1
> >
> > The reason is that the module only uses the tracepoints defined and
> > exported by the main kvm module. The tracepoint-udpate.c code fails the
>
> I guess you mean "tracepoint-update.c" ?
Oops
>
> > build if a tracepoint is used, but there's no tracepoints defined. But
>
> tracepoint
Actually, plural is fine here. Because it means one or more here.
>
> > this is acceptable in modules if the tracepoints is defined in the vmlinux
>
> tracepoint
Actually, it should stay plural (as it is more than one), but needs s/is/are/
>
> > proper or another module and exported.
> >
> > Do not fail to build if a tracepoint is used but no tracepoints are
>
> tracepoint .. is
>
Again, plural is OK here, but the other fixes can be done.
Although I see this right after I send a pull request to Linus, but
because I'm currently at the Maintainers Summit with Linus, and I don't
need to test this to fix it, I'll set up another pull request and tell
him to take the second one.
Thanks,
-- Steve
But, because it's just a change log fix and
^ permalink raw reply
* [PATCH v2] tracing: Fix unused tracepoints when module uses only exported ones
From: Steven Rostedt @ 2025-12-10 1:40 UTC (permalink / raw)
To: LKML, Linux trace kernel, Masami Hiramatsu, Mathieu Desnoyers,
Masahiro Yamada
From: Steven Rostedt <rostedt@goodmis.org>
Building the KVM intel module failed to build with UT=1:
no __tracepoint_strings in file: arch/x86/kvm/kvm-intel.o
make[3]: *** [/work/git/test-linux.git/scripts/Makefile.modfinal:62: arch/x86/kvm/kvm-intel.ko] Error 1
The reason is that the module only uses the tracepoints defined and
exported by the main kvm module. The tracepoint-update.c code fails the
build if a tracepoint is used, but there's no tracepoints defined. But
this is acceptable in modules if the tracepoints are defined in the vmlinux
proper or another module and exported.
Do not fail to build if a tracepoint is used but no tracepoints are
defined if the code is a module. This should still never happen for the
vmlinux itself.
Fixes: e30f8e61e2518 ("tracing: Add a tracepoint verification check at build time")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
Changes since v1: https://patch.msgid.link/20251208085336.6658743c@debian
- Just fixed the change log for grammar and spelling erros (Mathieu Desnoyers)
scripts/tracepoint-update.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/tracepoint-update.c b/scripts/tracepoint-update.c
index 7f7d90df14ce..90046aedc97b 100644
--- a/scripts/tracepoint-update.c
+++ b/scripts/tracepoint-update.c
@@ -210,6 +210,9 @@ static int process_tracepoints(bool mod, void *addr, const char *fname)
}
if (!tracepoint_data_sec) {
+ /* A module may reference only exported tracepoints */
+ if (mod)
+ return 0;
fprintf(stderr, "no __tracepoint_strings in file: %s\n", fname);
return -1;
}
--
2.51.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox