Re: [RFC PATCH v7 01/10] trace: add lock-free stackmap for stack trace deduplication

From: Li Pengfei

Date: Sat Nov 07 2026 - 00:40:18 EST


From: Pengfei Li <lipengfei28@xxxxxxxxxx>

On Tue, 3 Nov 2026 17:49:05 -0500
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> Let's get rid of using rcu_tasks_rude. If RCU isn't watching, then we
> simply discard the stack trace. We do not want to add any more code that
> relies on it. If an architecture wants this feature, then it needs to
> update to not allow tracing without RCU watching.

OK. v8 checks rcu_is_watching() before it loads the map and only uses
synchronize_rcu() for reset and free. When RCU is not watching, the
stack is discarded.

> There's no reason to use a rw semaphore here. Just use a mutex. It's
> serializing the reads of the stackmaps from user space right? There's no
> reason to have more than one reader at a time.

Yes. v8 uses a mutex.

> Instead of duplicating the open coded free in ftrace_stackmap_create(),
> move this ftrace_stackmap_destroy() above that function and call it on fail.

Done in v8.

> The above paragraph is unnecessary here. If you want to add it to kernel
> docs where it is user visible, then fine. (I haven't looked yet if you
> already did).

The docs cover it, so the paragraph goes.

Thanks,
Pengfei Li