mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH perf] perf: get_perf_callchain return NULL for crosstask
@ 2023-11-10 23:50 Jordan Rome
  2023-11-11  0:10 ` Andrii Nakryiko
  0 siblings, 1 reply; 5+ messages in thread
From: Jordan Rome @ 2023-11-10 23:50 UTC (permalink / raw)
  To: linux-perf-users
  Cc: bpf, linux-kernel, Andrii Nakryiko, Martin KaFai Lau,
	Kernel Team, Peter Zijlstra, Ingo Molnar, Song Liu

Return NULL instead of returning 1 incorrect frame, which
currently happens when trying to walk the user stack for
any task that isn't current. Returning NULL is a better
indicator that this behavior is not supported.

This issue was found using bpf_get_task_stack inside a BPF
iterator ("iter/task"), which iterates over all tasks. The
single address/frame in the buffer when getting user stacks
for tasks that aren't current could not be symbolized (testing
multiple symbolizers).

Signed-off-by: Jordan Rome <linux@jordanrome.com>
---
 kernel/events/callchain.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index 1273be84392c..430fa544fa80 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -201,6 +201,9 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
 	}
 
 	if (user) {
+		if (crosstask)
+			return NULL;
+
 		if (!user_mode(regs)) {
 			if  (current->mm)
 				regs = task_pt_regs(current);
@@ -209,9 +212,6 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
 		}
 
 		if (regs) {
-			if (crosstask)
-				goto exit_put;
-
 			if (add_mark)
 				perf_callchain_store_context(&ctx, PERF_CONTEXT_USER);
 
@@ -219,7 +219,6 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
 		}
 	}
 
-exit_put:
 	put_callchain_entry(rctx);
 
 	return entry;
-- 
2.39.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-11-11 11:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10 23:50 [PATCH perf] perf: get_perf_callchain return NULL for crosstask Jordan Rome
2023-11-11  0:10 ` Andrii Nakryiko
2023-11-11  0:42   ` Jordan Rome
2023-11-11  4:32     ` Andrii Nakryiko
2023-11-11 11:31       ` Jordan Rome

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®