Skip to contentSkip to conversation

perf jevents: Fix sys_event_tables to be freed like arch_std_events

PATCH Applied Like Xu 3 participants 11 messages Sep 28, 2021 – Oct 11, 2021 perf events

lore
Share & tools
lore

Like Xu

author
#0 lore raw

PATCH 1/1 perf jevents: Fix sys_event_tables to be freed like arch_std_events

From: Like Xu <[email protected]>

The compiler reports that free_sys_event_tables() is dead code. But according to the semantics, the "LIST_HEAD(arch_std_events)" should also be released, just like we do with 'arch_std_events' in the main().

Fixes e9d32c1bf0cd7a98 ("perf vendor events: Add support for arch standard events")
---
 tools/perf/pmu-events/jevents.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/pmu-events/jevents.c +2 -0
index 6731b3cf0c2f..7c887d37b893 100644
@@ -1285,6 +1285,7 @@ int main(int argc, char *argv[])
 	}
 
 	free_arch_std_events();
+	free_sys_event_tables();
 	free(mapfile);
 	return 0;
 
@@ -1306,6 +1307,7 @@ int main(int argc, char *argv[])
 		create_empty_mapping(output_file);
 err_out:
 	free_arch_std_events();
+	free_sys_event_tables();
 	free(mapfile);
 	return ret;
 }
Signature · 1 line
2.32.0
maintainer Applied
#1 lore raw

Em Tue, Sep 28, 2021 at 06:29:38PM +0800, Like Xu escreveu:

Quoted 5 lines

From: Like Xu <[email protected]>

The compiler reports that free_sys_event_tables() is dead code. But according to the semantics, the "LIST_HEAD(arch_std_events)" should also be released, just like we do with 'arch_std_events' in the main().

Thanks, applied.

- Arnaldo

Quoted 28 lines
Fixes e9d32c1bf0cd7a98 ("perf vendor events: Add support for arch standard events")
---
 tools/perf/pmu-events/jevents.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/pmu-events/jevents.c +2 -0
index 6731b3cf0c2f..7c887d37b893 100644
@@ -1285,6 +1285,7 @@ int main(int argc, char *argv[])
 	}
 
 	free_arch_std_events();
+	free_sys_event_tables();
 	free(mapfile);
 	return 0;
 
@@ -1306,6 +1307,7 @@ int main(int argc, char *argv[])
 		create_empty_mapping(output_file);
 err_out:
 	free_arch_std_events();
+	free_sys_event_tables();
 	free(mapfile);
 	return ret;
 }
Signature · 1 line
2.32.0
Signature · 1 line
- Arnaldo
author
#2 lore raw
Quoted 5 lines · Arnaldo Carvalho de Melo

Em Tue, Sep 28, 2021 at 06:29:38PM +0800, Like Xu escreveu:

Quoted 4 lines

From: Like Xu <[email protected]>

The compiler reports that free_sys_event_tables() is dead code. But according to the semantics, the "LIST_HEAD(arch_std_events)" should

Sorry, s/arch_std_events/sys_event_tables/, please --amend.

Quoted 36 lines
Quoted 1 line

also be released, just like we do with 'arch_std_events' in the main().

Thanks, applied.

- Arnaldo

Quoted 28 lines
Fixes e9d32c1bf0cd7a98 ("perf vendor events: Add support for arch standard events")
---
  tools/perf/pmu-events/jevents.c | 2 ++
  1 file changed, 2 insertions(+)
tools/perf/pmu-events/jevents.c +2 -0
index 6731b3cf0c2f..7c887d37b893 100644
@@ -1285,6 +1285,7 @@ int main(int argc, char *argv[])
  	}
 
  	free_arch_std_events();
+	free_sys_event_tables();
  	free(mapfile);
  	return 0;
 
@@ -1306,6 +1307,7 @@ int main(int argc, char *argv[])
  		create_empty_mapping(output_file);
  err_out:
  	free_arch_std_events();
+	free_sys_event_tables();
  	free(mapfile);
  	return ret;
  }
Signature · 1 line
2.32.0
#3 lore raw

Em Tue, Sep 28, 2021 at 07:53:54PM +0800, Like Xu escreveu:

Quoted 7 lines · Arnaldo Carvalho de Melo
Quoted 5 lines

Em Tue, Sep 28, 2021 at 06:29:38PM +0800, Like Xu escreveu:

Quoted 4 lines

From: Like Xu <[email protected]>

