2021-08-17 22:19:47

by Kim Phillips

[permalink] [raw]
Subject: [PATCH 0/3] perf report: Add support to print a textual representation of IBS raw sample data

Hello Linux perf tools users and maintainers,

The first patch in this series prepares the perf tool to support
retrieving cpuid and pmu_mappings data when in report mode,
information that is needed to accurately decode IBS data.

The second patch adds a header file tools/arch/x86/include/asm/amd-ibs.h
from a separate kernel-side submittion [1].

The third patch allows the tool to print a textual representation
of the sample data recorded by IBS.

[1] https://lore.kernel.org/lkml/[email protected]

Kim Phillips (3):
perf env: Add perf_env__cpuid, perf_env__{nr_}pmu_mappings
perf report: Add tools/arch/x86/include/asm/amd-ibs.h
perf report: Add support to print a textual representation of IBS raw
sample data

tools/arch/x86/include/asm/amd-ibs.h | 132 ++++++++++++
tools/perf/check-headers.sh | 1 +
tools/perf/util/Build | 1 +
tools/perf/util/amd-sample-raw.c | 290 +++++++++++++++++++++++++++
tools/perf/util/env.c | 78 +++++++
tools/perf/util/env.h | 5 +
tools/perf/util/sample-raw.c | 8 +
tools/perf/util/sample-raw.h | 6 +-
8 files changed, 520 insertions(+), 1 deletion(-)
create mode 100644 tools/arch/x86/include/asm/amd-ibs.h
create mode 100644 tools/perf/util/amd-sample-raw.c

Cc: Alexander Shishkin <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Joao Martins <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Michael Petlan <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Robert Richter <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: [email protected]
Cc: [email protected]

--
2.31.1



2021-09-09 22:26:19

by Kim Phillips

[permalink] [raw]
Subject: Re: [PATCH 0/3] perf report: Add support to print a textual representation of IBS raw sample data

Hi Arnaldo,

Can you please take a look at applying this series? Its kernel-side
dependent series has already been applied and is in Linus' master.

Thanks,

Kim

On 8/17/21 5:15 PM, Kim Phillips wrote:
> Hello Linux perf tools users and maintainers,
>
> The first patch in this series prepares the perf tool to support
> retrieving cpuid and pmu_mappings data when in report mode,
> information that is needed to accurately decode IBS data.
>
> The second patch adds a header file tools/arch/x86/include/asm/amd-ibs.h
> from a separate kernel-side submittion [1].
>
> The third patch allows the tool to print a textual representation
> of the sample data recorded by IBS.
>
> [1] https://lore.kernel.org/lkml/[email protected]
>
> Kim Phillips (3):
> perf env: Add perf_env__cpuid, perf_env__{nr_}pmu_mappings
> perf report: Add tools/arch/x86/include/asm/amd-ibs.h
> perf report: Add support to print a textual representation of IBS raw
> sample data
>
> tools/arch/x86/include/asm/amd-ibs.h | 132 ++++++++++++
> tools/perf/check-headers.sh | 1 +
> tools/perf/util/Build | 1 +
> tools/perf/util/amd-sample-raw.c | 290 +++++++++++++++++++++++++++
> tools/perf/util/env.c | 78 +++++++
> tools/perf/util/env.h | 5 +
> tools/perf/util/sample-raw.c | 8 +
> tools/perf/util/sample-raw.h | 6 +-
> 8 files changed, 520 insertions(+), 1 deletion(-)
> create mode 100644 tools/arch/x86/include/asm/amd-ibs.h
> create mode 100644 tools/perf/util/amd-sample-raw.c
>
> Cc: Alexander Shishkin <[email protected]>
> Cc: Arnaldo Carvalho de Melo <[email protected]>
> Cc: Boris Ostrovsky <[email protected]>
> Cc: Ian Rogers <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Jiri Olsa <[email protected]>
> Cc: Joao Martins <[email protected]>
> Cc: Konrad Rzeszutek Wilk <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Cc: Michael Petlan <[email protected]>
> Cc: Namhyung Kim <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Robert Richter <[email protected]>
> Cc: Stephane Eranian <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
>

2021-09-10 13:49:31

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/3] perf report: Add support to print a textual representation of IBS raw sample data

