Skip to contentSkip to conversation

perf build: Update kernel headers

PATCH Superseded Namhyung Kim 2 participants 11 messages May 7 – May 8

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

v2 cover perf build: Update kernel headers

Hello,

This is to update copy of kernel headers for v7.1. I've updated ones in the tools/perf/trace/beauty/ and left others which seem not to affect perf syscall beautifiers. This is suggested by Linus to avoid unnecessary builds of objtool and the kernel.

There are AMD IBS changes that are directly related to perf, but I think Ravi is working on it with other Zen6 changes. So I didn't include it here.

Due to the header file changes, some beautifier scripts for perf trace are updated too. This was detected by Sashiko.

Also I removed the header difference output in the default perf build and added a new make target to check it explicitly.

Thanks,
Namhyung

Namhyung Kim (7):
perf trace: Sync linux/socket.h with the kernel source perf trace: Sync uapi/linux/fs.h with the kernel source perf trace: Sync uapi/linux/mount.h with the kernel source perf trace: Sync uapi/linux/sched.h with the kernel source perf build: Add make check-headers target
perf trace: Add beautifier script for fsmount flags perf trace: Update beautifier script for clone flags

 tools/perf/Makefile                           |  5 ++++-
 tools/perf/Makefile.perf                      |  8 ++++++-
 tools/perf/builtin-trace.c                    |  7 +-----
 tools/perf/trace/beauty/beauty.h              |  3 +++
 tools/perf/trace/beauty/clone.sh              |  4 ++--
 tools/perf/trace/beauty/fsmount.c             | 18 ++++++++++++++-
 tools/perf/trace/beauty/fsmount.sh            | 11 +++-------
 tools/perf/trace/beauty/fsmount_attr.sh       | 22 +++++++++++++++++++
 .../perf/trace/beauty/include/linux/socket.h  |  2 +-
 .../perf/trace/beauty/include/uapi/linux/fs.h | 12 ++++++++++
 .../trace/beauty/include/uapi/linux/mount.h   |  1 +
 .../trace/beauty/include/uapi/linux/sched.h   | 17 ++++++++++++--
 12 files changed, 88 insertions(+), 22 deletions(-)
 create mode 100644 tools/perf/trace/beauty/fsmount_attr.sh
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH v2 1/7 perf trace: Sync linux/socket.h with the kernel source

To pick up changes from:

c66e0f453d1afa82 ("net: use ktime_t in struct scm_timestamping_internal")

This would be used to beautify networking syscall arguments and not to affect builds of other tools (e.g. objtool).

Please see tools/include/uapi/README.

---
 tools/perf/trace/beauty/include/linux/socket.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/trace/beauty/include/linux/socket.h +1 -1
index ec715ad4bf25f5f7..ec4a0a0257939a53 100644
@@ -415,7 +415,7 @@ struct __kernel_timespec;
 struct old_timespec32;
 
 struct scm_timestamping_internal {
-	struct timespec64 ts[3];
+	ktime_t ts[3];
 };
 
 extern void put_cmsg_scm_timestamping64(struct msghdr *msg, struct scm_timestamping_internal *tss);
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH v2 2/7 perf trace: Sync uapi/linux/fs.h with the kernel source

In reply to Namhyung Kim

To pick up changes from:

1f662195dbc07a66 ("fs: add generic FS_IOC_SHUTDOWN definitions")

This would be used to beautify filesystem syscall arguments and not to affect builds of other tools (e.g. objtool).

Please see tools/include/uapi/README.

---
 tools/perf/trace/beauty/include/uapi/linux/fs.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/perf/trace/beauty/include/uapi/linux/fs.h +12 -0
index 70b2b661f42cb6e5..13f71202845e8f9e 100644
@@ -657,4 +657,16 @@ struct procmap_query {
 	__u64 build_id_addr;		/* in */
 };
 
