* [PATCH] perf build: Improve fix for "argument list too long" error
@ 2026-09-28 8:55 Benoît Monin
2026-09-28 8:59 ` sashiko-bot
2026-09-28 9:15 ` James Clark
0 siblings, 2 replies; 5+ messages in thread
From: Benoît Monin @ 2026-09-28 8:55 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, James Clark, Markus Mayer
Cc: Gregory CLEMENT, Théo Lebrun, Tawfik Bayouk,
Vladimir Kondratiev, Thomas Petazzoni, Arnaldo Carvalho de Melo,
linux-perf-users, linux-kernel, Benoît Monin
The orphaned pmu-events JSON files are passed to the shell via
`echo "$^"`, which puts the whole list into a single argument. With
a long enough output directory path and enough files, exec'ing
/bin/sh fails with:
make[5]: /bin/sh: Argument list too long
make[5]: *** [pmu-events/Build:228: prune_orphans] Error 127
This only happens with out-of-tree builds, when setting O= to a
relatively long path.
To reproduce, build once with JEVENTS_ARCH=all, then rebuild with
a smaller JEVENTS_ARCH without cleaning first, so the leftover files
become orphans. Using nds32 (which leaves ~1100 orphans), an output
path of only ~70 characters is already enough to trigger it:
OUT=/any/long/path (at least 70 characters)
make -C tools/perf JEVENTS_ARCH=all O=$OUT -j$(nproc)
make -C tools/perf JEVENTS_ARCH=nds32 O=$OUT -j$(nproc)
Express the orphan file list as paths relative to $(OUT_DIR) by
stripping the common prefix and restoring it with printf, the same
approach used in scripts/Makefile.clean, so the shell arguments stay
short.
Fixes: b6712d91f8f5 ("perf build: Prevent "argument list too long" error")
Suggested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
Tested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
---
tools/perf/pmu-events/Build | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
index 372773b998e4..4c7b082cb2bb 100644
--- a/tools/perf/pmu-events/Build
+++ b/tools/perf/pmu-events/Build
@@ -223,9 +223,11 @@ ifneq ($(strip $(ORPHAN_FILES)),)
# of a build step.
quiet_cmd_rm = RM ...$(words $^) orphan file(s)...
-# The list of files can be long. Use xargs to prevent issues.
+# The list of files can be long. Remove the $(OUT_DIR)/ prefix, and
+# restore it with printf, to prevent "Argument list too long"
+# (see scripts/Makefile.clean).
prune_orphans: $(ORPHAN_FILES)
- $(Q)$(call echo-cmd,rm)echo "$^" | xargs rm -f
+ $(Q)$(call echo-cmd,rm)printf '$(OUT_DIR)/%s ' $(patsubst $(OUT_DIR)/%,%,$(ORPHAN_FILES)) | xargs rm -f
JEVENTS_DEPS += prune_orphans
endif
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260925-perf-orphan-args-5e60becd1916
Best regards,
--
Benoît Monin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] perf build: Improve fix for "argument list too long" error
2026-09-28 8:55 [PATCH] perf build: Improve fix for "argument list too long" error Benoît Monin
@ 2026-09-28 8:59 ` sashiko-bot
2026-09-28 9:15 ` James Clark
1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-09-28 8:59 UTC (permalink / raw)
To: Benoît Monin; +Cc: linux-perf-users
> The orphaned pmu-events JSON files are passed to the shell via
> `echo "$^"`, which puts the whole list into a single argument. With
> a long enough output directory path and enough files, exec'ing
> /bin/sh fails with:
>
> make[5]: /bin/sh: Argument list too long
> make[5]: *** [pmu-events/Build:228: prune_orphans] Error 127
>
> This only happens with out-of-tree builds, when setting O= to a
> relatively long path.
>
> To reproduce, build once with JEVENTS_ARCH=all, then rebuild with
> a smaller JEVENTS_ARCH without cleaning first, so the leftover files
> become orphans. Using nds32 (which leaves ~1100 orphans), an output
> path of only ~70 characters is already enough to trigger it:
>
> OUT=/any/long/path (at least 70 characters)
> make -C tools/perf JEVENTS_ARCH=all O=$OUT -j$(nproc)
> make -C tools/perf JEVENTS_ARCH=nds32 O=$OUT -j$(nproc)
>
> Express the orphan file list as paths relative to $(OUT_DIR) by
> stripping the common prefix and restoring it with printf, the same
> approach used in scripts/Makefile.clean, so the shell arguments stay
> short.
>
> Fixes: b6712d91f8f5 ("perf build: Prevent "argument list too long" error")
> Suggested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
> Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260928-perf-orphan-args-v1-1-8cacf784621e@bootlin.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] perf build: Improve fix for "argument list too long" error
2026-09-28 8:55 [PATCH] perf build: Improve fix for "argument list too long" error Benoît Monin
2026-09-28 8:59 ` sashiko-bot
@ 2026-09-28 9:15 ` James Clark
2026-09-28 15:10 ` Ian Rogers
2026-09-28 16:38 ` Arnaldo Carvalho de Melo
1 sibling, 2 replies; 5+ messages in thread
From: James Clark @ 2026-09-28 9:15 UTC (permalink / raw)
To: Benoît Monin
Cc: Gregory CLEMENT, Théo Lebrun, Tawfik Bayouk,
Vladimir Kondratiev, Thomas Petazzoni, Arnaldo Carvalho de Melo,
linux-perf-users, linux-kernel, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
Markus Mayer
On 28/09/2026 09:55, Benoît Monin wrote:
> The orphaned pmu-events JSON files are passed to the shell via
> `echo "$^"`, which puts the whole list into a single argument. With
> a long enough output directory path and enough files, exec'ing
> /bin/sh fails with:
>
> make[5]: /bin/sh: Argument list too long
> make[5]: *** [pmu-events/Build:228: prune_orphans] Error 127
>
> This only happens with out-of-tree builds, when setting O= to a
> relatively long path.
>
> To reproduce, build once with JEVENTS_ARCH=all, then rebuild with
> a smaller JEVENTS_ARCH without cleaning first, so the leftover files
> become orphans. Using nds32 (which leaves ~1100 orphans), an output
> path of only ~70 characters is already enough to trigger it:
>
> OUT=/any/long/path (at least 70 characters)
> make -C tools/perf JEVENTS_ARCH=all O=$OUT -j$(nproc)
> make -C tools/perf JEVENTS_ARCH=nds32 O=$OUT -j$(nproc)
>
> Express the orphan file list as paths relative to $(OUT_DIR) by
> stripping the common prefix and restoring it with printf, the same
> approach used in scripts/Makefile.clean, so the shell arguments stay
> short.
>
> Fixes: b6712d91f8f5 ("perf build: Prevent "argument list too long" error")
> Suggested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
> Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
> Tested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Reviewed-by: James Clark <james.clark@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] perf build: Improve fix for "argument list too long" error
2026-09-28 9:15 ` James Clark
@ 2026-09-28 15:10 ` Ian Rogers
2026-09-28 16:38 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 5+ messages in thread
From: Ian Rogers @ 2026-09-28 15:10 UTC (permalink / raw)
To: James Clark
Cc: Benoît Monin, Gregory CLEMENT, Théo Lebrun,
Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel,
Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Adrian Hunter, Markus Mayer
On Mon, Sep 28, 2026 at 2:15 AM James Clark <james.clark@linaro.org> wrote:
>
>
>
> On 28/09/2026 09:55, Benoît Monin wrote:
> > The orphaned pmu-events JSON files are passed to the shell via
> > `echo "$^"`, which puts the whole list into a single argument. With
> > a long enough output directory path and enough files, exec'ing
> > /bin/sh fails with:
> >
> > make[5]: /bin/sh: Argument list too long
> > make[5]: *** [pmu-events/Build:228: prune_orphans] Error 127
> >
> > This only happens with out-of-tree builds, when setting O= to a
> > relatively long path.
> >
> > To reproduce, build once with JEVENTS_ARCH=all, then rebuild with
> > a smaller JEVENTS_ARCH without cleaning first, so the leftover files
> > become orphans. Using nds32 (which leaves ~1100 orphans), an output
> > path of only ~70 characters is already enough to trigger it:
> >
> > OUT=/any/long/path (at least 70 characters)
> > make -C tools/perf JEVENTS_ARCH=all O=$OUT -j$(nproc)
> > make -C tools/perf JEVENTS_ARCH=nds32 O=$OUT -j$(nproc)
> >
> > Express the orphan file list as paths relative to $(OUT_DIR) by
> > stripping the common prefix and restoring it with printf, the same
> > approach used in scripts/Makefile.clean, so the shell arguments stay
> > short.
> >
> > Fixes: b6712d91f8f5 ("perf build: Prevent "argument list too long" error")
> > Suggested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
> > Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
> > Tested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
>
> Reviewed-by: James Clark <james.clark@linaro.org>
Acked-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] perf build: Improve fix for "argument list too long" error
2026-09-28 9:15 ` James Clark
2026-09-28 15:10 ` Ian Rogers
@ 2026-09-28 16:38 ` Arnaldo Carvalho de Melo
1 sibling, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-09-28 16:38 UTC (permalink / raw)
To: James Clark
Cc: Benoît Monin, Gregory CLEMENT, Théo Lebrun,
Tawfik Bayouk, Vladimir Kondratiev, Thomas Petazzoni,
Arnaldo Carvalho de Melo, linux-perf-users, linux-kernel,
Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
Markus Mayer
On Mon, Sep 28, 2026 at 10:15:47AM +0100, James Clark wrote:
> On 28/09/2026 09:55, Benoît Monin wrote:
> > Express the orphan file list as paths relative to $(OUT_DIR) by
> > stripping the common prefix and restoring it with printf, the same
> > approach used in scripts/Makefile.clean, so the shell arguments stay
> > short.
> > Fixes: b6712d91f8f5 ("perf build: Prevent "argument list too long" error")
> > Suggested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
> > Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
> > Tested-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
>
> Reviewed-by: James Clark <james.clark@linaro.org>
Thanks, applied to perf-tools-next, for v7.4.
- Arnaldo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-28 16:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-28 8:55 [PATCH] perf build: Improve fix for "argument list too long" error Benoît Monin
2026-09-28 8:59 ` sashiko-bot
2026-09-28 9:15 ` James Clark
2026-09-28 15:10 ` Ian Rogers
2026-09-28 16:38 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.