Em Thu, Sep 09, 2021 at 04:58:12PM -0500, Kim Phillips escreveu:
> Hi Arnaldo,
>
> Can you please take a look at applying this series? Its kernel-side
> dependent series has already been applied and is in Linus' master.

Sure, I'm now trying to fix this:

CC /tmp/build/perf/util/amd-sample-raw.o
util/amd-sample-raw.c: In function ‘evlist__amd_sample_raw’:
util/amd-sample-raw.c:125:42: error: ‘ bytes’ directive output may be truncated writing 6 bytes into a region of size between 4 and 7 [-Werror=format-truncation=]
125 | " OpMemWidth %2d bytes", 1 << (reg.op_mem_width - 1));
| ^~~~~~
In file included from /usr/include/stdio.h:866,
from util/amd-sample-raw.c:7:
/usr/include/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 21 and 24 bytes into a destination of size 21
71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[4]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/util/amd-sample-raw.o] Error 1

> Thanks,
>
> Kim
>
> On 8/17/21 5:15 PM, Kim Phillips wrote:
> > Hello Linux perf tools users and maintainers,
> >
> > The first patch in this series prepares the perf tool to support
> > retrieving cpuid and pmu_mappings data when in report mode,
> > information that is needed to accurately decode IBS data.
> >
> > The second patch adds a header file tools/arch/x86/include/asm/amd-ibs.h
> > from a separate kernel-side submittion [1].
> >
> > The third patch allows the tool to print a textual representation
> > of the sample data recorded by IBS.
> >
> > [1] https://lore.kernel.org/lkml/[email protected]
> >
> > Kim Phillips (3):
> > perf env: Add perf_env__cpuid, perf_env__{nr_}pmu_mappings
> > perf report: Add tools/arch/x86/include/asm/amd-ibs.h
> > perf report: Add support to print a textual representation of IBS raw
> > sample data
> >
> > tools/arch/x86/include/asm/amd-ibs.h | 132 ++++++++++++
> > tools/perf/check-headers.sh | 1 +
> > tools/perf/util/Build | 1 +
> > tools/perf/util/amd-sample-raw.c | 290 +++++++++++++++++++++++++++
> > tools/perf/util/env.c | 78 +++++++
> > tools/perf/util/env.h | 5 +
> > tools/perf/util/sample-raw.c | 8 +
> > tools/perf/util/sample-raw.h | 6 +-
> > 8 files changed, 520 insertions(+), 1 deletion(-)
> > create mode 100644 tools/arch/x86/include/asm/amd-ibs.h
> > create mode 100644 tools/perf/util/amd-sample-raw.c
> >
> > Cc: Alexander Shishkin <[email protected]>
> > Cc: Arnaldo Carvalho de Melo <[email protected]>
> > Cc: Boris Ostrovsky <[email protected]>
> > Cc: Ian Rogers <[email protected]>
> > Cc: Ingo Molnar <[email protected]>
> > Cc: Jiri Olsa <[email protected]>
> > Cc: Joao Martins <[email protected]>
> > Cc: Konrad Rzeszutek Wilk <[email protected]>
> > Cc: Mark Rutland <[email protected]>
> > Cc: Michael Petlan <[email protected]>
> > Cc: Namhyung Kim <[email protected]>
> > Cc: Peter Zijlstra <[email protected]>
> > Cc: Robert Richter <[email protected]>
> > Cc: Stephane Eranian <[email protected]>
> > Cc: [email protected]
> > Cc: [email protected]
> >

--

- Arnaldo

2021-09-10 14:10:11

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/3] perf report: Add support to print a textual representation of IBS raw sample data

Em Fri, Sep 10, 2021 at 10:47:16AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Sep 09, 2021 at 04:58:12PM -0500, Kim Phillips escreveu:
> > Hi Arnaldo,
> >
> > Can you please take a look at applying this series? Its kernel-side
> > dependent series has already been applied and is in Linus' master.
>
> Sure, I'm now trying to fix this:
>
> CC /tmp/build/perf/util/amd-sample-raw.o
> util/amd-sample-raw.c: In function ‘evlist__amd_sample_raw’:
> util/amd-sample-raw.c:125:42: error: ‘ bytes’ directive output may be truncated writing 6 bytes into a region of size between 4 and 7 [-Werror=format-truncation=]
> 125 | " OpMemWidth %2d bytes", 1 << (reg.op_mem_width - 1));
> | ^~~~~~
> In file included from /usr/include/stdio.h:866,
> from util/amd-sample-raw.c:7:
> /usr/include/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 21 and 24 bytes into a destination of size 21
> 71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 72 | __glibc_objsize (__s), __fmt,
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 73 | __va_arg_pack ());
> | ~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[4]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/util/amd-sample-raw.o] Error 1