+/*
+ * Shutdown the filesystem.
+ */
+#define FS_IOC_SHUTDOWN _IOR('X', 125, __u32)
+
+/*
+ * Flags for FS_IOC_SHUTDOWN
+ */
+#define FS_SHUTDOWN_FLAGS_DEFAULT	0x0
+#define FS_SHUTDOWN_FLAGS_LOGFLUSH	0x1	/* flush log but not data*/
+#define FS_SHUTDOWN_FLAGS_NOLOGFLUSH	0x2	/* don't flush log nor data */
+
 #endif /* _UAPI_LINUX_FS_H */
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH v2 3/7 perf trace: Sync uapi/linux/mount.h with the kernel source

In reply to Namhyung Kim

To pick up changes from:

5e8969bd19271241 ("mount: add FSMOUNT_NAMESPACE")

This would be used to beautify mount syscall arguments and not to affect builds of other tools (e.g. objtool).

Please see tools/include/uapi/README.

---
 tools/perf/trace/beauty/include/uapi/linux/mount.h | 1 +
 1 file changed, 1 insertion(+)
tools/perf/trace/beauty/include/uapi/linux/mount.h +1 -0
index d9d86598d100cb32..2204708dbf7a583a 100644
@@ -110,6 +110,7 @@ enum fsconfig_command {
  * fsmount() flags.
  */
 #define FSMOUNT_CLOEXEC		0x00000001
+#define FSMOUNT_NAMESPACE	0x00000002	/* Create the mount in a new mount namespace */
 
 /*
  * Mount attributes.
Signature · 1 line
2.53.0
author maintainer
#4 lore raw

PATCH v2 4/7 perf trace: Sync uapi/linux/sched.h with the kernel source

In reply to Namhyung Kim

To pick up changes from:

9d4e752a24f740b3 ("namespace: allow creating empty mount namespaces") c8134b5f13ae959d ("pidfd: add CLONE_PIDFD_AUTOKILL") 24baca56fafc33d4 ("clone: add CLONE_NNP")
12ae2c81b21cfaa1 ("clone: add CLONE_AUTOREAP") 2e7af192697ef2a7 ("sched/deadline: Add reporting of runtime left & ...")

This would be used to beautify scheduler syscall arguments and not to affect builds of other tools (e.g. objtool).

Please see tools/include/uapi/README.

---
 .../trace/beauty/include/uapi/linux/sched.h     | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
tools/perf/trace/beauty/include/uapi/linux/sched.h +15 -2
index 359a14cc76a4038a..33a4624285cd4179 100644
@@ -34,8 +34,12 @@
 #define CLONE_IO		0x80000000	/* Clone io context */
 
 /* Flags for the clone3() syscall. */
-#define CLONE_CLEAR_SIGHAND 0x100000000ULL /* Clear any signal handler and reset to SIG_DFL. */
-#define CLONE_INTO_CGROUP 0x200000000ULL /* Clone into a specific cgroup given the right permissions. */
+#define CLONE_CLEAR_SIGHAND	(1ULL << 32) /* Clear any signal handler and reset to SIG_DFL. */
+#define CLONE_INTO_CGROUP	(1ULL << 33) /* Clone into a specific cgroup given the right permissions. */
+#define CLONE_AUTOREAP		(1ULL << 34) /* Auto-reap child on exit. */
+#define CLONE_NNP		(1ULL << 35) /* Set no_new_privs on child. */
+#define CLONE_PIDFD_AUTOKILL	(1ULL << 36) /* Kill child when clone pidfd closes. */
+#define CLONE_EMPTY_MNTNS	(1ULL << 37) /* Create an empty mount namespace. */
 
 /*
  * cloning flags intersect with CSIGNAL so can be used with unshare and clone3
@@ -43,6 +47,12 @@
  */
 #define CLONE_NEWTIME	0x00000080	/* New time namespace */
 
+/*
+ * unshare flags share the bit space with clone flags but only apply to the
+ * unshare syscall:
+ */
+#define UNSHARE_EMPTY_MNTNS 0x00100000 /* Unshare an empty mount namespace. */
+
 #ifndef __ASSEMBLY__
 /**
  * struct clone_args - arguments for the clone3 syscall
@@ -146,4 +156,7 @@ struct clone_args {
 			 SCHED_FLAG_KEEP_ALL		| \
 			 SCHED_FLAG_UTIL_CLAMP)
 
+/* Only for sched_getattr() own flag param, if task is SCHED_DEADLINE */
+#define SCHED_GETATTR_FLAG_DL_DYNAMIC	0x01
+
 #endif /* _UAPI_LINUX_SCHED_H */
Signature · 1 line
2.53.0
#5 lore raw

Re: [PATCH v2 4/7] perf trace: Sync uapi/linux/sched.h with the kernel source

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Build Script Regex Regression --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Build Script Regex Regression
--

commit 95b9a74eb48111bfe1440ab1eb342b9d9108af43
Author: Namhyung Kim <[email protected]>

perf trace: Sync uapi/linux/sched.h with the kernel source

Syncs the tools copy of uapi/linux/sched.h with the kernel source to pick up changes related to clone3 and unshare flags.

Quoted 6 lines
tools/perf/trace/beauty/include/uapi/linux/sched.h +0 -0
index 359a14cc76a40..33a4624285cd4 100644
@@ -34,8 +34,12 @@
 #define CLONE_IO		0x80000000	/* Clone io context */

tools/perf/trace/beauty/include/uapi/linux/sched.h line 42

Quoted 10 lines
tools/perf/trace/beauty/include/uapi/linux/sched.h +6 -2
 
 /* Flags for the clone3() syscall. */
-#define CLONE_CLEAR_SIGHAND 0x100000000ULL /* Clear any signal handler and reset to SIG_DFL. */
-#define CLONE_INTO_CGROUP 0x200000000ULL /* Clone into a specific cgroup given the right permissions. */
+#define CLONE_CLEAR_SIGHAND	(1ULL << 32) /* Clear any signal handler and reset to SIG_DFL. */
+#define CLONE_INTO_CGROUP	(1ULL << 33) /* Clone into a specific cgroup given the right permissions. */
+#define CLONE_AUTOREAP		(1ULL << 34) /* Auto-reap child on exit. */
+#define CLONE_NNP		(1ULL << 35) /* Set no_new_privs on child. */
+#define CLONE_PIDFD_AUTOKILL	(1ULL << 36) /* Kill child when clone pidfd closes. */
+#define CLONE_EMPTY_MNTNS	(1ULL << 37) /* Create an empty mount namespace. */

Does changing these flag definitions from hexadecimal literals to bit-shifts break the beautifier script?

Looking at tools/perf/trace/beauty/clone.sh, the script relies on matching hexadecimal literals like (0x[[:xdigit:]]+) to extract these flags. Without updating the regex in this patch, the script will silently fail to extract these modified and new flags, causing them to be excluded from clone_flags_array.c.

While a subsequent patch in the series attempts to fix this by replacing the regex with one that exclusively matches 1ULL << X, this drops all standard 32-bit clone flags (like CLONE_VM and CLONE_FS) which remain defined as hexadecimal literals in the header.

Could the script be updated to support both formats?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
author maintainer
#6 lore raw

PATCH v2 5/7 perf build: Add make check-headers target

In reply to Namhyung Kim

Don't print header differences during the perf build as it's noisy. Mostly people won't care and find it annoying.

As it's to improve perf trace beautifier to catch up new changes mostly in UAPIs, we can make it a separate build target and call it occasionally. Make it and build-test related targets phony.

---
 tools/perf/Makefile      | 5 ++++-
 tools/perf/Makefile.perf | 1 -
 2 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/Makefile +4 -1
index 816d5d84816b3d53..5b713837eede7d52 100644
@@ -111,6 +111,9 @@ endif # MAKECMDGOALS
 build-test-tarball:
 	@$(MAKE) -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory out
 
+check-headers:
+	@./check-headers.sh
+
 #
 # All other targets get passed through:
 #
@@ -118,4 +121,4 @@ endif # MAKECMDGOALS
 	$(print_msg)
 	$(make)
 
-.PHONY: tags TAGS FORCE Makefile
+.PHONY: tags TAGS FORCE Makefile build-test build-test-tarball check-headers
tools/perf/Makefile.perf +0 -1
index cee19c923c0607d2..585637fc934fe6ec 100644
@@ -285,7 +285,6 @@ goals := $(filter-out all sub-make, $(MAKECMDGOALS))
 $(goals) all: sub-make
 
 sub-make: fixdep
-	@./check-headers.sh
 	$(Q)$(MAKE) FIXDEP_BUILT=1 -f Makefile.perf $(goals)
 
 else # force_fixdep
Signature · 1 line
2.53.0
author maintainer
#7 lore raw

PATCH v2 6/7 perf trace: Add beautifier script for fsmount flags

In reply to Namhyung Kim

And rename the existing one to fsmount_attr.{sh,c} to be more precise. Now the fsmount_flags[] is generated from the mount.h like below. The ilog2() + 1 is an existing pattern to handle bit flags.

  $ cat tools/perf/trace/beauty/generated/fsmount_arrays.c
  static const char *fsmount_flags[] = {
  	[ilog2(0x00000001) + 1] = "CLOEXEC",
  	[ilog2(0x00000002) + 1] = "NAMESPACE",
  };

It was found by Sashiko during the review.

---
 tools/perf/Makefile.perf                |  7 +++++++
 tools/perf/builtin-trace.c              |  7 +------
 tools/perf/trace/beauty/beauty.h        |  3 +++
 tools/perf/trace/beauty/fsmount.c       | 18 +++++++++++++++++-
 tools/perf/trace/beauty/fsmount.sh      | 11 +++--------
 tools/perf/trace/beauty/fsmount_attr.sh | 22 ++++++++++++++++++++++
 6 files changed, 53 insertions(+), 15 deletions(-)
 create mode 100644 tools/perf/trace/beauty/fsmount_attr.sh
tools/perf/Makefile.perf +7 -0
index 585637fc934fe6ec..f733103b5003bf79 100644
@@ -564,6 +564,12 @@ fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh
 $(fsmount_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsmount_tbls)
 	$(Q)$(SHELL) '$(fsmount_tbls)' $(beauty_uapi_linux_dir) > $@
 
+fsmount_attr_arrays := $(beauty_outdir)/fsmount_attr_arrays.c
+fsmount_attr_tbls := $(srctree)/tools/perf/trace/beauty/fsmount_attr.sh
+
+$(fsmount_attr_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsmount_attr_tbls)
+	$(Q)$(SHELL) '$(fsmount_attr_tbls)' $(beauty_uapi_linux_dir) > $@
+
 fspick_arrays := $(beauty_outdir)/fspick_arrays.c
 fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh
 
@@ -854,6 +860,7 @@ prepare: $(OUTPUT)PERF-VERSION-FILE archheaders \
 	$(fadvise_advice_array) \
 	$(fsconfig_arrays) \
 	$(fsmount_arrays) \
+	$(fsmount_attr_arrays) \
 	$(fspick_arrays) \
 	$(pkey_alloc_access_rights_array) \
 	$(sndrv_pcm_ioctl_array) \
tools/perf/builtin-trace.c +1 -6
index e58c49d047a294db..4096b855e7946d96 100644
@@ -771,11 +771,6 @@ static const char *bpf_cmd[] = {
 };
 static DEFINE_STRARRAY(bpf_cmd, "BPF_");
 
-static const char *fsmount_flags[] = {
-	[1] = "CLOEXEC",
-};
-static DEFINE_STRARRAY(fsmount_flags, "FSMOUNT_");
-
 #include "trace/beauty/generated/fsconfig_arrays.c"
 
 static DEFINE_STRARRAY(fsconfig_cmds, "FSCONFIG_");
@@ -1202,7 +1197,7 @@ static const struct syscall_fmt syscall_fmts[] = {
 	{ .name     = "fsconfig",
 	  .arg = { [1] = STRARRAY(cmd, fsconfig_cmds), }, },
 	{ .name     = "fsmount",
-	  .arg = { [1] = STRARRAY_FLAGS(flags, fsmount_flags),
+	  .arg = { [1] = { .scnprintf = SCA_FSMOUNT_FLAGS, /* fsmount_flags */ },
 		   [2] = { .scnprintf = SCA_FSMOUNT_ATTR_FLAGS, /* attr_flags */ }, }, },
 	{ .name     = "fspick",
 	  .arg = { [0] = { .scnprintf = SCA_FDAT,	  /* dfd */ },
tools/perf/trace/beauty/beauty.h +3 -0
index 0a07ad158f87c73c..a90c35fa5c123f2b 100644
@@ -179,6 +179,9 @@ size_t syscall_arg__scnprintf_fcntl_arg(char *bf, size_t size, struct syscall_ar
 size_t syscall_arg__scnprintf_flock(char *bf, size_t size, struct syscall_arg *arg);
 #define SCA_FLOCK syscall_arg__scnprintf_flock
 
+size_t syscall_arg__scnprintf_fsmount_flags(char *bf, size_t size, struct syscall_arg *arg);
+#define SCA_FSMOUNT_FLAGS syscall_arg__scnprintf_fsmount_flags
+
 size_t syscall_arg__scnprintf_fsmount_attr_flags(char *bf, size_t size, struct syscall_arg *arg);
 #define SCA_FSMOUNT_ATTR_FLAGS syscall_arg__scnprintf_fsmount_attr_flags
 
tools/perf/trace/beauty/fsmount.c +17 -1
index 28c2c16fc1a80dfd..0f13ef6599b9d0ee 100644
@@ -18,7 +18,7 @@
 
 static size_t fsmount__scnprintf_attr_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
 {
-#include "trace/beauty/generated/fsmount_arrays.c"
+#include "trace/beauty/generated/fsmount_attr_arrays.c"
        static DEFINE_STRARRAY(fsmount_attr_flags, "MOUNT_ATTR_");
        size_t printed = 0;
 
@@ -39,3 +39,19 @@ size_t syscall_arg__scnprintf_fsmount_attr_flags(char *bf, size_t size, struct s
 
 	return fsmount__scnprintf_attr_flags(flags, bf, size, arg->show_string_prefix);
 }
+
+
+static size_t fsmount__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
+{
+#include "trace/beauty/generated/fsmount_arrays.c"
+	static DEFINE_STRARRAY(fsmount_flags, "FSMOUNT_");
+
+	return strarray__scnprintf_flags(&strarray__fsmount_flags, bf, size, show_prefix, flags);
+}
+
+size_t syscall_arg__scnprintf_fsmount_flags(char *bf, size_t size, struct syscall_arg *arg)
+{
+	unsigned long flags = arg->val;
+
+	return fsmount__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
+}
tools/perf/trace/beauty/fsmount.sh +3 -8
index 6b67a54cdeee64b3..6d1e80bc15e4416b 100755
@@ -9,14 +9,9 @@ fi
 
 linux_mount=${beauty_uapi_linux_dir}/mount.h
 
-# Remove MOUNT_ATTR_RELATIME as it is zeros, handle it a special way in the beautifier
-# Only handle MOUNT_ATTR_ followed by a capital letter/num as __ is special case
-# for things like MOUNT_ATTR__ATIME that is a mask for the possible ATIME handling
-# bits. Special case it as well in the beautifier
-
-printf "static const char *fsmount_attr_flags[] = {\n"
-regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MOUNT_ATTR_([[:alnum:]][[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
-grep -E $regex ${linux_mount} | grep -v MOUNT_ATTR_RELATIME | \
+printf "static const char *fsmount_flags[] = {\n"
+regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+FSMOUNT_([[:alnum:]][[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
+grep -E $regex ${linux_mount} | \
 	sed -r "s/$regex/\2 \1/g"	| \
 	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n"
 printf "};\n"
tools/perf/trace/beauty/fsmount_attr.sh new file +22 -0
new file mode 100644
index 0000000000000000..6b67a54cdeee64b3
@@ -0,0 +1,22 @@
+#!/bin/sh
+# SPDX-License-Identifier: LGPL-2.1
+
+if [ $# -ne 1 ] ; then
+	beauty_uapi_linux_dir=tools/perf/trace/beauty/include/uapi/linux/
+else
+	beauty_uapi_linux_dir=$1
+fi
+
+linux_mount=${beauty_uapi_linux_dir}/mount.h
+
+# Remove MOUNT_ATTR_RELATIME as it is zeros, handle it a special way in the beautifier
+# Only handle MOUNT_ATTR_ followed by a capital letter/num as __ is special case
+# for things like MOUNT_ATTR__ATIME that is a mask for the possible ATIME handling
+# bits. Special case it as well in the beautifier
+
+printf "static const char *fsmount_attr_flags[] = {\n"
+regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MOUNT_ATTR_([[:alnum:]][[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
+grep -E $regex ${linux_mount} | grep -v MOUNT_ATTR_RELATIME | \
+	sed -r "s/$regex/\2 \1/g"	| \
+	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n"
+printf "};\n"
Signature · 1 line
2.53.0
#8 lore raw

Re: [PATCH v2 6/7] perf trace: Add beautifier script for fsmount flags

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] The replacement of STRARRAY_FLAGS with a custom formatter initialization silently drops the…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] The replacement of STRARRAY_FLAGS with a custom formatter initialization silently drops the .strtoul handler and .show_zero property for the fsmount flags argument.
- [Low] The newly generated fsmount_attr_arrays.c file is not removed during make clean.
- [Low] The commit message falsely claims that the source file fsmount.c was renamed.
--

commit 3df6eed17e58d1e1ddb3e75a7cd7fc70c8f3735f
Author: Namhyung Kim <[email protected]>

perf trace: Add beautifier script for fsmount flags

This commit updates the fsmount beautifier to generate fsmount_flags[] directly from mount.h. It also splits out the attribute flags generation into a separate fsmount_attr.sh script.

Quoted 1 line

And rename the existing one to fsmount_attr.{sh,c} to be more precise.

This isn't a bug, but the commit message says fsmount.c was renamed to fsmount_attr.c, while the patch only modifies fsmount.c without renaming it.

Should the commit message be updated to reflect this?

tools/perf/Makefile.perf fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh · line 571

Quoted 12 lines
tools/perf/Makefile.perf +5 -0
@@ -564,6 +564,12 @@ fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh
 $(fsmount_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsmount_tbls)
 	$(Q)$(SHELL) '$(fsmount_tbls)' $(beauty_uapi_linux_dir) > $@
 
+fsmount_attr_arrays := $(beauty_outdir)/fsmount_attr_arrays.c
+fsmount_attr_tbls := $(srctree)/tools/perf/trace/beauty/fsmount_attr.sh
+
+$(fsmount_attr_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsmount_attr_tbls)
+	$(Q)$(SHELL) '$(fsmount_attr_tbls)' $(beauty_uapi_linux_dir) > $@

Does the clean target in Makefile.perf need to be updated to remove the new fsmount_attr_arrays.c file? Without it, the generated file might be left behind during a make clean operation.

Quoted 3 lines
tools/perf/builtin-trace.c +0 -0

[ ... ]

tools/perf/builtin-trace.c static const struct syscall_fmt syscall_fmts[] = { · line 1201

Quoted 7 lines
tools/perf/builtin-trace.c +1 -1
@@ -1202,7 +1197,7 @@ static const struct syscall_fmt syscall_fmts[] = {
 	{ .name     = "fsconfig",
 	  .arg = { [1] = STRARRAY(cmd, fsconfig_cmds), }, },
 	{ .name     = "fsmount",
-	  .arg = { [1] = STRARRAY_FLAGS(flags, fsmount_flags),
+	  .arg = { [1] = { .scnprintf = SCA_FSMOUNT_FLAGS, /* fsmount_flags */ },
 		   [2] = { .scnprintf = SCA_FSMOUNT_ATTR_FLAGS, /* attr_flags */ }, }, },

Does replacing STRARRAY_FLAGS drop the .strtoul parser and .show_zero properties?

The original STRARRAY_FLAGS macro assigned .strtoul = STUL_STRARRAY_FLAGS and .show_zero = true. By dropping these, does perf trace lose the ability to parse symbolic names for the fsmount flags argument, such as during filter expressions like -e 'fsmount(flags==CLOEXEC)'?

Additionally, without .show_zero = true, will a flags value of 0 be skipped in the output, causing positional ambiguity with the remaining trailing arguments?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
author maintainer
#9 lore raw

PATCH v2 7/7 perf trace: Update beautifier script for clone flags

In reply to Namhyung Kim

According to the change in the sched.h, update the script to generate the flags array like below. Note that '+1' is needed to detect bitmask pattern at index 0.

  $ cat tools/perf/trace/beauty/generated/clone_flags_array.c
  static const char *clone_flags[] = {
  	[32 + 1] = "CLEAR_SIGHAND",
  	[33 + 1] = "INTO_CGROUP",
  	[34 + 1] = "AUTOREAP",
  	[35 + 1] = "NNP",
  	[36 + 1] = "PIDFD_AUTOKILL",
  	[37 + 1] = "EMPTY_MNTNS",
  };

This was found by Sashiko during review.

---
 tools/perf/trace/beauty/clone.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/trace/beauty/clone.sh +2 -2
index 18b6c0d75693721d..f807372519fe2c88 100755
@@ -10,8 +10,8 @@ fi
 linux_sched=${beauty_uapi_linux_dir}/sched.h
 
 printf "static const char *clone_flags[] = {\n"
-regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+CLONE_([^_]+[[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
+regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+CLONE_([^_]+[[:alnum:]_]+)[[:space:]]+\(1ULL[[:space:]]*<<[[:space:]]*([[:digit:]]+)\)[[:space:]]*.*'
 grep -E $regex ${linux_sched} | \
 	sed -r "s/$regex/\2 \1/g"	| \
-	xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n"
+	xargs printf "\t[%s + 1] = \"%s\",\n"
 printf "};\n"
Signature · 1 line
2.53.0
#10 lore raw

Re: [PATCH v2 7/7] perf trace: Update beautifier script for clone flags

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The beautifier script regex update drops all legacy clone flags (0-31), breaking flag decoding for…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The beautifier script regex update drops all legacy clone flags (0-31), breaking flag decoding for standard clone() syscalls.
- [High] Processing clone flags with indices >= 32 in strarray__scnprintf_flags() causes Undefined Behavior on 32-bit platforms, leading to incorrect flag decoding. --

commit 47293f130dab2e91781452bd39a472811835f8a9
Author: Namhyung Kim <[email protected]>

perf trace: Update beautifier script for clone flags

This commit updates the clone_flags beautifier script to parse the new bit shift definitions in sched.h. It changes the regex to match the 1ULL bit shift pattern instead of the previous hexadecimal values.

Quoted 9 lines
  $ cat tools/perf/trace/beauty/generated/clone_flags_array.c
  static const char *clone_flags[] = {
        [32 + 1] = "CLEAR_SIGHAND",
        [33 + 1] = "INTO_CGROUP",
        [34 + 1] = "AUTOREAP",
        [35 + 1] = "NNP",
        [36 + 1] = "PIDFD_AUTOKILL",
        [37 + 1] = "EMPTY_MNTNS",
  };

When the array has entries up to index 38, does this cause an issue on 32-bit builds of perf?

Looking at strarray__scnprintf_flags(), it computes the flag bit using:

    unsigned long bit = 1UL << (i - 1);

On 32-bit platforms, unsigned long is 32 bits. Shifting by 32 or more invokes undefined behavior. On architectures like x86, the shift amount is masked (e.g., modulo 32), so 1UL << 32 evaluates as 1UL << 0.

Could this cause perf trace to erroneously report clone3 flags like CLEAR_SIGHAND whenever unrelated lower bits are set?

Quoted 4 lines
tools/perf/trace/beauty/clone.sh +0 -0
index 18b6c0d756937..f807372519fe2 100755

[ ... ]

tools/perf/trace/beauty/clone.sh fi · line 13

Quoted 3 lines

printf "static const char *clone_flags[] = {\n"

tools/perf/trace/beauty/clone.sh +1 -1
-regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+CLONE_([^_]+[[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*'
+regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+CLONE_([^_]+[[:alnum:]_]+)[[:space:]]+\(1ULL[[:space:]]*<<[[:space:]]*([[:digit:]]+)\)[[:space:]]*.*'

Does this new regex miss the legacy clone flags?

In include/uapi/linux/sched.h, legacy flags like CLONE_VM, CLONE_FS, and CLONE_THREAD are still defined using hexadecimal notation.

Since the updated regex strictly requires the (1ULL << digit) format, it appears all lower 32 flags are excluded from the generated clone_flags_array.c.

Could this prevent perf trace from translating standard clone flags into human-readable strings?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7