All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5] perf record: collect user registers set jointly with dwarf stacks
@ 2019-05-30 19:03 Alexey Budankov
  2019-05-30 19:41 ` Arnaldo Carvalho de Melo
  2019-06-17 18:58 ` [tip:perf/core] perf record: Allow mixing --user-regs with --call-graph=dwarf tip-bot for Alexey Budankov
  0 siblings, 2 replies; 7+ messages in thread
From: Alexey Budankov @ 2019-05-30 19:03 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Namhyung Kim, Alexander Shishkin, Peter Zijlstra,
	Ingo Molnar, Andi Kleen, linux-kernel


When dwarf stacks are collected jointly with user specified register
set using --user-regs option like below the full register context is
captured on a sample:

  $ perf record -g --call-graph dwarf,1024 --user-regs=IP,SP,BP -- stack_test2.g.O3

  188143843893585 0x6b48 [0x4f8]: PERF_RECORD_SAMPLE(IP, 0x4002): 23828/23828: 0x401236 period: 1363819 addr: 0x7ffedbdd51ac
  ... FP chain: nr:0
  ... user regs: mask 0xff0fff ABI 64-bit
  .... AX    0x53b
  .... BX    0x7ffedbdd3cc0
  .... CX    0xffffffff
  .... DX    0x33d3a
  .... SI    0x7f09b74c38d0
  .... DI    0x0
  .... BP    0x401260
  .... SP    0x7ffedbdd3cc0
  .... IP    0x401236
  .... FLAGS 0x20a
  .... CS    0x33
  .... SS    0x2b
  .... R8    0x7f09b74c3800
  .... R9    0x7f09b74c2da0
  .... R10   0xfffffffffffff3ce
  .... R11   0x246
  .... R12   0x401070
  .... R13   0x7ffedbdd5db0
  .... R14   0x0
  .... R15   0x0
  ... ustack: size 1024, offset 0xe0
   . data_src: 0x5080021
   ... thread: stack_test2.g.O:23828
   ...... dso: /root/abudanko/stacks/stack_test2.g.O3

After applying the change suggested in the patch the sample data contain
only user specified register values. IP and SP registers (DWARF_MINIMAL_REGS)
are collected anyways regardless of the --user-regs value provided from
the command line:

  -g call-graph dwarf,K                         full_regs
  --user-regs=user_regs                         user_regs
  -g call-graph dwarf,K --user-regs=user_regs	user_regs + DWARF_MINIMAL_REGS

  $ perf record -g --call-graph dwarf,1024 --user-regs=BP -- ls
  WARNING: The use of --call-graph=dwarf may require all the user registers, specifying a subset with --user-regs may render DWARF unwinding unreliable, so the minimal registers set (IP, SP) is explicitly forced.
  arch   COPYING	Documentation  include	Kbuild	 lbuild    MAINTAINERS	modules.builtin		 Module.symvers  perf.data.old	scripts   System.map  virt
  block  CREDITS	drivers        init	Kconfig  lib	   Makefile	modules.builtin.modinfo  net		 README		security  tools       vmlinux
  certs  crypto	fs	       ipc	kernel	 LICENSES  mm		modules.order		 perf.data	 samples	sound	  usr	      vmlinux.o
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.030 MB perf.data (10 samples) ]

  188368474305373 0x5e40 [0x470]: PERF_RECORD_SAMPLE(IP, 0x4002): 23839/23839: 0x401236 period: 1260507 addr: 0x7ffd3d85e96c
  ... FP chain: nr:0
  ... user regs: mask 0x1c0 ABI 64-bit
  .... BP    0x401260
  .... SP    0x7ffd3d85cc20
  .... IP    0x401236
  ... ustack: size 1024, offset 0x58
   . data_src: 0x5080021

Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
---
Changes in v5:
- renamed minimal dwarf regs set macro to DWARF_MINIMAL_REGS
- edited warning message

Changes in v4:
- added warning message about dwarf registers unconditionally 
  included into the collected registers set

Changes in v3:
- avoid changes in platform specific header files

Changes in v2:
- implemented dwarf register set to avoid corrupted trace 
  when --user-regs option value omits IP,SP
---
 tools/perf/util/evsel.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a6f572a40deb..375ab4eb7560 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -669,6 +669,8 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size)
 	return ret;
 }
 
+#define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
+
 static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
 					   struct record_opts *opts,
 					   struct callchain_param *param)