So, that trick with using sizeof and that string 3 times is cumbersome
and prone to truncation, at least the compiler can't say that the number
you're passing to %2d will have just 2 digits:

[acme@quaco c]$ cat printf.c
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
char bf[64];
int len = snprintf(bf, sizeof(bf), "%2d", atoi(argv[1]));

printf("strlen(%s): %u\n", bf, len);

return 0;
}
[acme@quaco c]$ ./printf 1234567
strlen(1234567): 7
[acme@quaco c]$

I'm trying to rework this.

- Arnaldo

2021-09-10 14:14:44

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/3] perf report: Add support to print a textual representation of IBS raw sample data

Em Fri, Sep 10, 2021 at 11:08:02AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Sep 10, 2021 at 10:47:16AM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Thu, Sep 09, 2021 at 04:58:12PM -0500, Kim Phillips escreveu:
> > > Hi Arnaldo,
> > >
> > > Can you please take a look at applying this series? Its kernel-side
> > > dependent series has already been applied and is in Linus' master.
> >
> > Sure, I'm now trying to fix this:
> >
> > CC /tmp/build/perf/util/amd-sample-raw.o
> > util/amd-sample-raw.c: In function ‘evlist__amd_sample_raw’:
> > util/amd-sample-raw.c:125:42: error: ‘ bytes’ directive output may be truncated writing 6 bytes into a region of size between 4 and 7 [-Werror=format-truncation=]
> > 125 | " OpMemWidth %2d bytes", 1 << (reg.op_mem_width - 1));
> > | ^~~~~~
> > In file included from /usr/include/stdio.h:866,
> > from util/amd-sample-raw.c:7:
> > /usr/include/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 21 and 24 bytes into a destination of size 21
> > 71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 72 | __glibc_objsize (__s), __fmt,
> > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 73 | __va_arg_pack ());
> > | ~~~~~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> > make[4]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/util/amd-sample-raw.o] Error 1
>
> So, that trick with using sizeof and that string 3 times is cumbersome
> and prone to truncation, at least the compiler can't say that the number
> you're passing to %2d will have just 2 digits:
>
> [acme@quaco c]$ cat printf.c
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(int argc, char *argv[])
> {
> char bf[64];
> int len = snprintf(bf, sizeof(bf), "%2d", atoi(argv[1]));
>
> printf("strlen(%s): %u\n", bf, len);
>
> return 0;
> }
> [acme@quaco c]$ ./printf 1234567
> strlen(1234567): 7
> [acme@quaco c]$
>
> I'm trying to rework this.

So below is the minimal fix, the other cases the compiler somehow thinks
its ok, so I'll keep as is, will just remove the sizeof(string) to
sizeof(var), as I did below for the offending case.

- Arnaldo

