[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZYGZWWqwtSP82Sja@krava>
Date: Tue, 19 Dec 2023 14:23:37 +0100
From: Jiri Olsa <olsajiri@...il.com>
To: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Cc: Alexei Starovoitov <alexei.starovoitov@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
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>,
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 v5 06/34] function_graph: Allow multiple users to attach
to function graph
On Mon, Dec 18, 2023 at 10:12:45PM +0900, Masami Hiramatsu (Google) wrote:
SNIP
> /* Both enabled by default (can be cleared by function_graph tracer flags */
> static bool fgraph_sleep_time = true;
>
> @@ -126,9 +247,34 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func,
> calltime = trace_clock_local();
>
> index = current->curr_ret_stack;
> - RET_STACK_INC(current->curr_ret_stack);
> + /* ret offset = 1 ; type = reserved */
> + current->ret_stack[index + FGRAPH_RET_INDEX] = 1;
> ret_stack = RET_STACK(current, index);
> + ret_stack->ret = ret;
> + /*
> + * The unwinders expect curr_ret_stack to point to either zero
> + * or an index where to find the next ret_stack. Even though the
> + * ret stack might be bogus, we want to write the ret and the
> + * index to find the ret_stack before we increment the stack point.
> + * If an interrupt comes in now before we increment the curr_ret_stack
> + * it may blow away what we wrote. But that's fine, because the
> + * index will still be correct (even though the 'ret' won't be).
> + * What we worry about is the index being correct after we increment
> + * the curr_ret_stack and before we update that index, as if an
> + * interrupt comes in and does an unwind stack dump, it will need
> + * at least a correct index!
> + */
> barrier();
> + current->curr_ret_stack += FGRAPH_RET_INDEX + 1;
> + /*
> + * This next barrier is to ensure that an interrupt coming in
> + * will not corrupt what we are about to write.
> + */
> + barrier();
> +
> + /* Still keep it reserved even if an interrupt came in */
> + current->ret_stack[index + FGRAPH_RET_INDEX] = 1;
seems like this was set already few lines above?
jirka
> +
> ret_stack->ret = ret;
> ret_stack->func = func;
> ret_stack->calltime = calltime;
> @@ -159,6 +305,12 @@ int function_graph_enter(unsigned long ret, unsigned long func,
> unsigned long frame_pointer, unsigned long *retp)
> {
> struct ftrace_graph_ent trace;
> + int offset;
> + int start;
> + int type;
> + int val;
> + int cnt = 0;
> + int i;
>
> #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
> /*
SNIP
Powered by blists - more mailing lists