BPF Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] perf/x86: always include regs->ip in callchain
@ 2019-05-21 20:48 Song Liu
  2019-05-22 13:58 ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Song Liu @ 2019-05-21 20:48 UTC (permalink / raw)
  To: linux-kernel, bpf; +Cc: kernel-team, Song Liu, Kairui Song, Peter Zijlstra

Commit d15d356887e7 removes regs->ip for !perf_hw_regs(regs) case. This
breaks tests like test_stacktrace_map from selftests/bpf/tests_prog.

This patch adds regs->ip back.

Fixes: d15d356887e7 ("perf/x86: Make perf callchains work without CONFIG_FRAME_POINTER")
Cc: Kairui Song <kasong@redhat.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Song Liu <songliubraving@fb.com>
---
 arch/x86/events/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index f315425d8468..7b8a9eb4d5fd 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2402,9 +2402,9 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
 		return;
 	}
 
+	if (perf_callchain_store(entry, regs->ip))
+		return;
 	if (perf_hw_regs(regs)) {
-		if (perf_callchain_store(entry, regs->ip))
-			return;
 		unwind_start(&state, current, regs, NULL);
 	} else {
 		unwind_start(&state, current, NULL, (void *)regs->sp);
-- 
2.17.1


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

* Re: [PATCH] perf/x86: always include regs->ip in callchain
  2019-05-21 20:48 [PATCH] perf/x86: always include regs->ip in callchain Song Liu
@ 2019-05-22 13:58 ` Peter Zijlstra
  2019-05-22 16:12   ` Song Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2019-05-22 13:58 UTC (permalink / raw)
  To: Song Liu; +Cc: linux-kernel, bpf, kernel-team, Kairui Song, Josh Poimboeuf

On Tue, May 21, 2019 at 01:48:13PM -0700, Song Liu wrote:
> Commit d15d356887e7 removes regs->ip for !perf_hw_regs(regs) case. This
> breaks tests like test_stacktrace_map from selftests/bpf/tests_prog.

That test is broken by something else; just the one entry is wrong too.

That said, yes the patch below is actually correct, but the above
description is misleading at best.

> This patch adds regs->ip back.
> 
> Fixes: d15d356887e7 ("perf/x86: Make perf callchains work without CONFIG_FRAME_POINTER")
> Cc: Kairui Song <kasong@redhat.com>
> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Song Liu <songliubraving@fb.com>
> ---
>  arch/x86/events/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> index f315425d8468..7b8a9eb4d5fd 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -2402,9 +2402,9 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
>  		return;
>  	}
>  
> +	if (perf_callchain_store(entry, regs->ip))
> +		return;
>  	if (perf_hw_regs(regs)) {
> -		if (perf_callchain_store(entry, regs->ip))
> -			return;
>  		unwind_start(&state, current, regs, NULL);
>  	} else {
>  		unwind_start(&state, current, NULL, (void *)regs->sp);
> -- 
> 2.17.1
> 

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

* Re: [PATCH] perf/x86: always include regs->ip in callchain
  2019-05-22 13:58 ` Peter Zijlstra
@ 2019-05-22 16:12   ` Song Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Song Liu @ 2019-05-22 16:12 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, bpf, Kernel Team, Kairui Song, Josh Poimboeuf



> On May 22, 2019, at 6:58 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> 
> On Tue, May 21, 2019 at 01:48:13PM -0700, Song Liu wrote:
>> Commit d15d356887e7 removes regs->ip for !perf_hw_regs(regs) case. This
>> breaks tests like test_stacktrace_map from selftests/bpf/tests_prog.
> 
> That test is broken by something else; just the one entry is wrong too.
> 
> That said, yes the patch below is actually correct, but the above
> description is misleading at best.

How about we change it to: 

Commit d15d356887e7 removes regs->ip for !perf_hw_regs(regs) case. This
patch adds regs->ip back.


Shall I send v2 with the change? 

Thanks,
Song

> 
>> This patch adds regs->ip back.
>> 
>> Fixes: d15d356887e7 ("perf/x86: Make perf callchains work without CONFIG_FRAME_POINTER")
>> Cc: Kairui Song <kasong@redhat.com>
>> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
>> Signed-off-by: Song Liu <songliubraving@fb.com>
>> ---
>> arch/x86/events/core.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
>> index f315425d8468..7b8a9eb4d5fd 100644
>> --- a/arch/x86/events/core.c
>> +++ b/arch/x86/events/core.c
>> @@ -2402,9 +2402,9 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
>> 		return;
>> 	}
>> 
>> +	if (perf_callchain_store(entry, regs->ip))
>> +		return;
>> 	if (perf_hw_regs(regs)) {
>> -		if (perf_callchain_store(entry, regs->ip))
>> -			return;
>> 		unwind_start(&state, current, regs, NULL);
>> 	} else {
>> 		unwind_start(&state, current, NULL, (void *)regs->sp);
>> -- 
>> 2.17.1
>> 


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 20:48 [PATCH] perf/x86: always include regs->ip in callchain Song Liu
2019-05-22 13:58 ` Peter Zijlstra
2019-05-22 16:12   ` Song Liu

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
		bpf@vger.kernel.org bpf@archiver.kernel.org
	public-inbox-index bpf


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.bpf


AGPL code for this site: git clone https://public-inbox.org/ public-inbox