mbox series

[v2,0/2] perf: arm64: Tools support for Dwarf unwinding through SVE functions

Message ID 20220517102005.3022017-1-james.clark@arm.com (mailing list archive)
Headers show
Series perf: arm64: Tools support for Dwarf unwinding through SVE functions | expand

Message

James Clark May 17, 2022, 10:20 a.m. UTC
Changes since v1:

  * Split patchset into kernel side and Perf tool changes

When SVE registers are pushed onto the stack the VG register is required to
unwind because the stack offsets would vary by the SVE register width at the
time when the sample was taken.

The patches ("[PATCH v2 0/2] perf: arm64: Kernel support for Dwarf unwinding
through SVE functions") add support for sampling the VG register to the kernel
and the docs. This is the patchset to add support to userspace perf.

A small change is also required to libunwind or libdw depending on which
unwinder is used, and these will be published later. Without these changes Perf
continues to work with both libraries, although the VG register is still not
used for unwinding. 

Thanks
James

James Clark (4):
  perf tools: arm64: Copy perf_regs.h from the kernel
  perf tools: Use dynamic register set for Dwarf unwind
  perf tools: arm64: Decouple Libunwind register names from Perf
  perf tools: arm64: Add support for VG register

 tools/arch/arm64/include/uapi/asm/perf_regs.h |  7 +-
 tools/perf/arch/arm64/util/perf_regs.c        | 34 +++++++++
 tools/perf/arch/arm64/util/unwind-libunwind.c | 73 +------------------
 tools/perf/util/evsel.c                       |  2 +-
 tools/perf/util/perf_regs.c                   |  2 +
 5 files changed, 45 insertions(+), 73 deletions(-)

Comments

Arnaldo Carvalho de Melo May 17, 2022, 2:58 p.m. UTC | #1
Em Tue, May 17, 2022 at 11:20:01AM +0100, James Clark escreveu:
> Changes since v1:
> 
>   * Split patchset into kernel side and Perf tool changes

Thanks, now I'll wait for the kernel side to be merged.

- Arnaldo
 
> When SVE registers are pushed onto the stack the VG register is required to
> unwind because the stack offsets would vary by the SVE register width at the
> time when the sample was taken.
> 
> The patches ("[PATCH v2 0/2] perf: arm64: Kernel support for Dwarf unwinding
> through SVE functions") add support for sampling the VG register to the kernel
> and the docs. This is the patchset to add support to userspace perf.
> 
> A small change is also required to libunwind or libdw depending on which
> unwinder is used, and these will be published later. Without these changes Perf
> continues to work with both libraries, although the VG register is still not
> used for unwinding. 
> 
> Thanks
> James
> 
> James Clark (4):
>   perf tools: arm64: Copy perf_regs.h from the kernel
>   perf tools: Use dynamic register set for Dwarf unwind
>   perf tools: arm64: Decouple Libunwind register names from Perf
>   perf tools: arm64: Add support for VG register
> 
>  tools/arch/arm64/include/uapi/asm/perf_regs.h |  7 +-
>  tools/perf/arch/arm64/util/perf_regs.c        | 34 +++++++++
>  tools/perf/arch/arm64/util/unwind-libunwind.c | 73 +------------------
>  tools/perf/util/evsel.c                       |  2 +-
>  tools/perf/util/perf_regs.c                   |  2 +
>  5 files changed, 45 insertions(+), 73 deletions(-)
> 
> -- 
> 2.28.0
German Gomez May 20, 2022, 11:46 a.m. UTC | #2
On 17/05/2022 15:58, Arnaldo Carvalho de Melo wrote:
> Em Tue, May 17, 2022 at 11:20:01AM +0100, James Clark escreveu:
>> Changes since v1:
>>
>>   * Split patchset into kernel side and Perf tool changes
> Thanks, now I'll wait for the kernel side to be merged.
>
> - Arnaldo
>  

Hi,

I think we also need to fix the below import (it's trying to import the
perf_regs.h from the kernel, not the tools/ dir).

diff --git a/tools/perf/util/libunwind/arm64.c b/tools/perf/util/libunwind/arm64.c
index 15f60fd09424..014d82159656 100644
--- a/tools/perf/util/libunwind/arm64.c
+++ b/tools/perf/util/libunwind/arm64.c
@@ -24,7 +24,7 @@
 #include "unwind.h"
 #include "libunwind-aarch64.h"
 #define perf_event_arm_regs perf_event_arm64_regs
-#include <../../../../arch/arm64/include/uapi/asm/perf_regs.h>
+#include <../../../arch/arm64/include/uapi/asm/perf_regs.h>
 #undef perf_event_arm_regs
 #include "../../arch/arm64/util/unwind-libunwind.c"
Arnaldo Carvalho de Melo May 20, 2022, 12:32 p.m. UTC | #3
Em Fri, May 20, 2022 at 12:46:24PM +0100, German Gomez escreveu:
> 
> On 17/05/2022 15:58, Arnaldo Carvalho de Melo wrote:
> > Em Tue, May 17, 2022 at 11:20:01AM +0100, James Clark escreveu:
> >> Changes since v1:
> >>
> >>   * Split patchset into kernel side and Perf tool changes
> > Thanks, now I'll wait for the kernel side to be merged.
> >
> > - Arnaldo
> >  
> 
> Hi,
> 
> I think we also need to fix the below import (it's trying to import the
> perf_regs.h from the kernel, not the tools/ dir).

Sure, that is why it is important to do a:

make -C tools/perf build-test

before posting patches, as it will do, among other tests, a detached tarball test using:

⬢[acme@toolbox perf-urgent]$ make help | grep perf
  perf-tar-src-pkg    - Build perf-5.18.0-rc7.tar source tarball
  perf-targz-src-pkg  - Build perf-5.18.0-rc7.tar.gz source tarball
  perf-tarbz2-src-pkg - Build perf-5.18.0-rc7.tar.bz2 source tarball
  perf-tarxz-src-pkg  - Build perf-5.18.0-rc7.tar.xz source tarball
  perf-tarzst-src-pkg - Build perf-5.18.0-rc7.tar.zst source tarball
⬢[acme@toolbox perf-urgent]$

That will pick just what is in tools/perf/MANIFEST and that doesn´t
include the kernel headers, just what is in tools/ then building with
this patchkit would fail.

To recap:

⬢[acme@toolbox perf-urgent]$ make perf-tarxz-src-pkg
  TAR
  PERF_VERSION = 5.18.rc7.gc645054ef517
⬢[acme@toolbox perf-urgent]$ ls -la perf-5.18.0-rc7.tar.xz
-rw-r--r--. 1 acme acme 2364832 May 20 09:32 perf-5.18.0-rc7.tar.xz
⬢[acme@toolbox perf-urgent]$ tar tvf perf-5.18.0-rc7.tar.xz | tail
-rw-rw-r-- root/root      7364 2022-05-20 09:32 perf-5.18.0-rc7/tools/perf/util/vdso.c
-rw-rw-r-- root/root       639 2022-05-20 09:32 perf-5.18.0-rc7/tools/perf/util/vdso.h
-rw-rw-r-- root/root      1793 2022-05-20 09:32 perf-5.18.0-rc7/tools/perf/util/zlib.c
-rw-rw-r-- root/root      2672 2022-05-20 09:32 perf-5.18.0-rc7/tools/perf/util/zstd.c
drwxrwxr-x root/root         0 2022-05-20 09:32 perf-5.18.0-rc7/tools/scripts/
-rw-rw-r-- root/root      1091 2022-05-20 09:32 perf-5.18.0-rc7/tools/scripts/Makefile.arch
-rw-rw-r-- root/root      5905 2022-05-20 09:32 perf-5.18.0-rc7/tools/scripts/Makefile.include
-rw-rw-r-- root/root      5288 2022-05-20 09:32 perf-5.18.0-rc7/tools/scripts/utilities.mak
-rw-r--r-- acme/acme        41 2022-05-20 09:32 perf-5.18.0-rc7/HEAD
-rw-r--r-- acme/acme        46 2022-05-20 09:32 perf-5.18.0-rc7/PERF-VERSION-FILE
⬢[acme@toolbox perf-urgent]$

- Arnaldo
 
> diff --git a/tools/perf/util/libunwind/arm64.c b/tools/perf/util/libunwind/arm64.c
> index 15f60fd09424..014d82159656 100644
> --- a/tools/perf/util/libunwind/arm64.c
> +++ b/tools/perf/util/libunwind/arm64.c
> @@ -24,7 +24,7 @@
>  #include "unwind.h"
>  #include "libunwind-aarch64.h"
>  #define perf_event_arm_regs perf_event_arm64_regs
> -#include <../../../../arch/arm64/include/uapi/asm/perf_regs.h>
> +#include <../../../arch/arm64/include/uapi/asm/perf_regs.h>
>  #undef perf_event_arm_regs
>  #include "../../arch/arm64/util/unwind-libunwind.c"
>
James Clark May 20, 2022, 2:52 p.m. UTC | #4
On 20/05/2022 13:32, Arnaldo Carvalho de Melo wrote:
> Em Fri, May 20, 2022 at 12:46:24PM +0100, German Gomez escreveu:
>>
>> On 17/05/2022 15:58, Arnaldo Carvalho de Melo wrote:
>>> Em Tue, May 17, 2022 at 11:20:01AM +0100, James Clark escreveu:
>>>> Changes since v1:
>>>>
>>>>   * Split patchset into kernel side and Perf tool changes
>>> Thanks, now I'll wait for the kernel side to be merged.
>>>
>>> - Arnaldo
>>>  
>>
>> Hi,
>>
>> I think we also need to fix the below import (it's trying to import the
>> perf_regs.h from the kernel, not the tools/ dir).
> 
> Sure, that is why it is important to do a:
> 
> make -C tools/perf build-test
> 

Oops thanks, I will submit another version with a fix for this included.

James

> before posting patches, as it will do, among other tests, a detached tarball test using:
> 
> ⬢[acme@toolbox perf-urgent]$ make help | grep perf
>   perf-tar-src-pkg    - Build perf-5.18.0-rc7.tar source tarball
>   perf-targz-src-pkg  - Build perf-5.18.0-rc7.tar.gz source tarball
>   perf-tarbz2-src-pkg - Build perf-5.18.0-rc7.tar.bz2 source tarball
>   perf-tarxz-src-pkg  - Build perf-5.18.0-rc7.tar.xz source tarball
>   perf-tarzst-src-pkg - Build perf-5.18.0-rc7.tar.zst source tarball
> ⬢[acme@toolbox perf-urgent]$
> 
> That will pick just what is in tools/perf/MANIFEST and that doesn´t
> include the kernel headers, just what is in tools/ then building with
> this patchkit would fail.
> 
> To recap:
> 
> ⬢[acme@toolbox perf-urgent]$ make perf-tarxz-src-pkg
>   TAR
>   PERF_VERSION = 5.18.rc7.gc645054ef517
> ⬢[acme@toolbox perf-urgent]$ ls -la perf-5.18.0-rc7.tar.xz
> -rw-r--r--. 1 acme acme 2364832 May 20 09:32 perf-5.18.0-rc7.tar.xz
> ⬢[acme@toolbox perf-urgent]$ tar tvf perf-5.18.0-rc7.tar.xz | tail
> -rw-rw-r-- root/root      7364 2022-05-20 09:32 perf-5.18.0-rc7/tools/perf/util/vdso.c
> -rw-rw-r-- root/root       639 2022-05-20 09:32 perf-5.18.0-rc7/tools/perf/util/vdso.h
> -rw-rw-r-- root/root      1793 2022-05-20 09:32 perf-5.18.0-rc7/tools/perf/util/zlib.c
> -rw-rw-r-- root/root      2672 2022-05-20 09:32 perf-5.18.0-rc7/tools/perf/util/zstd.c
> drwxrwxr-x root/root         0 2022-05-20 09:32 perf-5.18.0-rc7/tools/scripts/
> -rw-rw-r-- root/root      1091 2022-05-20 09:32 perf-5.18.0-rc7/tools/scripts/Makefile.arch
> -rw-rw-r-- root/root      5905 2022-05-20 09:32 perf-5.18.0-rc7/tools/scripts/Makefile.include
> -rw-rw-r-- root/root      5288 2022-05-20 09:32 perf-5.18.0-rc7/tools/scripts/utilities.mak
> -rw-r--r-- acme/acme        41 2022-05-20 09:32 perf-5.18.0-rc7/HEAD
> -rw-r--r-- acme/acme        46 2022-05-20 09:32 perf-5.18.0-rc7/PERF-VERSION-FILE
> ⬢[acme@toolbox perf-urgent]$
> 
> - Arnaldo
>  
>> diff --git a/tools/perf/util/libunwind/arm64.c b/tools/perf/util/libunwind/arm64.c
>> index 15f60fd09424..014d82159656 100644
>> --- a/tools/perf/util/libunwind/arm64.c
>> +++ b/tools/perf/util/libunwind/arm64.c
>> @@ -24,7 +24,7 @@
>>  #include "unwind.h"
>>  #include "libunwind-aarch64.h"
>>  #define perf_event_arm_regs perf_event_arm64_regs
>> -#include <../../../../arch/arm64/include/uapi/asm/perf_regs.h>
>> +#include <../../../arch/arm64/include/uapi/asm/perf_regs.h>
>>  #undef perf_event_arm_regs
>>  #include "../../arch/arm64/util/unwind-libunwind.c"
>>
>