[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240215100254.2891c5da@gandalf.local.home>
Date: Thu, 15 Feb 2024 10:02:54 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Cc: Alexei Starovoitov <alexei.starovoitov@...il.com>, Florent Revest
<revest@...omium.org>, linux-trace-kernel@...r.kernel.org, LKML
<linux-kernel@...r.kernel.org>, Martin KaFai Lau <martin.lau@...ux.dev>,
bpf <bpf@...r.kernel.org>, Sven Schnelle <svens@...ux.ibm.com>, Alexei
Starovoitov <ast@...nel.org>, Jiri Olsa <jolsa@...nel.org>, Arnaldo
Carvalho de Melo <acme@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Alan Maguire <alan.maguire@...cle.com>, Mark Rutland
<mark.rutland@....com>, Peter Zijlstra <peterz@...radead.org>, Thomas
Gleixner <tglx@...utronix.de>, Guo Ren <guoren@...nel.org>
Subject: Re: [PATCH v7 21/36] function_graph: Add selftest for passing local
variables
On Wed, 7 Feb 2024 00:11:22 +0900
"Masami Hiramatsu (Google)" <mhiramat@...nel.org> wrote:
> From: Steven Rostedt (VMware) <rostedt@...dmis.org>
>
> Add boot up selftest that passes variables from a function entry to a
> function exit, and make sure that they do get passed around.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
> ---
> Changes in v2:
> - Add reserved size test.
> - Use pr_*() instead of printk(KERN_*).
> ---
> kernel/trace/trace_selftest.c | 169 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 169 insertions(+)
>
> diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
> index f0758afa2f7d..4d86cd4c8c8c 100644
> --- a/kernel/trace/trace_selftest.c
> +++ b/kernel/trace/trace_selftest.c
> @@ -756,6 +756,173 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
>
> +#ifdef CONFIG_DYNAMIC_FTRACE
> +
> +#define BYTE_NUMBER 123
> +#define SHORT_NUMBER 12345
> +#define WORD_NUMBER 1234567890
> +#define LONG_NUMBER 1234567890123456789LL
> +
> +static int fgraph_store_size __initdata;
> +static const char *fgraph_store_type_name __initdata;
> +static char *fgraph_error_str __initdata;
> +static char fgraph_error_str_buf[128] __initdata;
> +
> +static __init int store_entry(struct ftrace_graph_ent *trace,
> + struct fgraph_ops *gops)
> +{
> + const char *type = fgraph_store_type_name;
> + int size = fgraph_store_size;
> + void *p;
> +
> + p = fgraph_reserve_data(gops->idx, size);
> + if (!p) {
> + snprintf(fgraph_error_str_buf, sizeof(fgraph_error_str_buf),
> + "Failed to reserve %s\n", type);
> + fgraph_error_str = fgraph_error_str_buf;
> + return 0;
> + }
> +
> + switch (fgraph_store_size) {
> + case 1:
> + *(char *)p = BYTE_NUMBER;
> + break;
> + case 2:
> + *(short *)p = SHORT_NUMBER;
> + break;
> + case 4:
> + *(int *)p = WORD_NUMBER;
> + break;
> + case 8:
> + *(long long *)p = LONG_NUMBER;
> + break;
> + }
> +
What would be an interesting test is to run all versions together. That is,
to attach a callback that stores a byte, a callback that stores a short, a
callback that stores a word and a callback that stores a long, and attach
them all to the same function.
I guess we can add that as a separate patch.
-- Steve
> + return 1;
> +}
> +
Powered by blists - more mailing lists