@@ -702,7 +704,14 @@ static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
 		if (!function) {
 			perf_evsel__set_sample_bit(evsel, REGS_USER);
 			perf_evsel__set_sample_bit(evsel, STACK_USER);
-			attr->sample_regs_user |= PERF_REGS_MASK;
+			if (opts->sample_user_regs) {
+				attr->sample_regs_user |= DWARF_MINIMAL_REGS;
+				pr_warning("WARNING: The use of --call-graph=dwarf may require all the user registers, "
+					   "specifying a subset with --user-regs may render DWARF unwinding unreliable, "
+					   "so the minimal registers set (IP, SP) is explicitly forced.\n");
+			} else {
+				attr->sample_regs_user |= PERF_REGS_MASK;
+			}
 			attr->sample_stack_user = param->dump_size;
 			attr->exclude_callchain_user = 1;
 		} else {
-- 
2.20.1


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

* Re: [PATCH v5] perf record: collect user registers set jointly with dwarf stacks
  2019-05-30 19:03 [PATCH v5] perf record: collect user registers set jointly with dwarf stacks Alexey Budankov
@ 2019-05-30 19:41 ` Arnaldo Carvalho de Melo
  2019-05-31  6:27   ` Alexey Budankov
  2019-06-17 18:58 ` [tip:perf/core] perf record: Allow mixing --user-regs with --call-graph=dwarf tip-bot for Alexey Budankov
  1 sibling, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-05-30 19:41 UTC (permalink / raw)
  To: Alexey Budankov
  Cc: Jiri Olsa, Namhyung Kim, Alexander Shishkin, Peter Zijlstra,
	Ingo Molnar, Andi Kleen, linux-kernel

Em Thu, May 30, 2019 at 10:03:36PM +0300, Alexey Budankov escreveu:
> 
> When dwarf stacks are collected jointly with user specified register
> set using --user-regs option like below the full register context is
> captured on a sample:
> 
>   $ perf record -g --call-graph dwarf,1024 --user-regs=IP,SP,BP -- stack_test2.g.O3
> 
>   188143843893585 0x6b48 [0x4f8]: PERF_RECORD_SAMPLE(IP, 0x4002): 23828/23828: 0x401236 period: 1363819 addr: 0x7ffedbdd51ac
>   ... FP chain: nr:0
>   ... user regs: mask 0xff0fff ABI 64-bit
>   .... AX    0x53b
>   .... BX    0x7ffedbdd3cc0
>   .... CX    0xffffffff
>   .... DX    0x33d3a
>   .... SI    0x7f09b74c38d0
>   .... DI    0x0
>   .... BP    0x401260
>   .... SP    0x7ffedbdd3cc0
>   .... IP    0x401236
>   .... FLAGS 0x20a
>   .... CS    0x33
>   .... SS    0x2b
>   .... R8    0x7f09b74c3800
>   .... R9    0x7f09b74c2da0
>   .... R10   0xfffffffffffff3ce
>   .... R11   0x246
>   .... R12   0x401070
>   .... R13   0x7ffedbdd5db0
>   .... R14   0x0
>   .... R15   0x0
>   ... ustack: size 1024, offset 0xe0
>    . data_src: 0x5080021
>    ... thread: stack_test2.g.O:23828
>    ...... dso: /root/abudanko/stacks/stack_test2.g.O3
> 
> After applying the change suggested in the patch the sample data contain
> only user specified register values. IP and SP registers (DWARF_MINIMAL_REGS)
> are collected anyways regardless of the --user-regs value provided from
> the command line:

Applied, changed the subject and description to:

perf record: Allow mixing --user-regs with --call-graph=dwarf

When DWARF stacks were requested and at the same time that the user
specifies a register set using the --user-regs option the full register
context was being captured on samples:

  $ perf record -g --call-graph dwarf,1024 --user-regs=IP,SP,BP -- stack_test2.g.O3

  188143843893585 0x6b48 [0x4f8]: PERF_RECORD_SAMPLE(IP, 0x4002): 23828/23828: 0x401236 period: 1363819 addr: 0x7ffedbdd51ac
  ... FP chain: nr:0
  ... user regs: mask 0xff0fff ABI 64-bit
  .... AX    0x53b
  .... BX    0x7ffedbdd3cc0
  .... CX    0xffffffff
  .... DX    0x33d3a
  .... SI    0x7f09b74c38d0
  .... DI    0x0
  .... BP    0x401260
  .... SP    0x7ffedbdd3cc0
  .... IP    0x401236
  .... FLAGS 0x20a
  .... CS    0x33
  .... SS    0x2b
  .... R8    0x7f09b74c3800
  .... R9    0x7f09b74c2da0
  .... R10   0xfffffffffffff3ce
  .... R11   0x246
  .... R12   0x401070
  .... R13   0x7ffedbdd5db0
  .... R14   0x0
  .... R15   0x0
  ... ustack: size 1024, offset 0xe0
   . data_src: 0x5080021
   ... thread: stack_test2.g.O:23828
   ...... dso: /root/abudanko/stacks/stack_test2.g.O3

I.e. the --user-regs=IP,SP,BP was being ignored, being overridden by the
needs of --call-graph=dwarf.

After applying the change in this patch the sample data contains the
user specified register, but making sure that at least the minimal set
of register needed for DWARF unwinding (DWARF_MINIMAL_REGS) is
requested.

The user is warned that DWARF unwinding may not work if extra registers
end up being needed.

  -g call-graph dwarf,K                         full_regs
  --user-regs=user_regs                         user_regs
  -g call-graph dwarf,K --user-regs=user_regs   user_regs + DWARF_MINIMAL_REGS
<REST remains the same>

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

* Re: [PATCH v5] perf record: collect user registers set jointly with dwarf stacks
  2019-05-30 19:41 ` Arnaldo Carvalho de Melo
@ 2019-05-31  6:27   ` Alexey Budankov
  2019-06-04 14:12     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Budankov @ 2019-05-31  6:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Namhyung Kim, Alexander Shishkin, Peter Zijlstra,
	Ingo Molnar, Andi Kleen, linux-kernel


On 30.05.2019 22:41, Arnaldo Carvalho de Melo wrote:
> Em Thu, May 30, 2019 at 10:03:36PM +0300, Alexey Budankov escreveu:
>>
>> When dwarf stacks are collected jointly with user specified register
>> set using --user-regs option like below the full register context is
>> captured on a sample:
>>
>>   $ perf record -g --call-graph dwarf,1024 --user-regs=IP,SP,BP -- stack_test2.g.O3
>>
>>   188143843893585 0x6b48 [0x4f8]: PERF_RECORD_SAMPLE(IP, 0x4002): 23828/23828: 0x401236 period: 1363819 addr: 0x7ffedbdd51ac
>>   ... FP chain: nr:0
>>   ... user regs: mask 0xff0fff ABI 64-bit
>>   .... AX    0x53b
>>   .... BX    0x7ffedbdd3cc0
>>   .... CX    0xffffffff
>>   .... DX    0x33d3a
>>   .... SI    0x7f09b74c38d0
>>   .... DI    0x0
>>   .... BP    0x401260
>>   .... SP    0x7ffedbdd3cc0
>>   .... IP    0x401236
>>   .... FLAGS 0x20a
>>   .... CS    0x33
>>   .... SS    0x2b
>>   .... R8    0x7f09b74c3800
>>   .... R9    0x7f09b74c2da0
>>   .... R10   0xfffffffffffff3ce
>>   .... R11   0x246
>>   .... R12   0x401070
>>   .... R13   0x7ffedbdd5db0
>>   .... R14   0x0
>>   .... R15   0x0
>>   ... ustack: size 1024, offset 0xe0
>>    . data_src: 0x5080021
>>    ... thread: stack_test2.g.O:23828
>>    ...... dso: /root/abudanko/stacks/stack_test2.g.O3
>>
>> After applying the change suggested in the patch the sample data contain
>> only user specified register values. IP and SP registers (DWARF_MINIMAL_REGS)
>> are collected anyways regardless of the --user-regs value provided from
>> the command line:
> 
> Applied, changed the subject and description to:
> 
> perf record: Allow mixing --user-regs with --call-graph=dwarf
> 
> When DWARF stacks were requested and at the same time that the user
> specifies a register set using the --user-regs option the full register
> context was being captured on samples:
> 
>   $ perf record -g --call-graph dwarf,1024 --user-regs=IP,SP,BP -- stack_test2.g.O3
> 
>   188143843893585 0x6b48 [0x4f8]: PERF_RECORD_SAMPLE(IP, 0x4002): 23828/23828: 0x401236 period: 1363819 addr: 0x7ffedbdd51ac
>   ... FP chain: nr:0
>   ... user regs: mask 0xff0fff ABI 64-bit
>   .... AX    0x53b
>   .... BX    0x7ffedbdd3cc0
>   .... CX    0xffffffff
>   .... DX    0x33d3a
>   .... SI    0x7f09b74c38d0
>   .... DI    0x0
>   .... BP    0x401260
>   .... SP    0x7ffedbdd3cc0
>   .... IP    0x401236
>   .... FLAGS 0x20a
>   .... CS    0x33
>   .... SS    0x2b
>   .... R8    0x7f09b74c3800
>   .... R9    0x7f09b74c2da0
>   .... R10   0xfffffffffffff3ce
>   .... R11   0x246
>   .... R12   0x401070
>   .... R13   0x7ffedbdd5db0
>   .... R14   0x0
>   .... R15   0x0
>   ... ustack: size 1024, offset 0xe0
>    . data_src: 0x5080021
>    ... thread: stack_test2.g.O:23828
>    ...... dso: /root/abudanko/stacks/stack_test2.g.O3
> 
> I.e. the --user-regs=IP,SP,BP was being ignored, being overridden by the
> needs of --call-graph=dwarf.
> 
> After applying the change in this patch the sample data contains the
> user specified register, but making sure that at least the minimal set
> of register needed for DWARF unwinding (DWARF_MINIMAL_REGS) is
> requested.
> 
> The user is warned that DWARF unwinding may not work if extra registers
> end up being needed.
> 
>   -g call-graph dwarf,K                         full_regs
>   --user-regs=user_regs                         user_regs
>   -g call-graph dwarf,K --user-regs=user_regs   user_regs + DWARF_MINIMAL_REGS
> <REST remains the same>
> 

Sounds better. Thanks!

~Alexey

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

* Re: [PATCH v5] perf record: collect user registers set jointly with dwarf stacks
  2019-05-31  6:27   ` Alexey Budankov
@ 2019-06-04 14:12     ` Arnaldo Carvalho de Melo
  2019-06-04 14:56       ` Alexey Budankov
  0 siblings, 1 reply; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-06-04 14:12 UTC (permalink / raw)
  To: Alexey Budankov
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Namhyung Kim,
	Alexander Shishkin, Peter Zijlstra, Ingo Molnar, Andi Kleen,
	linux-kernel

Em Fri, May 31, 2019 at 09:27:38AM +0300, Alexey Budankov escreveu:
> On 30.05.2019 22:41, Arnaldo Carvalho de Melo wrote:
> > Em Thu, May 30, 2019 at 10:03:36PM +0300, Alexey Budankov escreveu:
> >> When dwarf stacks are collected jointly with user specified register
> >> set using --user-regs option like below the full register context is
> >> captured on a sample:
> >>
> >>   $ perf record -g --call-graph dwarf,1024 --user-regs=IP,SP,BP -- stack_test2.g.O3
> >>
> >>   188143843893585 0x6b48 [0x4f8]: PERF_RECORD_SAMPLE(IP, 0x4002): 23828/23828: 0x401236 period: 1363819 addr: 0x7ffedbdd51ac
> >>   ... FP chain: nr:0
> >>   ... user regs: mask 0xff0fff ABI 64-bit
> >>   .... AX    0x53b
> >>   .... BX    0x7ffedbdd3cc0
> >>   .... CX    0xffffffff
> >>   .... DX    0x33d3a
> >>   .... SI    0x7f09b74c38d0
> >>   .... DI    0x0
> >>   .... BP    0x401260
> >>   .... SP    0x7ffedbdd3cc0
> >>   .... IP    0x401236
> >>   .... FLAGS 0x20a
> >>   .... CS    0x33
> >>   .... SS    0x2b
> >>   .... R8    0x7f09b74c3800
> >>   .... R9    0x7f09b74c2da0
> >>   .... R10   0xfffffffffffff3ce
> >>   .... R11   0x246
> >>   .... R12   0x401070
> >>   .... R13   0x7ffedbdd5db0
> >>   .... R14   0x0
> >>   .... R15   0x0
> >>   ... ustack: size 1024, offset 0xe0
> >>    . data_src: 0x5080021
> >>    ... thread: stack_test2.g.O:23828
> >>    ...... dso: /root/abudanko/stacks/stack_test2.g.O3
> >>
> >> After applying the change suggested in the patch the sample data contain
> >> only user specified register values. IP and SP registers (DWARF_MINIMAL_REGS)
> >> are collected anyways regardless of the --user-regs value provided from
> >> the command line:
> > 
> > Applied, changed the subject and description to:
> > 
> > perf record: Allow mixing --user-regs with --call-graph=dwarf
> > 
> > When DWARF stacks were requested and at the same time that the user
> > specifies a register set using the --user-regs option the full register
> > context was being captured on samples:
> > 
> >   $ perf record -g --call-graph dwarf,1024 --user-regs=IP,SP,BP -- stack_test2.g.O3
> > 
> >   188143843893585 0x6b48 [0x4f8]: PERF_RECORD_SAMPLE(IP, 0x4002): 23828/23828: 0x401236 period: 1363819 addr: 0x7ffedbdd51ac
> >   ... FP chain: nr:0
> >   ... user regs: mask 0xff0fff ABI 64-bit
> >   .... AX    0x53b
> >   .... BX    0x7ffedbdd3cc0
> >   .... CX    0xffffffff
> >   .... DX    0x33d3a
> >   .... SI    0x7f09b74c38d0
> >   .... DI    0x0
> >   .... BP    0x401260
> >   .... SP    0x7ffedbdd3cc0
> >   .... IP    0x401236
> >   .... FLAGS 0x20a
> >   .... CS    0x33
> >   .... SS    0x2b
> >   .... R8    0x7f09b74c3800
> >   .... R9    0x7f09b74c2da0
> >   .... R10   0xfffffffffffff3ce
> >   .... R11   0x246
> >   .... R12   0x401070
> >   .... R13   0x7ffedbdd5db0
> >   .... R14   0x0
> >   .... R15   0x0
> >   ... ustack: size 1024, offset 0xe0
> >    . data_src: 0x5080021
> >    ... thread: stack_test2.g.O:23828
> >    ...... dso: /root/abudanko/stacks/stack_test2.g.O3
> > 
> > I.e. the --user-regs=IP,SP,BP was being ignored, being overridden by the
> > needs of --call-graph=dwarf.
> > 
> > After applying the change in this patch the sample data contains the
> > user specified register, but making sure that at least the minimal set
> > of register needed for DWARF unwinding (DWARF_MINIMAL_REGS) is
> > requested.
> > 
> > The user is warned that DWARF unwinding may not work if extra registers
> > end up being needed.
> > 
> >   -g call-graph dwarf,K                         full_regs
> >   --user-regs=user_regs                         user_regs
> >   -g call-graph dwarf,K --user-regs=user_regs   user_regs + DWARF_MINIMAL_REGS
> > <REST remains the same>
> > 
> 
> Sounds better. Thanks!
> 
> ~Alexey

Now cross building to a few arches is failing, so far:

[perfbuilder@quaco ~]$ cat /tmp/dm.log/summary
 alpine:3.4: Ok
 alpine:3.5: Ok
 alpine:3.6: Ok
 alpine:3.7: Ok
 alpine:3.8: Ok
 alpine:3.9: Ok
 alpine:edge: Ok
 amazonlinux:1: Ok
 amazonlinux:2: Ok
 android-ndk:r12b-arm: Ok
 android-ndk:r15c-arm: Ok
 centos:5: Ok
 centos:6: Ok
 centos:7: Ok
 clearlinux:latest: Ok
 debian:8: Ok
 debian:9: Ok
 debian:experimental: Ok
 debian:experimental-x-arm64: Ok
 debian:experimental-x-mips: FAIL
 debian:experimental-x-mips64: FAIL
 debian:experimental-x-mipsel: FAIL
 fedora:20: Ok
 fedora:22: Ok
 fedora:23: Ok
 fedora:24: Ok
 fedora:24-x-ARC-uClibc: FAIL
 fedora:25: Ok
 fedora:26: Ok
 fedora:27: Ok
[perfbuilder@quaco ~]$

For instance:

[perfbuilder@quaco ~]$ cat /tmp/dm.log/debian\:experimental-x-mips64
<SNIP>
  CC       /tmp/build/perf/tests/pmu.o
util/evsel.c: In function '__perf_evsel__config_callchain':
util/evsel.c:672:38: error: 'PERF_REG_IP' undeclared (first use in this function); did you mean 'PERF_REGS_MAX'?
 #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
                                      ^~~~~~~~~~~
util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
     attr->sample_regs_user |= DWARF_MINIMAL_REGS;
                               ^~~~~~~~~~~~~~~~~~
util/evsel.c:672:38: note: each undeclared identifier is reported only once for each function it appears in
 #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
                                      ^~~~~~~~~~~
util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
     attr->sample_regs_user |= DWARF_MINIMAL_REGS;
                               ^~~~~~~~~~~~~~~~~~
util/evsel.c:672:62: error: 'PERF_REG_SP' undeclared (first use in this function); did you mean 'PERF_MEM_S'?
 #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
                                                              ^~~~~~~~~~~
util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
     attr->sample_regs_user |= DWARF_MINIMAL_REGS;
                               ^~~~~~~~~~~~~~~~~~
  LD       /tmp/build/perf/bench/perf-in.o
  CC       /tmp/build/perf/tests/hists_common.o
mv: cannot stat '/tmp/build/perf/util/.evsel.o.tmp': No such file or directory
make[4]: *** [/git/linux/tools/build/Makefile.build:97: /tmp/build/perf/util/evsel.o] Error 1
make[4]: *** Waiting for unfinished jobs....
<SNIP>



[perfbuilder@quaco ~]$ cat /tmp/dm.log/fedora\:24-x-ARC-uClibc

<SNIP>
  CC       /tmp/build/perf/tests/mmap-basic.o
  CC       /tmp/build/perf/ui/hist.o
util/evsel.c: In function '__perf_evsel__config_callchain':
util/evsel.c:672:38: error: 'PERF_REG_IP' undeclared (first use in this function); did you mean 'PERF_MEM_S'?
 #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
                                      ^
util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
     attr->sample_regs_user |= DWARF_MINIMAL_REGS;
                               ^~~~~~~~~~~~~~~~~~
util/evsel.c:672:38: note: each undeclared identifier is reported only once for each function it appears in
 #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
                                      ^
util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
     attr->sample_regs_user |= DWARF_MINIMAL_REGS;
                               ^~~~~~~~~~~~~~~~~~
util/evsel.c:672:62: error: 'PERF_REG_SP' undeclared (first use in this function); did you mean 'PERF_REG_IP'?
 #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
                                                              ^
util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
     attr->sample_regs_user |= DWARF_MINIMAL_REGS;
                               ^~~~~~~~~~~~~~~~~~
  MKDIR    /tmp/build/perf/ui/stdio/
mv: cannot stat '/tmp/build/perf/util/.evsel.o.tmp': No such file or directory
/git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/util/evsel.o' failed
make[4]: *** [/tmp/build/perf/util/evsel.o] Error 1


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

* Re: [PATCH v5] perf record: collect user registers set jointly with dwarf stacks
  2019-06-04 14:12     ` Arnaldo Carvalho de Melo
@ 2019-06-04 14:56       ` Alexey Budankov
  2019-06-04 15:42         ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Budankov @ 2019-06-04 14:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Namhyung Kim, Alexander Shishkin, Peter Zijlstra,
	Ingo Molnar, Andi Kleen, linux-kernel


On 04.06.2019 17:12, Arnaldo Carvalho de Melo wrote:
> Em Fri, May 31, 2019 at 09:27:38AM +0300, Alexey Budankov escreveu:
<SNIP>
> 
> Now cross building to a few arches is failing, so far:
> 
> [perfbuilder@quaco ~]$ cat /tmp/dm.log/summary
>  alpine:3.4: Ok
>  alpine:3.5: Ok
>  alpine:3.6: Ok
>  alpine:3.7: Ok
>  alpine:3.8: Ok
>  alpine:3.9: Ok
>  alpine:edge: Ok
>  amazonlinux:1: Ok
>  amazonlinux:2: Ok
>  android-ndk:r12b-arm: Ok
>  android-ndk:r15c-arm: Ok
>  centos:5: Ok
>  centos:6: Ok
>  centos:7: Ok
>  clearlinux:latest: Ok
>  debian:8: Ok
>  debian:9: Ok
>  debian:experimental: Ok
>  debian:experimental-x-arm64: Ok
>  debian:experimental-x-mips: FAIL
>  debian:experimental-x-mips64: FAIL
>  debian:experimental-x-mipsel: FAIL
>  fedora:20: Ok
>  fedora:22: Ok
>  fedora:23: Ok
>  fedora:24: Ok
>  fedora:24-x-ARC-uClibc: FAIL
>  fedora:25: Ok
>  fedora:26: Ok
>  fedora:27: Ok
> [perfbuilder@quaco ~]$

That below can fix it. Unfortunately can't test in advance on that architectures.

Thanks,
Alexey

---
 tools/perf/util/evsel.c     | 4 +---
 tools/perf/util/perf_regs.h | 4 ++++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 375ab4eb7560..cc6e7a0dda92 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -669,8 +669,6 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size)
 	return ret;
 }
 
