Skip to contentSkip to conversation

Add --buildids-blacklist option to perf archive command

PATCH Superseded Tianyou Li 2 participants 3 messages Jun 9, 2025 – Jun 25, 2025 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tianyou Li

author
#0 lore raw

PATCH 1/1 Add --buildids-blacklist option to perf archive command

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

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

Then remove the lines from the buildids_blacklist.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..e5ff840ac6b4 100755
@@ -16,6 +16,13 @@ while [ $# -gt 0 ] ; do
 	elif [ $1 == "--unpack" ]; then
 		UNPACK=1
 		shift
+	elif [ $1 == "--buildids-blacklist" ]; then
+		BUILDIDS_BLACKLIST="$2"
+		if [ ! -e "$BUILDIDS_BLACKLIST" ]; then
+			echo "Provided buildids blacklist file $BUILDIDS_BLACKLIST 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
+#
+# BUILDIDS_BLACKLIST 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 blacklist
+# file, you can use the following command:
+# 	perf buildid-list -i perf.data --with-hits | grep -v "^ " > buildids_blacklist.txt
+# You can edit the file to remove the lines that you want to keep in the archive, then:
+# 	perf archive --buildids-blacklist buildids_blacklist.txt
+#
+if [ ! -s $BUILDIDS_BLACKLIST ]; then
+	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
+else
+	perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " | grep -Fv -f $BUILDIDS_BLACKLIST > $BUILDIDS
+	if [ ! -s $BUILDIDS ] ; then
+		echo "perf archive: no build-ids found after applying blacklist"
+		rm $BUILDIDS || true
+		exit 1
+	fi
 fi
 
 MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
Signature · 1 line
2.47.1
maintainer
#1 lore raw

Hello,

Quoted 7 lines · Tianyou Li

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

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

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

Instead of blacklist, how about saying it like "--exclude-buildids"?

Quoted 32 lines
---
 tools/perf/perf-archive.sh | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)
tools/perf/perf-archive.sh +7 -3
index 6ed7e52ab881..e5ff840ac6b4 100755
@@ -16,6 +16,13 @@ while [ $# -gt 0 ] ; do
 	elif [ $1 == "--unpack" ]; then
 		UNPACK=1
 		shift
+	elif [ $1 == "--buildids-blacklist" ]; then
+		BUILDIDS_BLACKLIST="$2"
+		if [ ! -e "$BUILDIDS_BLACKLIST" ]; then
+			echo "Provided buildids blacklist file $BUILDIDS_BLACKLIST 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"

tools/perf/perf-archive.sh fi · line 103

Quoted 10 lines
tools/perf/perf-archive.sh +8 -2
-	rm $BUILDIDS || true
-	exit 1
+#
+# BUILDIDS_BLACKLIST 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 blacklist
+# file, you can use the following command:
+# 	perf buildid-list -i perf.data --with-hits | grep -v "^ " > buildids_blacklist.txt
+# You can edit the file to remove the lines that you want to keep in the archive, then:
+# 	perf archive --buildids-blacklist buildids_blacklist.txt

Then you'll need to update the comment here.

Thanks,
Namhyung

Quoted 21 lines
tools/perf/perf-archive.sh +15 -0
+#
+if [ ! -s $BUILDIDS_BLACKLIST ]; then
+	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
+else
+	perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " | grep -Fv -f $BUILDIDS_BLACKLIST > $BUILDIDS
+	if [ ! -s $BUILDIDS ] ; then
+		echo "perf archive: no build-ids found after applying blacklist"
+		rm $BUILDIDS || true
+		exit 1
+	fi
 fi
 
 MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
Signature · 1 line
2.47.1
#2 lore raw

Hi Namhyung,

Thanks for your comments, that make sense. I have sent a V2 patch named "[PATCH V2] tools/perf: Add --exclude-buildids option to perf archive command" for your review.

Regards,
Tianyou

-----Original Message-----
From: Namhyung Kim <[email protected]>
Sent: Wednesday, June 25, 2025 2:50 AM
To: Li, Tianyou <[email protected]>
Cc: Peter Zijlstra <[email protected]>; Ingo Molnar <[email protected]>; Arnaldo Carvalho de Melo <[email protected]>; 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] Add --buildids-blacklist option to perf archive command

Hello,

Quoted 8 lines · Tianyou Li

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

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

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

Instead of blacklist, how about saying it like "--exclude-buildids"?

Quoted 32 lines
---
 tools/perf/perf-archive.sh | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)
tools/perf/perf-archive.sh +7 -1
index 6ed7e52ab881..e5ff840ac6b4 100755
@@ -16,6 +16,13 @@ while [ $# -gt 0 ] ; do
 	elif [ $1 == "--unpack" ]; then
 		UNPACK=1
 		shift
+	elif [ $1 == "--buildids-blacklist" ]; then
+		BUILDIDS_BLACKLIST="$2"
+		if [ ! -e "$BUILDIDS_BLACKLIST" ]; then
+			echo "Provided buildids blacklist file $BUILDIDS_BLACKLIST 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

tools/perf/perf-archive.sh +0 -1
-	echo "perf archive: no build-ids found"

tools/perf/perf-archive.sh fi · line 103

Quoted 10 lines
tools/perf/perf-archive.sh +8 -2
-	rm $BUILDIDS || true
-	exit 1
+#
+# BUILDIDS_BLACKLIST 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 blacklist # file, you can use the following command:
+# 	perf buildid-list -i perf.data --with-hits | grep -v "^ " > buildids_blacklist.txt
+# You can edit the file to remove the lines that you want to keep in the archive, then:
+# 	perf archive --buildids-blacklist buildids_blacklist.txt

Then you'll need to update the comment here.

Thanks,
Namhyung

Quoted 21 lines
tools/perf/perf-archive.sh +15 -1
+#
+if [ ! -s $BUILDIDS_BLACKLIST ]; then
+	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
+else
+	perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " | grep -Fv -f $BUILDIDS_BLACKLIST > $BUILDIDS
+	if [ ! -s $BUILDIDS ] ; then
+		echo "perf archive: no build-ids found after applying blacklist"
+		rm $BUILDIDS || true
+		exit 1
+	fi
 fi
 
 MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
--

2.47.1