The compiler reports that free_sys_event_tables() is dead code. But according to the semantics, the "LIST_HEAD(arch_std_events)" should

Sorry, s/arch_std_events/sys_event_tables/, please --amend.

sure

Quoted 33 lines
Quoted 33 lines
Quoted 1 line

also be released, just like we do with 'arch_std_events' in the main().

Thanks, applied.

- Arnaldo

Quoted 26 lines
Fixes e9d32c1bf0cd7a98 ("perf vendor events: Add support for arch standard events")
---
  tools/perf/pmu-events/jevents.c | 2 ++
  1 file changed, 2 insertions(+)
tools/perf/pmu-events/jevents.c +2 -0
index 6731b3cf0c2f..7c887d37b893 100644
@@ -1285,6 +1285,7 @@ int main(int argc, char *argv[])
  	}
  	free_arch_std_events();
+	free_sys_event_tables();
  	free(mapfile);
  	return 0;
@@ -1306,6 +1307,7 @@ int main(int argc, char *argv[])
  		create_empty_mapping(output_file);
  err_out:
  	free_arch_std_events();
+	free_sys_event_tables();
  	free(mapfile);
  	return ret;
  }
Signature · 1 line
2.32.0
Signature · 1 line
- Arnaldo
Reviewed-by
#4 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 11 lines · Arnaldo Carvalho de Melo

Em Tue, Sep 28, 2021 at 06:29:38PM +0800, Like Xu escreveu:

Quoted 5 lines

From: Like Xu <[email protected]>

The compiler reports that free_sys_event_tables() is dead code. But according to the semantics, the "LIST_HEAD(arch_std_events)" should also be released, just like we do with 'arch_std_events' in the main().

Thanks, applied.

- Arnaldo

If not too late:

I think that it could be a good idea to raise gcc warning level to detect unused static functions, like this was

thanks

Quoted 30 lines
Quoted 29 lines
Fixes e9d32c1bf0cd7a98 ("perf vendor events: Add support for arch standard events")
---
  tools/perf/pmu-events/jevents.c | 2 ++
  1 file changed, 2 insertions(+)
tools/perf/pmu-events/jevents.c +2 -0
index 6731b3cf0c2f..7c887d37b893 100644
@@ -1285,6 +1285,7 @@ int main(int argc, char *argv[])
  	}
 
  	free_arch_std_events();
+	free_sys_event_tables();
  	free(mapfile);
  	return 0;
 
@@ -1306,6 +1307,7 @@ int main(int argc, char *argv[])
  		create_empty_mapping(output_file);
  err_out:
  	free_arch_std_events();
+	free_sys_event_tables();
  	free(mapfile);
  	return ret;
  }
Signature · 1 line
2.32.0
#5 lore raw

Em Tue, Sep 28, 2021 at 01:49:20PM +0100, John Garry escreveu:

Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 7 lines

Em Tue, Sep 28, 2021 at 06:29:38PM +0800, Like Xu escreveu:

Quoted 5 lines

From: Like Xu <[email protected]>

The compiler reports that free_sys_event_tables() is dead code. But according to the semantics, the "LIST_HEAD(arch_std_events)" should also be released, just like we do with 'arch_std_events' in the main().

Quoted 7 lines
Quoted 4 lines

Thanks, applied.

- Arnaldo

If not too late:

Not too late, collected.

Quoted 2 lines

I think that it could be a good idea to raise gcc warning level to detect unused static functions, like this was

Agreed, but we already have:

CORE_CFLAGS += -Wall
CORE_CFLAGS += -Wextra

We can se it for this specific case with:

$ make V=1 -k BUILD_BPF_SKEL=1 CORESIGHT=1 PYTHON=python3 O=/tmp/build/perf -C tools/perf install-bin | grep jevents
make -f /var/home/acme/git/perf/tools/build/Makefile.build dir=pmu-events obj=jevents
  gcc -Wp,-MD,/tmp/build/perf/pmu-events/.jevents.o.d -Wp,-MT,/tmp/build/perf/pmu-events/jevents.o  -D"BUILD_STR(s)=#s" -I/var/home/acme/git/perf/tools/include  -c -o /tmp/build/perf/pmu-events/jevents.o pmu-events/jevents.c
   ld -r -o /tmp/build/perf/pmu-events/jevents-in.o  /tmp/build/perf/pmu-events/json.o /tmp/build/perf/pmu-events/jsmn.o /tmp/build/perf/pmu-events/jevents.o