-#define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
-
 static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
 					   struct record_opts *opts,
 					   struct callchain_param *param)
@@ -704,7 +702,7 @@ static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
 		if (!function) {
 			perf_evsel__set_sample_bit(evsel, REGS_USER);
 			perf_evsel__set_sample_bit(evsel, STACK_USER);
-			if (opts->sample_user_regs) {
+			if (opts->sample_user_regs && DWARF_MINIMAL_REGS != PERF_REGS_MASK) {
 				attr->sample_regs_user |= DWARF_MINIMAL_REGS;
 				pr_warning("WARNING: The use of --call-graph=dwarf may require all the user registers, "
 					   "specifying a subset with --user-regs may render DWARF unwinding unreliable, "
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h
index cb9c246c8962..47fe34e5f7d5 100644
--- a/tools/perf/util/perf_regs.h
+++ b/tools/perf/util/perf_regs.h
@@ -29,12 +29,16 @@ uint64_t arch__user_reg_mask(void);
 #ifdef HAVE_PERF_REGS_SUPPORT
 #include <perf_regs.h>
 
+#define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
+
 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
 
 #else
 #define PERF_REGS_MASK	0
 #define PERF_REGS_MAX	0
 
+#define DWARF_MINIMAL_REGS PERF_REGS_MASK
+
 static inline const char *perf_reg_name(int id __maybe_unused)
 {
 	return NULL;
---

> 
> For instance:
> 
> [perfbuilder@quaco ~]$ cat /tmp/dm.log/debian\:experimental-x-mips64
> <SNIP>
>   CC       /tmp/build/perf/tests/pmu.o
> util/evsel.c: In function '__perf_evsel__config_callchain':
> util/evsel.c:672:38: error: 'PERF_REG_IP' undeclared (first use in this function); did you mean 'PERF_REGS_MAX'?
>  #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
>                                       ^~~~~~~~~~~
> util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
>      attr->sample_regs_user |= DWARF_MINIMAL_REGS;
>                                ^~~~~~~~~~~~~~~~~~
> util/evsel.c:672:38: note: each undeclared identifier is reported only once for each function it appears in
>  #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
>                                       ^~~~~~~~~~~
> util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
>      attr->sample_regs_user |= DWARF_MINIMAL_REGS;
>                                ^~~~~~~~~~~~~~~~~~
> util/evsel.c:672:62: error: 'PERF_REG_SP' undeclared (first use in this function); did you mean 'PERF_MEM_S'?
>  #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
>                                                               ^~~~~~~~~~~
> util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
>      attr->sample_regs_user |= DWARF_MINIMAL_REGS;
>                                ^~~~~~~~~~~~~~~~~~
>   LD       /tmp/build/perf/bench/perf-in.o
>   CC       /tmp/build/perf/tests/hists_common.o
> mv: cannot stat '/tmp/build/perf/util/.evsel.o.tmp': No such file or directory
> make[4]: *** [/git/linux/tools/build/Makefile.build:97: /tmp/build/perf/util/evsel.o] Error 1
> make[4]: *** Waiting for unfinished jobs....
> <SNIP>
> 
> 
> 
> [perfbuilder@quaco ~]$ cat /tmp/dm.log/fedora\:24-x-ARC-uClibc
> 
> <SNIP>
>   CC       /tmp/build/perf/tests/mmap-basic.o
>   CC       /tmp/build/perf/ui/hist.o
> util/evsel.c: In function '__perf_evsel__config_callchain':
> util/evsel.c:672:38: error: 'PERF_REG_IP' undeclared (first use in this function); did you mean 'PERF_MEM_S'?
>  #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
>                                       ^
> util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
>      attr->sample_regs_user |= DWARF_MINIMAL_REGS;
>                                ^~~~~~~~~~~~~~~~~~
> util/evsel.c:672:38: note: each undeclared identifier is reported only once for each function it appears in
>  #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
>                                       ^
> util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
>      attr->sample_regs_user |= DWARF_MINIMAL_REGS;
>                                ^~~~~~~~~~~~~~~~~~
> util/evsel.c:672:62: error: 'PERF_REG_SP' undeclared (first use in this function); did you mean 'PERF_REG_IP'?
>  #define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
>                                                               ^
> util/evsel.c:708:31: note: in expansion of macro 'DWARF_MINIMAL_REGS'
>      attr->sample_regs_user |= DWARF_MINIMAL_REGS;
>                                ^~~~~~~~~~~~~~~~~~
>   MKDIR    /tmp/build/perf/ui/stdio/
> mv: cannot stat '/tmp/build/perf/util/.evsel.o.tmp': No such file or directory
> /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/util/evsel.o' failed
> make[4]: *** [/tmp/build/perf/util/evsel.o] Error 1
> 
> 

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

* Re: [PATCH v5] perf record: collect user registers set jointly with dwarf stacks
  2019-06-04 14:56       ` Alexey Budankov
@ 2019-06-04 15:42         ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2019-06-04 15:42 UTC (permalink / raw)
  To: Alexey Budankov
  Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Namhyung Kim,
	Alexander Shishkin, Peter Zijlstra, Ingo Molnar, Andi Kleen,
	linux-kernel

Em Tue, Jun 04, 2019 at 05:56:30PM +0300, Alexey Budankov escreveu:
> 
> On 04.06.2019 17:12, Arnaldo Carvalho de Melo wrote:
> > Em Fri, May 31, 2019 at 09:27:38AM +0300, Alexey Budankov escreveu:
> <SNIP>
> > 
> > Now cross building to a few arches is failing, so far:
> > 
> > [perfbuilder@quaco ~]$ cat /tmp/dm.log/summary
> >  alpine:3.4: Ok
> >  alpine:3.5: Ok
> >  alpine:3.6: Ok
> >  alpine:3.7: Ok
> >  alpine:3.8: Ok
> >  alpine:3.9: Ok
> >  alpine:edge: Ok
> >  amazonlinux:1: Ok
> >  amazonlinux:2: Ok
> >  android-ndk:r12b-arm: Ok
> >  android-ndk:r15c-arm: Ok
> >  centos:5: Ok
> >  centos:6: Ok
> >  centos:7: Ok
> >  clearlinux:latest: Ok
> >  debian:8: Ok
> >  debian:9: Ok
> >  debian:experimental: Ok
> >  debian:experimental-x-arm64: Ok
> >  debian:experimental-x-mips: FAIL
> >  debian:experimental-x-mips64: FAIL
> >  debian:experimental-x-mipsel: FAIL
> >  fedora:20: Ok
> >  fedora:22: Ok
> >  fedora:23: Ok
> >  fedora:24: Ok
> >  fedora:24-x-ARC-uClibc: FAIL
> >  fedora:25: Ok
> >  fedora:26: Ok
> >  fedora:27: Ok
> > [perfbuilder@quaco ~]$
> 
> That below can fix it. Unfortunately can't test in advance on that architectures.

Thanks for the prompt fix, just from visual inspection it looks good,
but just in case:

[perfbuilder@quaco ~]$ dm debian:experimental-x-{arm64,mips,mips64,mipsel} fedora:{24-x-ARC-uClibc,30-x-ARC-{g,uC}libc} 
   1   debian:experimental-x-arm64   : Ok   aarch64-linux-gnu-gcc (Debian 8.3.0-7) 8.3.0
   2   debian:experimental-x-mips    : Ok   mips-linux-gnu-gcc (Debian 8.3.0-7) 8.3.0
   3   debian:experimental-x-mips64  : Ok   mips64-linux-gnuabi64-gcc (Debian 8.3.0-7) 8.3.0
   4   debian:experimental-x-mipsel  : Ok   mipsel-linux-gnu-gcc (Debian 8.3.0-7) 8.3.0
   5   fedora:24-x-ARC-uClibc        : Ok   arc-linux-gcc (ARCompact ISA Linux uClibc toolchain 2017.09-rc2) 7.1.1 20170710
   6   fedora:30-x-ARC-glibc         : Ok   arc-linux-gcc (ARC HS GNU/Linux glibc toolchain 2019.03-rc1) 8.3.1 20190225
   7   fedora:30-x-ARC-uClibc        : Ok   arc-linux-gcc (ARCv2 ISA Linux uClibc toolchain 2019.03-rc1) 8.3.1 20190225
[perfbuilder@quaco ~]$

So I merged this fix with your v5 so as to keep the tree bisectable,

- Arnaldo

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

* [tip:perf/core] perf record: Allow mixing --user-regs with --call-graph=dwarf
  2019-05-30 19:03 [PATCH v5] perf record: collect user registers set jointly with dwarf stacks Alexey Budankov
  2019-05-30 19:41 ` Arnaldo Carvalho de Melo
@ 2019-06-17 18:58 ` tip-bot for Alexey Budankov
  1 sibling, 0 replies; 7+ messages in thread
From: tip-bot for Alexey Budankov @ 2019-06-17 18:58 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: ak, peterz, jolsa, alexander.shishkin, linux-kernel, tglx, acme,
	hpa, alexey.budankov, mingo, namhyung

Commit-ID:  d194d8fccf610a3f5cdfa94f2bbbe6b89e11a295
Gitweb:     https://git.kernel.org/tip/d194d8fccf610a3f5cdfa94f2bbbe6b89e11a295
Author:     Alexey Budankov <alexey.budankov@linux.intel.com>
AuthorDate: Thu, 30 May 2019 22:03:36 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 5 Jun 2019 09:47:54 -0300

perf record: Allow mixing --user-regs with --call-graph=dwarf

When DWARF stacks were requested and at the same time that the user
specifies a register set using the --user-regs option the full register
context was being captured on samples:

  $ perf record -g --call-graph dwarf,1024 --user-regs=IP,SP,BP -- stack_test2.g.O3

  188143843893585 0x6b48 [0x4f8]: PERF_RECORD_SAMPLE(IP, 0x4002): 23828/23828: 0x401236 period: 1363819 addr: 0x7ffedbdd51ac
  ... FP chain: nr:0
  ... user regs: mask 0xff0fff ABI 64-bit
  .... AX    0x53b
  .... BX    0x7ffedbdd3cc0
  .... CX    0xffffffff
  .... DX    0x33d3a
  .... SI    0x7f09b74c38d0
  .... DI    0x0
  .... BP    0x401260
  .... SP    0x7ffedbdd3cc0
  .... IP    0x401236
  .... FLAGS 0x20a
  .... CS    0x33
  .... SS    0x2b
  .... R8    0x7f09b74c3800
  .... R9    0x7f09b74c2da0
  .... R10   0xfffffffffffff3ce
  .... R11   0x246
  .... R12   0x401070
  .... R13   0x7ffedbdd5db0
  .... R14   0x0
  .... R15   0x0
  ... ustack: size 1024, offset 0xe0
   . data_src: 0x5080021
   ... thread: stack_test2.g.O:23828
   ...... dso: /root/abudanko/stacks/stack_test2.g.O3

I.e. the --user-regs=IP,SP,BP was being ignored, being overridden by the
needs of --call-graph=dwarf.

After applying the change in this patch the sample data contains the
user specified register, but making sure that at least the minimal set
of register needed for DWARF unwinding (DWARF_MINIMAL_REGS) is
requested.

The user is warned that DWARF unwinding may not work if extra registers
end up being needed.

  -g call-graph dwarf,K                         full_regs
  --user-regs=user_regs                         user_regs
  -g call-graph dwarf,K --user-regs=user_regs	user_regs + DWARF_MINIMAL_REGS

  $ perf record -g --call-graph dwarf,1024 --user-regs=BP -- ls
  WARNING: The use of --call-graph=dwarf may require all the user registers, specifying a subset with --user-regs may render DWARF unwinding unreliable, so the minimal registers set (IP, SP) is explicitly forced.
  arch   COPYING	Documentation  include	Kbuild	 lbuild    MAINTAINERS	modules.builtin		 Module.symvers  perf.data.old	scripts   System.map  virt
  block  CREDITS	drivers        init	Kconfig  lib	   Makefile	modules.builtin.modinfo  net		 README		security  tools       vmlinux
  certs  crypto	fs	       ipc	kernel	 LICENSES  mm		modules.order		 perf.data	 samples	sound	  usr	      vmlinux.o
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.030 MB perf.data (10 samples) ]

  188368474305373 0x5e40 [0x470]: PERF_RECORD_SAMPLE(IP, 0x4002): 23839/23839: 0x401236 period: 1260507 addr: 0x7ffd3d85e96c
  ... FP chain: nr:0
  ... user regs: mask 0x1c0 ABI 64-bit
  .... BP    0x401260
  .... SP    0x7ffd3d85cc20
  .... IP    0x401236
  ... ustack: size 1024, offset 0x58
   . data_src: 0x5080021

Committer notes:

Detected build failures on arches where PERF_REGS_ is not available,
such as debian:experimental-x-{mips,mips64,mipsel}, fedora 24 and 30 for
ARC uClibc and glibc, reported to Alexey that provided a patch moving
the DWARF_MINIMAL_REGS from evsel.c to util/perf_regs.h, where it is
guarded by an HAVE_PERF_REGS_SUPPORT ifdef.

Committer testing:

  # perf record --user-regs=bp,ax -a sleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 1.955 MB perf.data (1773 samples) ]
  # perf script -F+uregs | grep AX: | head -5
     perf 1719 [000] 181.272398:    1 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
     perf 1719 [000] 181.272402:    1 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
     perf 1719 [000] 181.272403:    8 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
     perf 1719 [000] 181.272405:  181 cycles: ffffffffba06a7c6 native_write_msr+0x6 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
     perf 1719 [000] 181.272406: 4405 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffef828fb00
  # perf record --call-graph=dwarf --user-regs=bp,ax -a sleep 1
  WARNING: The use of --call-graph=dwarf may require all the user registers, specifying a subset with --user-regs may render DWARF unwinding unreliable, so the minimal registers set (IP, SP) is explicitly forced.
  [ perf record: Woken up 55 times to write data ]
  [ perf record: Captured and wrote 24.184 MB perf.data (2841 samples) ]
  [root@quaco ~]# perf script --hide-call-graph -F+uregs | grep AX: | head -5
     perf 1729 [000] 211.268006:    1 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
     perf 1729 [000] 211.268014:    1 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
     perf 1729 [000] 211.268017:    5 cycles: ffffffffba06a7c4 native_write_msr+0x4 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
     perf 1729 [000] 211.268020:   48 cycles: ffffffffba06a7c6 native_write_msr+0x6 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
     perf 1729 [000] 211.268024:  490 cycles: ffffffffba00e471 intel_bts_enable_local+0x21 (/lib/modules/5.2.0-rc1+/build/vmlinux) ABI:2 AX:0xffffffffffffffda BP:0x7ffc8679abb0 SP:0x7ffc8679ab78 IP:0x7fa75223a0db
  #

Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/e7fd37b1-af22-0d94-a0dc-5895e803bbfe@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c     | 9 ++++++++-
 tools/perf/util/perf_regs.h | 4 ++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a6f572a40deb..cc6e7a0dda92 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -702,7 +702,14 @@ static void __perf_evsel__config_callchain(struct perf_evsel *evsel,
 		if (!function) {
 			perf_evsel__set_sample_bit(evsel, REGS_USER);
 			perf_evsel__set_sample_bit(evsel, STACK_USER);
-			attr->sample_regs_user |= PERF_REGS_MASK;
+			if (opts->sample_user_regs && DWARF_MINIMAL_REGS != PERF_REGS_MASK) {
+				attr->sample_regs_user |= DWARF_MINIMAL_REGS;
+				pr_warning("WARNING: The use of --call-graph=dwarf may require all the user registers, "
+					   "specifying a subset with --user-regs may render DWARF unwinding unreliable, "
+					   "so the minimal registers set (IP, SP) is explicitly forced.\n");
+			} else {
+				attr->sample_regs_user |= PERF_REGS_MASK;
+			}
 			attr->sample_stack_user = param->dump_size;
 			attr->exclude_callchain_user = 1;
 		} else {
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h
index cb9c246c8962..47fe34e5f7d5 100644
--- a/tools/perf/util/perf_regs.h
+++ b/tools/perf/util/perf_regs.h
@@ -29,12 +29,16 @@ uint64_t arch__user_reg_mask(void);
 #ifdef HAVE_PERF_REGS_SUPPORT
 #include <perf_regs.h>
 
+#define DWARF_MINIMAL_REGS ((1ULL << PERF_REG_IP) | (1ULL << PERF_REG_SP))
+
 int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
 
 #else
 #define PERF_REGS_MASK	0
 #define PERF_REGS_MAX	0
 
+#define DWARF_MINIMAL_REGS PERF_REGS_MASK
+
 static inline const char *perf_reg_name(int id __maybe_unused)
 {
 	return NULL;

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

end of thread, other threads:[~2019-06-17 18:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 19:03 [PATCH v5] perf record: collect user registers set jointly with dwarf stacks Alexey Budankov
2019-05-30 19:41 ` Arnaldo Carvalho de Melo
2019-05-31  6:27   ` Alexey Budankov
2019-06-04 14:12     ` Arnaldo Carvalho de Melo
2019-06-04 14:56       ` Alexey Budankov
2019-06-04 15:42         ` Arnaldo Carvalho de Melo
2019-06-17 18:58 ` [tip:perf/core] perf record: Allow mixing --user-regs with --call-graph=dwarf tip-bot for Alexey Budankov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.