tools/perf/util/evsel.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
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")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
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(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 37c338b0f8b2bb04..88e98c0b10528a63 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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);
--
2.47.0.rc1.288.g06298d1525-goog
Hi Namhyung, On Thu, 10 Oct 2024 16:57:43 -0700 Namhyung Kim <namhyung@kernel.org> wrote: > > Hi Stephen, can you please test if this patch fixes it? Sorry, I still get the same errors. -- Cheers, Stephen Rothwell
On Fri, Oct 11, 2024 at 11:48:58AM +1100, Stephen Rothwell wrote: > Hi Namhyung, > > On Thu, 10 Oct 2024 16:57:43 -0700 Namhyung Kim <namhyung@kernel.org> 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
On Thu, Oct 10, 2024 at 11:34 PM Namhyung Kim <namhyung@kernel.org> wrote: > > On Fri, Oct 11, 2024 at 11:48:58AM +1100, Stephen Rothwell wrote: > > Hi Namhyung, > > > > On Thu, 10 Oct 2024 16:57:43 -0700 Namhyung Kim <namhyung@kernel.org> 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
Hi Ian, On Fri, 11 Oct 2024 00:05:21 -0700 Ian Rogers <irogers@google.com> 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__ > ``` > 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 -- Cheers, Stephen Rothwell
© 2016 - 2024 Red Hat, Inc.