gcc /tmp/build/perf/pmu-events/jevents-in.o -o /tmp/build/perf/pmu-events/jevents
/tmp/build/perf/pmu-events/jevents x86 pmu-events/arch /tmp/build/perf/pmu-events/pmu-events.c 1
jevents: Processing mapfile pmu-events/arch/x86/mapfile.csv

Humm... no "-Wall -Wextra" there... lemme try to fix it

- Arnaldo

Quoted 29 lines

thanks

Quoted 27 lines
Quoted 26 lines
Fixes e9d32c1bf0cd7a98 ("perf vendor events: Add support for arch standard events")
---
  tools/perf/pmu-events/jevents.c | 2 ++
  1 file changed, 2 insertions(+)
tools/perf/pmu-events/jevents.c +2 -0
index 6731b3cf0c2f..7c887d37b893 100644
@@ -1285,6 +1285,7 @@ int main(int argc, char *argv[])
  	}
  	free_arch_std_events();
+	free_sys_event_tables();
  	free(mapfile);
  	return 0;
@@ -1306,6 +1307,7 @@ int main(int argc, char *argv[])
  		create_empty_mapping(output_file);
  err_out:
  	free_arch_std_events();
+	free_sys_event_tables();
  	free(mapfile);
  	return ret;
  }
Signature · 1 line
2.32.0
Signature · 1 line
- Arnaldo
#6 lore raw

Em Tue, Sep 28, 2021 at 10:16:48AM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 37 lines

Em Tue, Sep 28, 2021 at 01:49:20PM +0100, John Garry escreveu:

Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 7 lines

Em Tue, Sep 28, 2021 at 06:29:38PM +0800, Like Xu escreveu:

Quoted 5 lines

From: Like Xu <[email protected]>

The compiler reports that free_sys_event_tables() is dead code. But according to the semantics, the "LIST_HEAD(arch_std_events)" should also be released, just like we do with 'arch_std_events' in the main().

Quoted 7 lines
Quoted 4 lines

Thanks, applied.

- Arnaldo

If not too late:

Not too late, collected.

Quoted 2 lines

I think that it could be a good idea to raise gcc warning level to detect unused static functions, like this was

Agreed, but we already have:

CORE_CFLAGS += -Wall
CORE_CFLAGS += -Wextra

We can se it for this specific case with:

$ make V=1 -k BUILD_BPF_SKEL=1 CORESIGHT=1 PYTHON=python3 O=/tmp/build/perf -C tools/perf install-bin | grep jevents
make -f /var/home/acme/git/perf/tools/build/Makefile.build dir=pmu-events obj=jevents
  gcc -Wp,-MD,/tmp/build/perf/pmu-events/.jevents.o.d -Wp,-MT,/tmp/build/perf/pmu-events/jevents.o  -D"BUILD_STR(s)=#s" -I/var/home/acme/git/perf/tools/include  -c -o /tmp/build/perf/pmu-events/jevents.o pmu-events/jevents.c
   ld -r -o /tmp/build/perf/pmu-events/jevents-in.o  /tmp/build/perf/pmu-events/json.o /tmp/build/perf/pmu-events/jsmn.o /tmp/build/perf/pmu-events/jevents.o
gcc /tmp/build/perf/pmu-events/jevents-in.o -o /tmp/build/perf/pmu-events/jevents
/tmp/build/perf/pmu-events/jevents x86 pmu-events/arch /tmp/build/perf/pmu-events/pmu-events.c 1
jevents: Processing mapfile pmu-events/arch/x86/mapfile.csv
Quoted 1 line

Humm... no "-Wall -Wextra" there... lemme try to fix it

With this:

⬢[acme@toolbox perf]$ git diff

tools/perf/pmu-events/Build +1 -1
index a055dee6a46af77e..ea7107630bf4327f 100644
@@ -1,7 +1,7 @@
 hostprogs := jevents
 
 jevents-y      += json.o jsmn.o jevents.o
-HOSTCFLAGS_jevents.o   = -I$(srctree)/tools/include
+HOSTCFLAGS_jevents.o   = -I$(srctree)/tools/include -Wall -Wextra
 pmu-events-y   += pmu-events.o
 JDIR           =  pmu-events/arch/$(SRCARCH)
 JSON           =  $(shell [ -d $(JDIR) ] &&                            \

⬢[acme@toolbox perf]$

I get this before applying Xu's patch:

LINK /tmp/build/perf/libbpf.a
pmu-events/jevents.c: In function ‘save_arch_std_events’:
pmu-events/jevents.c:473:39: warning: unused parameter ‘data’ [-Wunused-parameter]
473 | static int save_arch_std_events(void *data, struct json_event *je)
| ~~~~~~^~~~
At top level:
pmu-events/jevents.c:93:13: warning: ‘free_sys_event_tables’ defined but not used [-Wunused-function]
93 | static void free_sys_event_tables(void)

      |             ^~~~~~~~~~~~~~~~~~~~~

-------------------------------------

I'll add this to perf/core, as this isn't a strict fix, so can wait for v5.16.

- Arnaldo

#7 lore raw
Quoted 21 lines · Arnaldo Carvalho de Melo

jevents-y += json.o jsmn.o jevents.o

(quoted diff) +1 -1
-HOSTCFLAGS_jevents.o   = -I$(srctree)/tools/include
+HOSTCFLAGS_jevents.o   = -I$(srctree)/tools/include -Wall -Wextra
  pmu-events-y   += pmu-events.o
  JDIR           =  pmu-events/arch/$(SRCARCH)
  JSON           =  $(shell [ -d $(JDIR) ] &&                            \

⬢[acme@toolbox perf]$

I get this before applying Xu's patch:

LINK /tmp/build/perf/libbpf.a
pmu-events/jevents.c: In function ‘save_arch_std_events’:
pmu-events/jevents.c:473:39: warning: unused parameter ‘data’ [-Wunused-parameter]
473 | static int save_arch_std_events(void *data, struct json_event *je)
| ~~~~~~^~~~
At top level:
pmu-events/jevents.c:93:13: warning: ‘free_sys_event_tables’ defined but not used [-Wunused-function]
93 | static void free_sys_event_tables(void)
| ^~~~~~~~~~~~~~~~~~~~~

Quoted 4 lines

-------------------------------------

I'll add this to perf/core, as this isn't a strict fix, so can wait for v5.16.

Hi Arnaldo,

OK, would you also consider reusing CFLAGS:

tools/perf/pmu-events/Build +0 -0
@@ -9,10 +9,12 @@ JSON          =  $(shell [ -d $(JDIR) ] && 
               \
JDIR_TEST      =  pmu-events/arch/test
JSON_TEST      =  $(shell [ -d $(JDIR_TEST) ] &&                       \
                       find $(JDIR_TEST) -name '*.json')

-
+HOSTCFLAGS_jevents += $(CFLAGS)

I tried it, and there are more things to fix for jevents.o. Let me know your preference and if any help required to fix any errors up.

Thanks!

#8 lore raw

Em Tue, Sep 28, 2021 at 02:32:02PM +0100, John Garry escreveu:

Quoted 38 lines · Arnaldo Carvalho de Melo
Quoted 21 lines

jevents-y += json.o jsmn.o jevents.o

(quoted diff) +1 -1
-HOSTCFLAGS_jevents.o   = -I$(srctree)/tools/include
+HOSTCFLAGS_jevents.o   = -I$(srctree)/tools/include -Wall -Wextra
  pmu-events-y   += pmu-events.o
  JDIR           =  pmu-events/arch/$(SRCARCH)
  JSON           =  $(shell [ -d $(JDIR) ] &&                            \

⬢[acme@toolbox perf]$

I get this before applying Xu's patch:

LINK /tmp/build/perf/libbpf.a
pmu-events/jevents.c: In function ‘save_arch_std_events’:
pmu-events/jevents.c:473:39: warning: unused parameter ‘data’ [-Wunused-parameter]
473 | static int save_arch_std_events(void *data, struct json_event *je)
| ~~~~~~^~~~
At top level:
pmu-events/jevents.c:93:13: warning: ‘free_sys_event_tables’ defined but not used [-Wunused-function]
93 | static void free_sys_event_tables(void)
| ^~~~~~~~~~~~~~~~~~~~~

Quoted 4 lines

-------------------------------------

I'll add this to perf/core, as this isn't a strict fix, so can wait for v5.16.

Hi Arnaldo,

OK, would you also consider reusing CFLAGS:

tools/perf/pmu-events/Build +0 -0
@@ -9,10 +9,12 @@ JSON          =  $(shell [ -d $(JDIR) ] &&
 \
JDIR_TEST      =  pmu-events/arch/test
JSON_TEST      =  $(shell [ -d $(JDIR_TEST) ] &&                       \
                       find $(JDIR_TEST) -name '*.json')

tools/perf/pmu-events/Build

Quoted 2 lines
tools/perf/pmu-events/Build +1 -1
-
+HOSTCFLAGS_jevents += $(CFLAGS)

Humm, we have to check if CFLAGS doesn't come with cross-build options, i.e. IIRC we have to use HOSTCFLAGS instead. Unsure if there is some *CFLAGS variable that gets the common part, where these -Wall and -Wextra, -Werror could go.

Quoted 2 lines

I tried it, and there are more things to fix for jevents.o. Let me know your preference and if any help required to fix any errors up.

I fixed the one I found, see below, I'll test build what I have in perf/core and push it, then you can continue from there, after checking this HOSTCFLAGS/CFLAGS issue.

- Arnaldo

From 0e46c8307574a8e2dac8d7ba97e0f6f4bbee67a5 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <[email protected]>
Date: Tue, 28 Sep 2021 14:15:01 -0300
Subject: [PATCH 1/1] perf jevents: Add __maybe_unused attribute to unused
function arg

The tools/perf/pmu-events/jevents.c file isn't being compiled with -Werror and -Wextra, which will be the case soon, so before we turn those compiler flags on, fix what it would flag.

Cc Alexander Shishkin <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Like Xu <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>

To: John Garry <[email protected]>

---
 tools/perf/pmu-events/jevents.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/pmu-events/jevents.c +2 -1
index 6731b3cf0c2fc9b7..323e1dfe2436c049 100644
@@ -45,6 +45,7 @@
 #include <sys/resource.h>		/* getrlimit */
 #include <ftw.h>
 #include <sys/stat.h>
+#include <linux/compiler.h>
 #include <linux/list.h>
 #include "jsmn.h"
 #include "json.h"
@@ -470,7 +471,7 @@ static void free_arch_std_events(void)
 	}
 }
 
-static int save_arch_std_events(void *data, struct json_event *je)
+static int save_arch_std_events(void *data __maybe_unused, struct json_event *je)
 {
 	struct event_struct *es;
 
Signature · 1 line
2.31.1
Reviewed-by
#9 lore raw
Quoted 18 lines · Arnaldo Carvalho de Melo
Quoted 18 lines
Quoted 10 lines

‘save_arch_std_events’:
pmu-events/jevents.c:473:39: warning: unused parameter ‘data’ [-Wunused-parameter]
473 | static int save_arch_std_events(void *data, struct json_event *je)
| ~~~~~~^~~~
At top level:
pmu-events/jevents.c:93:13: warning: ‘free_sys_event_tables’ defined but not used [-Wunused-function]
93 | static void free_sys_event_tables(void)
| ^~~~~~~~~~~~~~~~~~~~~

Quoted 4 lines

-------------------------------------

I'll add this to perf/core, as this isn't a strict fix, so can wait for v5.16.

Hi Arnaldo,

OK, would you also consider reusing CFLAGS:

Quoted 13 lines

tools/perf/pmu-events/Build

Quoted 9 lines
tools/perf/pmu-events/Build +0 -0
@@ -9,10 +9,12 @@ JSON          =  $(shell [ -d $(JDIR) ] &&
 \
JDIR_TEST      =  pmu-events/arch/test
JSON_TEST      =  $(shell [ -d $(JDIR_TEST) ] &&                       \
                        find $(JDIR_TEST) -name '*.json')
tools/perf/pmu-events/Build +1 -1
-
+HOSTCFLAGS_jevents += $(CFLAGS)

Humm, we have to check if CFLAGS doesn't come with cross-build options, i.e. IIRC we have to use HOSTCFLAGS instead. Unsure if there is some *CFLAGS variable that gets the common part, where these -Wall and -Wextra, -Werror could go.

not sure. As I see, the bulk of flags we have in CFLAGS comes from EXTRA_WARNINGS in scripts/Makefile.include; but CFLAGS seems to also include EXTRA_CLAGS, which are for cross-builds (see perf/Makefile.config)

So maybe we just need to use EXTRA_WARNINGS for HOST_CFLAGS

Quoted 27 lines
Quoted 3 lines

I tried it, and there are more things to fix for jevents.o. Let me know your preference and if any help required to fix any errors up.

I fixed the one I found, see below, I'll test build what I have in perf/core and push it, then you can continue from there, after checking this HOSTCFLAGS/CFLAGS issue.

- Arnaldo

Quoted 1 line

From 0e46c8307574a8e2dac8d7ba97e0f6f4bbee67a5 Mon Sep 17 00:00:00 2001

From: Arnaldo Carvalho de Melo<[email protected]>
Date: Tue, 28 Sep 2021 14:15:01 -0300
Subject: [PATCH 1/1] perf jevents: Add __maybe_unused attribute to unused
function arg

The tools/perf/pmu-events/jevents.c file isn't being compiled with -Werror and -Wextra, which will be the case soon, so before we turn those compiler flags on, fix what it would flag.

Cc Alexander Shishkin<[email protected]>
Cc Ingo Molnar<[email protected]>
Cc Jiri Olsa<[email protected]>
Cc Like Xu<[email protected]>
Cc Mark Rutland<[email protected]>
Cc Namhyung Kim<[email protected]>
Cc Peter Zijlstra<[email protected]>
Quoted 1 line

To: John Garry<[email protected]>

thanks.

Quoted 24 lines
---
  tools/perf/pmu-events/jevents.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/pmu-events/jevents.c +2 -1
index 6731b3cf0c2fc9b7..323e1dfe2436c049 100644
@@ -45,6 +45,7 @@
  #include <sys/resource.h>		/* getrlimit */
  #include <ftw.h>
  #include <sys/stat.h>
+#include <linux/compiler.h>
  #include <linux/list.h>
  #include "jsmn.h"
  #include "json.h"
@@ -470,7 +471,7 @@ static void free_arch_std_events(void)
  	}
  }
 
-static int save_arch_std_events(void *data, struct json_event *je)
+static int save_arch_std_events(void *data __maybe_unused, struct json_event *je)
  {
  	struct event_struct *es;
#10 lore raw

perf tools jevents build flags (was Re: [PATCH] perf jevents: Fix sys_event_tables to be freed like arch_std_events)

Quoted 17 lines · John Garry
Quoted 16 lines

tools/perf/pmu-events/Build

Quoted 12 lines

OK, would you also consider reusing CFLAGS:

tools/perf/pmu-events/Build +0 -0
@@ -9,10 +9,12 @@ JSON          =  $(shell [ -d $(JDIR) ] &&
 \

JDIR_TEST      =  pmu-events/arch/test
JSON_TEST      =  $(shell [ -d $(JDIR_TEST) ] &&                       \
                        find $(JDIR_TEST) -name '*.json')

tools/perf/pmu-events/Build +1 -1
-
+HOSTCFLAGS_jevents += $(CFLAGS)

Humm, we have to check if CFLAGS doesn't come with cross-build options, i.e. IIRC we have to use HOSTCFLAGS instead. Unsure if there is some *CFLAGS variable that gets the common part, where these -Wall and -Wextra, -Werror could go.

Quoted 2 lines

not sure. As I see, the bulk of flags we have in CFLAGS comes from EXTRA_WARNINGS in scripts/Makefile.include; but CFLAGS seems to also include EXTRA_CLAGS, which are for cross-builds (see perf/Makefile.config)

Hi Arnaldo,

I'm just looking at enabling warning cflags for jevents again.

So how about this:

--->8----

Subject: [PATCH] perf pmu-events: Enable jevents warnings through HOSTCFLAGS

tools/perf/Makefile.config +1 -0
index 0ae2e3d8b832..65934984f032 100644
@@ -17,6 +17,7 @@ detected     = $(shell echo "$(1)=y"       >> $(OUTPUT).config-detected)
 detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
 
 CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
+HOSTCFLAGS := $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
 
 include $(srctree)/tools/scripts/Makefile.arch
 
tools/perf/Makefile.perf +1 -1
index 7df13e74450c..118bcdc70bb4 100644
@@ -226,7 +226,7 @@ else
 endif
 
 export srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWK
-export HOSTCC HOSTLD HOSTAR
+export HOSTCC HOSTLD HOSTAR HOSTCFLAGS
 
 include $(srctree)/tools/build/Makefile.include
 
tools/perf/pmu-events/Build +1 -1
index a055dee6a46a..d5c287f069a2 100644
@@ -1,7 +1,7 @@
 hostprogs := jevents
 
 jevents-y	+= json.o jsmn.o jevents.o
-HOSTCFLAGS_jevents.o	= -I$(srctree)/tools/include
+HOSTCFLAGS_jevents.o	= -I$(srctree)/tools/include $(HOSTCFLAGS)
 pmu-events-y	+= pmu-events.o
 JDIR		=  pmu-events/arch/$(SRCARCH)
 JSON		=  $(shell [ -d $(JDIR) ] &&				\
Signature · 8 lines
2.26.2

---8<---

The newly generated warnings in jevents.c are pretty straightforward to tidy up.

Thanks,
John