Commit c7fbf8d9 authored by Andrii Nakryiko's avatar Andrii Nakryiko
Browse files

Merge branch 'x86-fgraph-bpf-fix-orc-stack-unwind-from-kprobe_multi'

Jiri Olsa says:

====================
x86/fgraph,bpf: Fix ORC stack unwind from kprobe_multi

hi,
Mahe reported missing function from stack trace on top of kprobe multi
program. It turned out the latest fix [1] needs some more fixing.

v2 changes:
- keep the unwind same as for kprobes, attached function
  is part of entry probe stacktrace, not kretprobe [Steven]
- several change in trigger bench [Andrii]
- added selftests for standard kprobes and fentry/fexit probes [Andrii]

Note I'll try to add similar stacktrace adjustment for fentry/fexit
in separate patchset to not complicate this change.

thanks,
jirka

[1] https://lore.kernel.org/bpf/20251104215405.168643-1-jolsa@kernel.org/
---
====================

Link: https://patch.msgid.link/20260126211837.472802-1-jolsa@kernel.org


Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
parents cd77618c 4173b494
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ arch_ftrace_get_regs(struct ftrace_regs *fregs)
}

#define arch_ftrace_partial_regs(regs) do {	\
	regs->flags &= ~X86_EFLAGS_FIXED;	\
	regs->flags |= X86_EFLAGS_FIXED;	\
	regs->cs = __KERNEL_CS;			\
} while (0)

+4 −1
Original line number Diff line number Diff line
@@ -364,6 +364,9 @@ SYM_CODE_START(return_to_handler)
	UNWIND_HINT_UNDEFINED
	ANNOTATE_NOENDBR

	/* Store original rsp for pt_regs.sp value. */
	movq %rsp, %rdi

	/* Restore return_to_handler value that got eaten by previous ret instruction. */
	subq $8, %rsp
	UNWIND_HINT_FUNC
@@ -374,7 +377,7 @@ SYM_CODE_START(return_to_handler)
	movq %rax, RAX(%rsp)
	movq %rdx, RDX(%rsp)
	movq %rbp, RBP(%rsp)
	movq %rsp, RSP(%rsp)
	movq %rdi, RSP(%rsp)
	movq %rsp, %rdi

	call ftrace_return_to_handler
+4 −0
Original line number Diff line number Diff line
@@ -265,6 +265,7 @@ static const struct argp_option opts[] = {
	{ "verbose", 'v', NULL, 0, "Verbose debug output"},
	{ "affinity", 'a', NULL, 0, "Set consumer/producer thread affinity"},
	{ "quiet", 'q', NULL, 0, "Be more quiet"},
	{ "stacktrace", 's', NULL, 0, "Get stack trace"},
	{ "prod-affinity", ARG_PROD_AFFINITY_SET, "CPUSET", 0,
	  "Set of CPUs for producer threads; implies --affinity"},
	{ "cons-affinity", ARG_CONS_AFFINITY_SET, "CPUSET", 0,
@@ -350,6 +351,9 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
	case 'q':
		env.quiet = true;
		break;
	case 's':
		env.stacktrace = true;
		break;
	case ARG_PROD_AFFINITY_SET:
		env.affinity = true;
		if (parse_num_list(arg, &env.prod_cpus.cpus,
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ struct env {
	bool list;
	bool affinity;
	bool quiet;
	bool stacktrace;
	int consumer_cnt;
	int producer_cnt;
	int nr_cpus;
+1 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ static void setup_ctx(void)
	bpf_program__set_autoload(ctx.skel->progs.trigger_driver, true);

	ctx.skel->rodata->batch_iters = args.batch_iters;
	ctx.skel->rodata->stacktrace = env.stacktrace;
}

static void load_ctx(void)
Loading