Thread (27 messages) 27 messages, 4 authors, 2025-05-12

Re: [PATCH v8 15/18] perf: Have get_perf_callchain() return NULL if crosstask and user are set

From: Andrii Nakryiko <hidden>
Date: 2025-05-09 21:53:50
Also in: bpf, lkml

On Fri, May 9, 2025 at 9:52 AM Steven Rostedt [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Josh Poimboeuf <jpoimboe@kernel.org>

get_perf_callchain() doesn't support cross-task unwinding for user space
stacks, have it return NULL if both the crosstask and user arguments are
set.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/events/callchain.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index b0f5bd228cd8..abf258913ab6 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -224,6 +224,10 @@ get_perf_callchain(struct pt_regs *regs, bool kernel, bool user,
        struct perf_callchain_entry_ctx ctx;
        int rctx, start_entry_idx;

+       /* crosstask is not supported for user stacks */
+       if (crosstask && user)
+               return NULL;
I think get_perf_callchain() supports requesting both user and kernel
stack traces, and if it's crosstask, you can still get kernel (but not
user) stack, if I'm reading the code correctly.

So by just returning NULL early you will change this behavior, no?
quoted hunk ↗ jump to hunk
+
        entry = get_callchain_entry(&rctx);
        if (!entry)
                return NULL;
@@ -249,9 +253,6 @@ get_perf_callchain(struct pt_regs *regs, bool kernel, bool user,
                }

                if (regs) {
-                       if (crosstask)
-                               goto exit_put;
-
                        if (add_mark)
                                perf_callchain_store_context(&ctx, PERF_CONTEXT_USER);
@@ -261,7 +262,6 @@ get_perf_callchain(struct pt_regs *regs, bool kernel, bool user,
                }
        }

-exit_put:
        put_callchain_entry(rctx);

        return entry;
--
2.47.2

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help