bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: x86@kernel.org, Alexei Starovoitov <ast@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Song Liu <songliubraving@fb.com>, Kairui Song <kasong@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	David Laight <David.Laight@ACULAB.COM>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@kernel.org>
Subject: [PATCH v2 1/5] perf/x86: Always store regs->ip in perf_callchain_kernel()
Date: Fri, 14 Jun 2019 12:56:40 -0500	[thread overview]
Message-ID: <81b0cdc5aa276dac315a0536df384cc82da86243.1560534694.git.jpoimboe@redhat.com> (raw)
In-Reply-To: <cover.1560534694.git.jpoimboe@redhat.com>

From: Song Liu <songliubraving@fb.com>

The stacktrace_map_raw_tp BPF selftest is failing because the RIP saved
by perf_arch_fetch_caller_regs() isn't getting saved by
perf_callchain_kernel().

This was broken by the following commit:

  d15d356887e7 ("perf/x86: Make perf callchains work without CONFIG_FRAME_POINTER")

With that change, when starting with non-HW regs, the unwinder starts
with the current stack frame and unwinds until it passes up the frame
which called perf_arch_fetch_caller_regs().  So regs->ip needs to be
saved deliberately.

Fixes: d15d356887e7 ("perf/x86: Make perf callchains work without CONFIG_FRAME_POINTER")
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/events/core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index f0e4804515d8..6a7cfcadfc1e 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2328,13 +2328,13 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
 		return;
 	}
 
-	if (perf_hw_regs(regs)) {
-		if (perf_callchain_store(entry, regs->ip))
-			return;
+	if (perf_callchain_store(entry, regs->ip))
+		return;
+
+	if (perf_hw_regs(regs))
 		unwind_start(&state, current, regs, NULL);
-	} else {
+	else
 		unwind_start(&state, current, NULL, (void *)regs->sp);
-	}
 
 	for (; !unwind_done(&state); unwind_next_frame(&state)) {
 		addr = unwind_get_return_address(&state);
-- 
2.20.1


  reply	other threads:[~2019-06-14 18:01 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 17:56 [PATCH v2 0/5] x86/bpf: unwinder fixes Josh Poimboeuf
2019-06-14 17:56 ` Josh Poimboeuf [this message]
2019-06-14 20:56   ` [PATCH v2 1/5] perf/x86: Always store regs->ip in perf_callchain_kernel() Alexei Starovoitov
2019-06-14 21:06     ` Josh Poimboeuf
2019-06-14 21:16       ` Steven Rostedt
2019-06-14 21:20         ` Song Liu
2019-06-14 17:56 ` [PATCH v2 2/5] objtool: Fix ORC unwinding in non-JIT BPF generated code Josh Poimboeuf
2019-06-14 20:58   ` Alexei Starovoitov
2019-06-14 21:07     ` Josh Poimboeuf
2019-06-14 21:09       ` Alexei Starovoitov
2019-06-14 21:19         ` Josh Poimboeuf
2019-06-14 21:22           ` Alexei Starovoitov
2019-06-14 23:17             ` Josh Poimboeuf
2019-06-14 23:30               ` Alexei Starovoitov
2019-06-15  0:02                 ` Josh Poimboeuf
2019-06-15  0:06                   ` abhja kaanlani
2019-06-15  0:07                   ` Alexei Starovoitov
2019-06-17 14:57     ` David Laight
2019-06-14 17:56 ` [PATCH v2 3/5] x86/bpf: Move epilogue generation to a dedicated function Josh Poimboeuf
2019-06-14 17:56 ` [PATCH v2 4/5] x86/bpf: Fix 64-bit JIT frame pointer usage Josh Poimboeuf
2019-06-14 21:05   ` Alexei Starovoitov
2019-06-14 21:19     ` Josh Poimboeuf
2019-06-14 21:27       ` Alexei Starovoitov
2019-06-14 23:13         ` Josh Poimboeuf
2019-06-14 23:23           ` Alexei Starovoitov
2019-06-14 23:54             ` Josh Poimboeuf
2019-06-15  0:02               ` Alexei Starovoitov
2019-06-15  4:27                 ` Josh Poimboeuf
2019-06-15  5:16                   ` Alexei Starovoitov
2019-06-15 12:57                     ` Josh Poimboeuf
2019-06-14 17:56 ` [PATCH v2 5/5] x86/unwind/orc: Fall back to using frame pointers for generated code Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81b0cdc5aa276dac315a0536df384cc82da86243.1560534694.git.jpoimboe@redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=ast@kernel.org \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kasong@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).