diff --git a/tools/perf/util/amd-sample-raw.c b/tools/perf/util/amd-sample-raw.c
index fc1f670e88562b2e..e24025022735acdc 100644
--- a/tools/perf/util/amd-sample-raw.c
+++ b/tools/perf/util/amd-sample-raw.c
@@ -106,7 +106,7 @@ static void pr_ibs_op_data2(union ibs_op_data2 reg)
static void pr_ibs_op_data3(union ibs_op_data3 reg)
{
char l2_miss_str[sizeof(" L2Miss _")] = "";
- char op_mem_width_str[sizeof(" OpMemWidth __ bytes")] = "";
+ char op_mem_width_str[sizeof(" OpMemWidth _____ bytes")] = "";
char op_dc_miss_open_mem_reqs_str[sizeof(" OpDcMissOpenMemReqs __")] = "";

/*
@@ -121,7 +121,7 @@ static void pr_ibs_op_data3(union ibs_op_data3 reg)
}

if (reg.op_mem_width)
- snprintf(op_mem_width_str, sizeof(" OpMemWidth __ bytes"),
+ snprintf(op_mem_width_str, sizeof(op_mem_width_str),
" OpMemWidth %2d bytes", 1 << (reg.op_mem_width - 1));

printf("ibs_op_data3:\t%016llx LdOp %d StOp %d DcL1TlbMiss %d DcL2TlbMiss %d "

2021-09-10 14:21:04

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 0/3] perf report: Add support to print a textual representation of IBS raw sample data

Em Fri, Sep 10, 2021 at 11:11:48AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Sep 10, 2021 at 11:08:02AM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Fri, Sep 10, 2021 at 10:47:16AM -0300, Arnaldo Carvalho de Melo escreveu:
> > > Em Thu, Sep 09, 2021 at 04:58:12PM -0500, Kim Phillips escreveu:
> > > > Hi Arnaldo,
> > > >
> > > > Can you please take a look at applying this series? Its kernel-side
> > > > dependent series has already been applied and is in Linus' master.
> > >
> > > Sure, I'm now trying to fix this:
> > >
> > > CC /tmp/build/perf/util/amd-sample-raw.o
> > > util/amd-sample-raw.c: In function ‘evlist__amd_sample_raw’:
> > > util/amd-sample-raw.c:125:42: error: ‘ bytes’ directive output may be truncated writing 6 bytes into a region of size between 4 and 7 [-Werror=format-truncation=]
> > > 125 | " OpMemWidth %2d bytes", 1 << (reg.op_mem_width - 1));
> > > | ^~~~~~
> > > In file included from /usr/include/stdio.h:866,
> > > from util/amd-sample-raw.c:7:
> > > /usr/include/bits/stdio2.h:71:10: note: ‘__builtin___snprintf_chk’ output between 21 and 24 bytes into a destination of size 21
> > > 71 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
> > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > 72 | __glibc_objsize (__s), __fmt,
> > > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > 73 | __va_arg_pack ());
> > > | ~~~~~~~~~~~~~~~~~
> > > cc1: all warnings being treated as errors
> > > make[4]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/util/amd-sample-raw.o] Error 1
> >
> > So, that trick with using sizeof and that string 3 times is cumbersome
> > and prone to truncation, at least the compiler can't say that the number
> > you're passing to %2d will have just 2 digits:
> >
> > [acme@quaco c]$ cat printf.c
> > #include <stdio.h>
> > #include <stdlib.h>
> >
> > int main(int argc, char *argv[])
> > {
> > char bf[64];
> > int len = snprintf(bf, sizeof(bf), "%2d", atoi(argv[1]));
> >
> > printf("strlen(%s): %u\n", bf, len);
> >
> > return 0;
> > }
> > [acme@quaco c]$ ./printf 1234567
> > strlen(1234567): 7
> > [acme@quaco c]$
> >
> > I'm trying to rework this.
>
> So below is the minimal fix, the other cases the compiler somehow thinks
> its ok, so I'll keep as is, will just remove the sizeof(string) to
> sizeof(var), as I did below for the offending case.

End result:

diff --git a/tools/perf/util/amd-sample-raw.c b/tools/perf/util/amd-sample-raw.c
index fc1f670e88562b2e..fbb7d61c50489374 100644
--- a/tools/perf/util/amd-sample-raw.c
+++ b/tools/perf/util/amd-sample-raw.c
@@ -106,7 +106,7 @@ static void pr_ibs_op_data2(union ibs_op_data2 reg)
static void pr_ibs_op_data3(union ibs_op_data3 reg)
{
char l2_miss_str[sizeof(" L2Miss _")] = "";
- char op_mem_width_str[sizeof(" OpMemWidth __ bytes")] = "";
+ char op_mem_width_str[sizeof(" OpMemWidth _____ bytes")] = "";
char op_dc_miss_open_mem_reqs_str[sizeof(" OpDcMissOpenMemReqs __")] = "";

/*
@@ -114,14 +114,13 @@ static void pr_ibs_op_data3(union ibs_op_data3 reg)
* Ignore L2Miss and OpDcMissOpenMemReqs (and opdata2) if DcMissNoMabAlloc or SwPf set
*/
if (!(cpu_family == 0x19 && cpu_model < 0x10 && (reg.dc_miss_no_mab_alloc || reg.sw_pf))) {
- snprintf(l2_miss_str, sizeof(" L2Miss _"),
- " L2Miss %d", reg.l2_miss);
- snprintf(op_dc_miss_open_mem_reqs_str, sizeof(" OpDcMissOpenMemReqs __"),
+ snprintf(l2_miss_str, sizeof(l2_miss_str), " L2Miss %d", reg.l2_miss);
+ snprintf(op_dc_miss_open_mem_reqs_str, sizeof(op_dc_miss_open_mem_reqs_str),
" OpDcMissOpenMemReqs %2d", reg.op_dc_miss_open_mem_reqs);
}

if (reg.op_mem_width)
- snprintf(op_mem_width_str, sizeof(" OpMemWidth __ bytes"),
+ snprintf(op_mem_width_str, sizeof(op_mem_width_str),
" OpMemWidth %2d bytes", 1 << (reg.op_mem_width - 1));

printf("ibs_op_data3:\t%016llx LdOp %d StOp %d DcL1TlbMiss %d DcL2TlbMiss %d "

2021-09-10 19:49:56

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Another bug: Re: [PATCH 0/3] perf report: Add support to print a textual representation of IBS raw sample data


All the cross builds are failing:

28 9.20 debian:experimental-x-arm64 : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
util/amd-sample-raw.c:12:10: fatal error: asm/amd-ibs.h: No such file or directory
12 | #include <asm/amd-ibs.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
29 7.29 debian:experimental-x-mips : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
util/amd-sample-raw.c:12:10: fatal error: asm/amd-ibs.h: No such file or directory
12 | #include <asm/amd-ibs.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
30 8.50 debian:experimental-x-mips64 : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
util/amd-sample-raw.c:12:10: fatal error: asm/amd-ibs.h: No such file or directory
12 | #include <asm/amd-ibs.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
31 8.50 debian:experimental-x-mipsel : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
util/amd-sample-raw.c:12:10: fatal error: asm/amd-ibs.h: No such file or directory
12 | #include <asm/amd-ibs.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
32 26.37 fedora:22 : Ok gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6) , clang version 3.5.0 (tags/RELEASE_350/final)
33 66.13 fedora:23 : Ok gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6) , clang version 3.7.0 (tags/RELEASE_370/final)
34 79.47 fedora:24 : Ok gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1) , clang version 3.8.1 (tags/RELEASE_381/final)
35 6.89 fedora:24-x-ARC-uClibc : FAIL gcc version 7.1.1 20170710 (ARCompact ISA Linux uClibc toolchain 2017.09-rc2)
util/amd-sample-raw.c:12:10: fatal error: asm/amd-ibs.h: No such file or directory
#include <asm/amd-ibs.h>
^~~~~~~~~~~~~~~

2021-09-10 20:59:14

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: Another bug: Re: [PATCH 0/3] perf report: Add support to print a textual representation of IBS raw sample data

Em Fri, Sep 10, 2021 at 04:48:42PM -0300, Arnaldo Carvalho de Melo escreveu:
>
> All the cross builds are failing:
>
> 28 9.20 debian:experimental-x-arm64 : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
> util/amd-sample-raw.c:12:10: fatal error: asm/amd-ibs.h: No such file or directory
> 12 | #include <asm/amd-ibs.h>
> | ^~~~~~~~~~~~~~~
> compilation terminated.

Trying with the same trick used by intel-pt to build on all arches:

diff --git a/tools/perf/util/amd-sample-raw.c b/tools/perf/util/amd-sample-raw.c
index fbb7d61c50489374..d19d765195c54b79 100644
--- a/tools/perf/util/amd-sample-raw.c
+++ b/tools/perf/util/amd-sample-raw.c
@@ -9,7 +9,7 @@
#include <inttypes.h>

#include <linux/string.h>
-#include <asm/amd-ibs.h>
+#include "../../arch/x86/include/asm/amd-ibs.h"

#include "debug.h"
#include "session.h"

2021-09-10 21:41:14

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: Another bug: Re: [PATCH 0/3] perf report: Add support to print a textual representation of IBS raw sample data

Em Fri, Sep 10, 2021 at 05:58:14PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Sep 10, 2021 at 04:48:42PM -0300, Arnaldo Carvalho de Melo escreveu:
> >
> > All the cross builds are failing:
> >
> > 28 9.20 debian:experimental-x-arm64 : FAIL gcc version 10.2.1 20210110 (Debian 10.2.1-6)
> > util/amd-sample-raw.c:12:10: fatal error: asm/amd-ibs.h: No such file or directory
> > 12 | #include <asm/amd-ibs.h>
> > | ^~~~~~~~~~~~~~~
> > compilation terminated.
>
> Trying with the same trick used by intel-pt to build on all arches:
>
> diff --git a/tools/perf/util/amd-sample-raw.c b/tools/perf/util/amd-sample-raw.c
> index fbb7d61c50489374..d19d765195c54b79 100644
> --- a/tools/perf/util/amd-sample-raw.c
> +++ b/tools/perf/util/amd-sample-raw.c
> @@ -9,7 +9,7 @@
> #include <inttypes.h>
>
> #include <linux/string.h>
> -#include <asm/amd-ibs.h>
> +#include "../../arch/x86/include/asm/amd-ibs.h"
>
> #include "debug.h"
> #include "session.h"

Not enough, this one is needed for msr-index.h, same reason, a bit more
involved, but check-patch.h has a few entries like that, see below.

Now it seems to be ok:

# export BUILD_TARBALL=http://192.168.100.2/perf/perf-5.14.0.tar.xz
# dm android-ndk:r12b-arm android-ndk:r15c-arm debian:experimental-x-arm64 debian:experimental-x-mips debian:experimental-x-mips64 debian:experimental-x-mipsel fedora:24-x-ARC-uClibc fedora:34-x-ARC-glibc fedora:34-x-ARC-uClibc mageia:7 openmandriva:cooker ubuntu:16.04-x-arm ubuntu:16.04-x-arm64 ubuntu:16.04-x-powerpc ubuntu:16.04-x-powerpc64 ubuntu:16.04-x-powerpc64el ubuntu:16.04-x-s390 ubuntu:18.04-x-arm ubuntu:18.04-x-arm64 ubuntu:18.04-x-m68k ubuntu:18.04-x-powerpc ubuntu:18.04-x-powerpc64 ubuntu:18.04-x-powerpc64el ubuntu:18.04-x-riscv64 ubuntu:18.04-x-s390 ubuntu:18.04-x-sh4 ubuntu:18.04-x-sparc64 ubuntu:20.04-x-powerpc64el ubuntu:20.04-x-s390 ubuntu:21.04-x-mips ubuntu:21.04-x-mips64
1 29.83 android-ndk:r12b-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
2 40.15 android-ndk:r15c-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
3 49.76 debian:experimental-x-arm64 : Ok aarch64-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110
4 38.37 debian:experimental-x-mips : Ok mips-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110
5 45.28 debian:experimental-x-mips64 : Ok mips64-linux-gnuabi64-gcc (Debian 10.2.1-6) 10.2.1 20210110
6 45.15 debian:experimental-x-mipsel : Ok mipsel-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110
7: fedora:24-x-ARC-uClibc

Some more to go, but should be ok by now.

- Arnaldo

diff --git a/tools/arch/x86/include/asm/amd-ibs.h b/tools/arch/x86/include/asm/amd-ibs.h
index 46e1df45efc04627..174e7d83fcbdb22f 100644
--- a/tools/arch/x86/include/asm/amd-ibs.h
+++ b/tools/arch/x86/include/asm/amd-ibs.h
@@ -4,7 +4,7 @@
* 55898 Rev 0.35 - Feb 5, 2021
*/

-#include <asm/msr-index.h>
+#include "msr-index.h"

/*
* IBS Hardware MSRs
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 4a6b2b4ec5074a49..f1e46277e8226b5a 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -34,7 +34,6 @@ arch/x86/include/asm/inat_types.h
arch/x86/include/asm/emulate_prefix.h
arch/x86/include/asm/irq_vectors.h
arch/x86/include/asm/msr-index.h
-arch/x86/include/asm/amd-ibs.h
arch/x86/include/uapi/asm/prctl.h
arch/x86/lib/x86-opcode-map.txt
arch/x86/tools/gen-insn-attr-x86.awk
@@ -145,6 +144,7 @@ done
# diff with extra ignore lines
check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memcpy_\(erms\|orig\))"'
check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memset_\(erms\|orig\))"'
+check arch/x86/include/asm/amd-ibs.h '-I "^#include [<\"]\(asm/\)*msr-index.h"'
check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"'
check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"'
check include/linux/build_bug.h '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"'