Re: [PATCH v2 00/11] unwind, perf: sframe user space unwinding, deferred perf callchains

From: Steven Rostedt
Date: Wed Oct 02 2024 - 22:30:43 EST


On Mon, 16 Sep 2024 17:39:53 +0200
Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:

> Completely untested patch here that I hacked up today:

I can tell it wasn't tested ;-)

>
> git://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git sframe-2.1
>
> To avoid races, unwind_user_deferred() can't be called from NMI. The
> tracers will need to trigger irq_work to call it.

diff --git a/kernel/unwind/user.c b/kernel/unwind/user.c
index 7edb0833fe46..c56cf5d564df 100644
--- a/kernel/unwind/user.c
+++ b/kernel/unwind/user.c
@@ -177,7 +181,8 @@ int unwind_user_deferred(struct unwind_callback *callback, u64 *ctx_cookie)

cookie = __this_cpu_read(ctx_ctr);
cookie &= ((1UL << 48) - 1);
- cookie |= ((cpu << 48) + 1);
+ cookie |= cpu << 48;
+ cookie++;
__this_cpu_write(ctx_ctr, cookie);

current->unwind_ctx_cookie = cookie;

As the cookie never got incremented.

That was just one issue. Things are still not working but I'll debug the
rest later.

-- Steve