Skip to contentSkip to conversation

tools/perf: Add --exclude-buildids option to perf archive command

PATCH Applied Tianyou Li 2 participants 3 messages Jun 25, 2025 – Jun 30, 2025 1 message not in the archive perf events

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): aFrzSpvzzWeHdyJ5 () google ! com

Tianyou Li

author
#1 lore raw

PATCH v2 1/1 tools/perf: Add --exclude-buildids option to perf archive command

When make a perf archive, it may contains the binaries that user did not want to ship with, add --exclude-buildids option to specify a file which contains the buildids need to be excluded. The file can be generated from command:

    perf buildid-list -i perf.data --with-hits | grep -v "^ " > exclude-buildids.txt

Then remove the lines from the exclude-buildids.txt for buildids should be included.

---
 tools/perf/perf-archive.sh | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)
tools/perf/perf-archive.sh +30 -5
index 6ed7e52ab881..7977e9b0a5ea 100755
@@ -16,6 +16,13 @@ while [ $# -gt 0 ] ; do
 	elif [ $1 == "--unpack" ]; then
 		UNPACK=1
 		shift
+	elif [ $1 == "--exclude-buildids" ]; then
+		EXCLUDE_BUILDIDS="$2"
+		if [ ! -e "$EXCLUDE_BUILDIDS" ]; then
+			echo "Provided exclude-buildids file $EXCLUDE_BUILDIDS does not exist"
+			exit 1
+		fi
+		shift 2
 	else
 		PERF_DATA=$1
 		UNPACK_TAR=$1
@@ -86,11 +93,29 @@ fi
 
 BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
 
-perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " > $BUILDIDS
-if [ ! -s $BUILDIDS ] ; then
-	echo "perf archive: no build-ids found"
-	rm $BUILDIDS || true
-	exit 1
+#
+# EXCLUDE_BUILDIDS is an optional file that contains build-ids to be excluded from the
+# archive. It is a list of build-ids, one per line, without any leading or trailing spaces.
+# If the file is empty, all build-ids will be included in the archive. To create a exclude-
+# buildids file, you can use the following command:
+# 	perf buildid-list -i perf.data --with-hits | grep -v "^ " > exclude_buildids.txt
+# You can edit the file to remove the lines that you want to keep in the archive, then:
+# 	perf archive --exclude-buildids exclude_buildids.txt
+#
+if [ -s "$EXCLUDE_BUILDIDS" ]; then
+	perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " | grep -Fv -f $EXCLUDE_BUILDIDS > $BUILDIDS
+	if [ ! -s "$BUILDIDS" ] ; then
+		echo "perf archive: no build-ids found after applying exclude-buildids file"
+		rm $BUILDIDS || true
+		exit 1
+	fi
+else
+	perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " > $BUILDIDS
+	if [ ! -s "$BUILDIDS" ] ; then
+		echo "perf archive: no build-ids found"
+		rm $BUILDIDS || true
+		exit 1
+	fi
 fi
 
 MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
Signature · 1 line
2.47.1
maintainer Applied
#2 lore raw
Quoted 9 lines · Tianyou Li

When make a perf archive, it may contains the binaries that user did not want to ship with, add --exclude-buildids option to specify a file which contains the buildids need to be excluded. The file can be generated from command:

    perf buildid-list -i perf.data --with-hits | grep -v "^ " > exclude-buildids.txt

Then remove the lines from the exclude-buildids.txt for buildids should be included.

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung

author Applied
#3 lore raw

Thanks Namhyung, very appreciated for your review.

Regards,
Tianyou

-----Original Message-----
From: Namhyung Kim <[email protected]>
Sent: Saturday, June 28, 2025 2:53 AM
To: Peter Zijlstra <[email protected]>; Ingo Molnar <[email protected]>; Arnaldo Carvalho de Melo <[email protected]>; Li, Tianyou <[email protected]>
Cc: Mark Rutland <[email protected]>; Alexander Shishkin <[email protected]>; Jiri Olsa <[email protected]>; Ian Rogers <[email protected]>; Hunter, Adrian <[email protected]>; Kan Liang <[email protected]>; Guo, Wangyang <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH V2] tools/perf: Add --exclude-buildids option to perf archive command

Quoted 10 lines · Tianyou Li

When make a perf archive, it may contains the binaries that user did
not want to ship with, add --exclude-buildids option to specify a file which contains the buildids need to be excluded. The file can be generated from command:

    perf buildid-list -i perf.data --with-hits | grep -v "^ " > 

exclude-buildids.txt

Then remove the lines from the exclude-buildids.txt for buildids should be included.

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung