From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
Leo Yan <leo.yan@arm.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH] libperf: Add back guard on MAX_NR_CPUS
Date: Tue, 7 Jan 2025 09:31:41 +0100 [thread overview]
Message-ID: <fa5dfd6d-3b8d-4086-9604-e5abddd324c9@csgroup.eu> (raw)
In-Reply-To: <CAP-5=fWVHaVpJbDf=afn5MhZ972uEq=sGEmsULoD=LRff2Vouw@mail.gmail.com>
Le 06/01/2025 à 21:05, Ian Rogers a écrit :
> On Mon, Jan 6, 2025 at 11:38 AM Christophe Leroy
> <christophe.leroy@csgroup.eu> wrote:
>>
>> Building perf with EXTRA_CFLAGS="-DMAX_NR_CPUS=1" fails:
>>
>> CC /home/chleroy/linux-powerpc/tools/perf/libperf/cpumap.o
>> cpumap.c:16: error: "MAX_NR_CPUS" redefined [-Werror]
>> 16 | #define MAX_NR_CPUS 4096
>> |
>> <command-line>: note: this is the location of the previous definition
>>
>> Commit e8399d34d568 ("libperf cpumap: Hide/reduce scope of MAX_NR_CPUS")
>> moved definition of MAX_NR_CPUS from lib/perf/include/internal/cpumap.h
>> to lib/perf/cpumap.c but the guard surrounding that definition got lost
>> in the move.
>>
>> See commit 21b8732eb447 ("perf tools: Allow overriding MAX_NR_CPUS at
>> compile time") to see why it is needed.
>>
>> Note that MAX_NR_CPUS was initialy defined in perf/perf.h and a
>> redundant definition was added by commit 9c3516d1b850 ("libperf:
>> Add perf_cpu_map__new()/perf_cpu_map__read() functions").
>>
>> A cleaner fix would be to remove that duplicate but for the time
>> being fix the problem by bringing back the guard for when MAX_NR_CPUS
>> is already defined.
>>
>> Fixes: e8399d34d568 ("libperf cpumap: Hide/reduce scope of MAX_NR_CPUS")
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> Hello,
>
> I believe this change might be unnecessary. The only use of
> MAX_NR_CPUS is in a warning message within perf_cpu_map__new, which
> takes a string and produces a perf_cpu_map. Other similar functions
> like cpu_map__new_sysconf don't check MAX_NR_CPUS. Therefore,
> specifying a -DMAX_NR_CPUS value on the build command line has little
> effect—it only impacts a warning message for certain kinds of
> perf_cpu_map creation. It's also unclear what the intended outcome is
> on the build command line.
>
> Given that specifying the value doesn't seem to have a clear purpose,
> allowing the build to break might be the best option. This would alert
> the person building perf that they are doing something that doesn't
> make sense.
>
Ok so I looked at it once more and indeed it looks like it has changed
since 2017. See commit 21b8732eb447 ("perf tools: Allow overriding
MAX_NR_CPUS at compile time") to understand why it was required at that
time.
Now I don't have much size difference anymore between a build with
MAX_NR_CPUS=1 and the default MAX_NR_CPUS=4096:
$ size perf perf-1cpu
text data bss dec hex filename
3415908 104164 17148 3537220 35f944 perf
3415904 104164 16124 3536192 35f540 perf-1cpu
Apparently that was changed by commit 6a1e2c5c2673 ("perf stat: Remove a
set of shadow stats static variables")
So I agree with you, it is apparently not worth reducing MAX_NR_CPUS
anymore, I'll give it a try.
Thanks
Christophe
next prev parent reply other threads:[~2025-01-07 8:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 19:38 [PATCH] libperf: Add back guard on MAX_NR_CPUS Christophe Leroy
2025-01-06 19:38 ` [PATCH] perf: Fix display of kernel symbols Christophe Leroy
2025-01-06 20:24 ` Ian Rogers
2025-01-06 20:05 ` [PATCH] libperf: Add back guard on MAX_NR_CPUS Ian Rogers
2025-01-07 8:31 ` Christophe Leroy [this message]
2025-01-07 16:46 ` Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fa5dfd6d-3b8d-4086-9604-e5abddd324c9@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).