From: Steven Rostedt <rostedt@goodmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH 2/2] fgraph: Free ret_stack when task is done with it
Date: Thu, 24 Oct 2024 21:05:15 -0400 [thread overview]
Message-ID: <20241024210515.53943bdf@rorschach.local.home> (raw)
In-Reply-To: <20241025002121.ef5dc8be87e1b6baa2dd544c@kernel.org>
On Fri, 25 Oct 2024 00:21:21 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:
> > +static void fgraph_ret_stack_work_func(struct work_struct *work)
> > +{
> > + mutex_lock(&ftrace_lock);
> > + if (!ftrace_graph_active)
> > + free_ret_stacks();
> > + mutex_unlock(&ftrace_lock);
> > +}
>
> Hmm, will you scan all tasks everytime? Shouldn't we have another global
> list of skipped tasks in remove_ret_stack(), like below?
>
> static void remove_ret_stack(struct task_struct *t, struct list_head *freelist, struct list_head *skiplist, int list_index)
> {
> struct ret_stack_free_data *free_data;
> struct list_head *head;
>
> /* If the ret_stack is still in use, skip this */
> if (t->curr_ret_depth >= 0)
> head = skiplist;
> else
> head = freelist;
>
> free_data = (struct ret_stack_free_data*)(t->ret_stack + list_index);
> list_add(&free_data->list, head);
> free_data->task = t;
> }
>
> Then we can scan only skiplist in free_ret_stacks() in fgraph_ret_stack_work_func().
>
> Of course this will need to decouple preparing freelist/skiplist and
> actual free function.
I thought about doing it this way, but I felt that it made the code
more complex with little benefit. Yeah, we scan all tasks, but it only
happens in a work queue that is grabbing the ftrace_lock mutex. If
anything, I rather keep it this way and if it ends up being an issue we
can change it later.
One thing Thomas always says is "correctness first, optimize later".
This is much easier to get correct. Adding a skip list will add
complexity. Like I said, nothing prevents us from adding that feature
later, and if it ends up buggy, we can know which change caused the bug.
-- Steve
next prev parent reply other threads:[~2024-10-25 1:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 9:27 [PATCH 0/2] fgraph: Free up function graph shadow stacks Steven Rostedt
2024-10-24 9:27 ` [PATCH 1/2] fgraph: Free ret_stacks when graph tracing is done Steven Rostedt
2024-10-24 15:00 ` Masami Hiramatsu
2024-10-25 1:00 ` Steven Rostedt
2024-10-24 9:27 ` [PATCH 2/2] fgraph: Free ret_stack when task is done with it Steven Rostedt
2024-10-24 15:21 ` Masami Hiramatsu
2024-10-25 1:05 ` Steven Rostedt [this message]
2024-10-25 3:31 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241024210515.53943bdf@rorschach.local.home \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox