Re: [PATCH] perf jevents: Fix sys_event_tables to be freed like arch_std_events

From: Arnaldo Carvalho de Melo
Date: Tue Sep 28 2021 - 13:56:37 EST


Em Tue, Sep 28, 2021 at 02:32:02PM +0100, John Garry escreveu:
> On 28/09/2021 14:22, Arnaldo Carvalho de Melo wrote:
> > 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.
>
> Hi Arnaldo,
>
> OK, would you also consider reusing CFLAGS:
>
> --- a/tools/perf/pmu-events/Build
> +++ b/tools/perf/pmu-events/Build
> @@ -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)

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.

> 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