Skip to contentSkip to conversation

linux-next: build failure after merge of the perf tree

PATCH In review Stephen Rothwell 3 participants 6 messages Oct 10, 2024 – Oct 13, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

After merging the perf tree, today's linux-next build (native perf) failed like this:

util/evsel.c: In function 'store_event':
util/evsel.c:138:50: error: format '%llu' expects argument of type 'long long unsigned int', but argument 6 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]

  138 |         snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir,
      |                                               ~~~^
      |                                                  |
      |                                                  long long unsigned int
      |                                               %lu
  139 |                  attr->type, attr->config, fd);
      |                              ~~~~~~~~~~~~         
      |                                  |
      |                                  __u64 {aka long unsigned int}
util/evsel.c:147:41: error: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
  147 |         if (fprintf(file, "[event-%d-%llu-%d]\n",
      |                                      ~~~^
      |                                         |
      |                                         long long unsigned int
      |                                      %lu
  148 |                     attr->type, attr->config, fd) < 0) {
      |                                 ~~~~~~~~~~~~
      |                                     |
      |                                     __u64 {aka long unsigned int}

util/evsel.c:164:33: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
164 | WRITE_ASS(config, "llu");
| ^
util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
122 | if (fprintf(file, #str "=%"fmt "\n", data) < 0) { \
| ^~~
util/evsel.c:164:9: note: in expansion of macro 'WRITE_ASS'

  164 |         WRITE_ASS(config,  "llu");
      |         ^~~~~~~~~

util/evsel.c:165:39: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
165 | WRITE_ASS(sample_period, "llu");
| ^
util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
122 | if (fprintf(file, #str "=%"fmt "\n", data) < 0) { \
| ^~~
util/evsel.c:165:9: note: in expansion of macro 'WRITE_ASS'

  165 |         WRITE_ASS(sample_period, "llu");
      |         ^~~~~~~~~

util/evsel.c:166:39: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
166 | WRITE_ASS(sample_type, "llu");
| ^
util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
122 | if (fprintf(file, #str "=%"fmt "\n", data) < 0) { \
| ^~~
util/evsel.c:166:9: note: in expansion of macro 'WRITE_ASS'

  166 |         WRITE_ASS(sample_type,   "llu");
      |         ^~~~~~~~~

util/evsel.c:167:39: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
167 | WRITE_ASS(read_format, "llu");
| ^
util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
122 | if (fprintf(file, #str "=%"fmt "\n", data) < 0) { \
| ^~~
util/evsel.c:167:9: note: in expansion of macro 'WRITE_ASS'

  167 |         WRITE_ASS(read_format,   "llu");
      |         ^~~~~~~~~

util/evsel.c:198:33: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
198 | WRITE_ASS(config1, "llu");
| ^
util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
122 | if (fprintf(file, #str "=%"fmt "\n", data) < 0) { \
| ^~~
util/evsel.c:198:9: note: in expansion of macro 'WRITE_ASS'

  198 |         WRITE_ASS(config1, "llu");
      |         ^~~~~~~~~

util/evsel.c:199:33: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
199 | WRITE_ASS(config2, "llu");
| ^
util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
122 | if (fprintf(file, #str "=%"fmt "\n", data) < 0) { \
| ^~~
util/evsel.c:199:9: note: in expansion of macro 'WRITE_ASS'

  199 |         WRITE_ASS(config2, "llu");
      |         ^~~~~~~~~

util/evsel.c:200:44: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
200 | WRITE_ASS(branch_sample_type, "llu");
| ^
util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
122 | if (fprintf(file, #str "=%"fmt "\n", data) < 0) { \
| ^~~
util/evsel.c:200:9: note: in expansion of macro 'WRITE_ASS'

  200 |         WRITE_ASS(branch_sample_type, "llu");
      |         ^~~~~~~~~

util/evsel.c:201:44: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
201 | WRITE_ASS(sample_regs_user, "llu");
| ^
util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
122 | if (fprintf(file, #str "=%"fmt "\n", data) < 0) { \
| ^~~
util/evsel.c:201:9: note: in expansion of macro 'WRITE_ASS'

  201 |         WRITE_ASS(sample_regs_user,   "llu");
      |         ^~~~~~~~~

cc1: all warnings being treated as errors

Caused by commit

f90a29144887 ("perf test: Remove C test wrapper for attr.py")

This is a native build of perf on ppc64le using

make -C tools/perf -f Makefile.perf NO_BPF_SKEL=1

I have merged the perf tree from next-20241010 for today.

Signature · 2 lines
Cheers,
Stephen Rothwell
maintainer
#1 lore raw

PATCH 1/1 perf tools: Fix build failures on ppc64le

util/evsel.c: In function 'store_event':
util/evsel.c:138:50: error: format '%llu' expects argument of type 'long long unsigned int',

                       but argument 6 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
    138 |         snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir,
        |                                               ~~~^
        |                                                  |
        |                                                  long long unsigned int
        |                                               %lu
    139 |                  attr->type, attr->config, fd);
        |                              ~~~~~~~~~~~~
        |                                  |
        |                                  __u64 {aka long unsigned int}
  util/evsel.c:147:41: error: format '%llu' expects argument of type 'long long unsigned int',
                       but argument 4 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
    147 |         if (fprintf(file, "[event-%d-%llu-%d]\n",
        |                                      ~~~^
        |                                         |
        |                                         long long unsigned int
        |                                      %lu
    148 |                     attr->type, attr->config, fd) < 0) {
        |                                 ~~~~~~~~~~~~
        |                                     |
        |                                     __u64 {aka long unsigned int}
  util/evsel.c:164:33: error: format '%llu' expects argument of type 'long long unsigned int',
                       but argument 3 has type '__u64' {aka 'long unsigned int'} [-Werror=format=]
    164 |         WRITE_ASS(config,  "llu");
        |                                 ^
  util/evsel.c:122:28: note: in definition of macro '__WRITE_ASS'
    122 |         if (fprintf(file, #str "=%"fmt "\n", data) < 0) {               \
        |                            ^~~
  util/evsel.c:164:9: note: in expansion of macro 'WRITE_ASS'
    164 |         WRITE_ASS(config,  "llu");
        |         ^~~~~~~~~

...
cc1: all warnings being treated as errors

Fixes f90a291448877ab45 ("perf test: Remove C test wrapper for attr.py")

---
Hi Stephen, can you please test if this patch fixes it?

Thanks,
Namhyung

 tools/perf/util/evsel.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
tools/perf/util/evsel.c +10 -10
index 37c338b0f8b2bb04..88e98c0b10528a63 100644
@@ -108,7 +108,7 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, struct perf_cpu
 	char path[PATH_MAX];
 	char *dir = getenv("PERF_TEST_ATTR");
 
-	snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir,
+	snprintf(path, PATH_MAX, "%s/event-%d-%"PRI_lu64"-%d", dir,
 		 attr->type, attr->config, fd);
 
 	file = fopen(path, "w+");
@@ -117,7 +117,7 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, struct perf_cpu
 		return -1;
 	}
 
-	if (fprintf(file, "[event-%d-%llu-%d]\n",
+	if (fprintf(file, "[event-%d-%"PRI_lu64"-%d]\n",
 		    attr->type, attr->config, fd) < 0) {
 		perror("test attr - failed to write event file");
 		fclose(file);
@@ -134,10 +134,10 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, struct perf_cpu
 	/* struct perf_event_attr */
 	WRITE_ASS(type,   PRIu32);
 	WRITE_ASS(size,   PRIu32);
-	WRITE_ASS(config,  "llu");
-	WRITE_ASS(sample_period, "llu");
-	WRITE_ASS(sample_type,   "llu");
-	WRITE_ASS(read_format,   "llu");
+	WRITE_ASS(config,  PRI_lu64);
+	WRITE_ASS(sample_period, PRI_lu64);
+	WRITE_ASS(sample_type,   PRI_lu64);
+	WRITE_ASS(read_format,   PRI_lu64);
 	WRITE_ASS(disabled,       "d");
 	WRITE_ASS(inherit,        "d");
 	WRITE_ASS(pinned,         "d");
@@ -168,10 +168,10 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, struct perf_cpu
 	WRITE_ASS(use_clockid,    "d");
 	WRITE_ASS(wakeup_events, PRIu32);
 	WRITE_ASS(bp_type, PRIu32);
-	WRITE_ASS(config1, "llu");
-	WRITE_ASS(config2, "llu");
-	WRITE_ASS(branch_sample_type, "llu");
-	WRITE_ASS(sample_regs_user,   "llu");
+	WRITE_ASS(config1, PRI_lu64);
+	WRITE_ASS(config2, PRI_lu64);
+	WRITE_ASS(branch_sample_type, PRI_lu64);
+	WRITE_ASS(sample_regs_user,   PRI_lu64);
 	WRITE_ASS(sample_stack_user,  PRIu32);
 
 	fclose(file);
Signature · 1 line
2.47.0.rc1.288.g06298d1525-goog
#2 lore raw

Re: [PATCH] perf tools: Fix build failures on ppc64le

Hi Namhyung,

Quoted 2 lines · On Thu, 10 Oct 2024 16:57:43 -0700 Namhyung Kim <[email protected]> wrote:

Hi Stephen, can you please test if this patch fixes it?

Sorry, I still get the same errors.

Signature · 2 lines
Cheers,
Stephen Rothwell
maintainer
#3 lore raw

Re: [PATCH] perf tools: Fix build failures on ppc64le

Quoted 7 lines · Stephen Rothwell

Hi Namhyung,

Quoted 2 lines · On Thu, 10 Oct 2024 16:57:43 -0700 Namhyung Kim <[email protected]> wrote:

Hi Stephen, can you please test if this patch fixes it?

Sorry, I still get the same errors.

Ok, thanks for the test. I'll drop the series and rebase the branch.

Thanks,
Namhyung

reviewer
#4 lore raw

Re: [PATCH] perf tools: Fix build failures on ppc64le

Quoted 11 lines · Namhyung Kim
Quoted 7 lines · Stephen Rothwell

Hi Namhyung,

Quoted 2 lines · On Thu, 10 Oct 2024 16:57:43 -0700 Namhyung Kim <[email protected]> wrote:

Hi Stephen, can you please test if this patch fixes it?

Sorry, I still get the same errors.

Ok, thanks for the test. I'll drop the series and rebase the branch.

Is this a define issue? I dislike that PPC has a #define __SANE_USERSPACE_TYPES__, we might be trying to fix something inherently insane.

The failure at:

```
    138 |         snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir,
        |                                               ~~~^
        |                                                  |
        |                                                  long long
unsigned int
        |                                               %lu
    139 |                  attr->type, attr->config, fd);
        |                              ~~~~~~~~~~~~
        |                                  |
        |                                  __u64 {aka long unsigned int}
  util/evsel.c:147:41: error: format '%llu' expects argument of type
'long long unsigned int',
                       but argument 4 has type '__u64' {aka 'long
unsigned int'} [-Werror=format=]
```
is for code moved from here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/tests/attr.c#n77
```
snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir,
attr->type, attr->config, fd);
```

ie the code is identical, so why does it compile in one file and not in another?

Elsewhere for PPC we carry:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/tests/bp_account.c#n3

```
/*
 * Powerpc needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
 * 'int-ll64.h' and avoid compile warnings when printing __u64 with %llu.
 */
#define __SANE_USERSPACE_TYPES__
```

Given the comment I suspect we need to do similar to fix this. Stephen, could you test?

Thanks,
Ian

#5 lore raw

Re: [PATCH] perf tools: Fix build failures on ppc64le

Hi Ian,

Quoted 10 lines · On Fri, 11 Oct 2024 00:05:21 -0700 Ian Rogers <[email protected]> wrote:

Elsewhere for PPC we carry:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/tests/bp_account.c#n3

```
/*
 * Powerpc needs __SANE_USERSPACE_TYPES__ before <linux/types.h> to select
 * 'int-ll64.h' and avoid compile warnings when printing __u64 with %llu.
 */
#define __SANE_USERSPACE_TYPES__
```
Quoted 2 lines

Given the comment I suspect we need to do similar to fix this. Stephen, could you test?

I added that to the start of tools/perf/util/evsel.c and it builds fine.

Thanks

Signature · 2 lines
Cheers,
Stephen Rothwell