[PATCH] add config3 struct to perf_event_open()

Sven Schnelle svens at linux.ibm.com
Thu Mar 9 12:52:54 UTC 2023


commit 09519ec3b19 ("perf: Add perf_event_attr::config3") in the
linu kernel adds a new config3 field to struct perf_event_attr.
Add this flag to strace, which also fixes compilation because of an
array out-of-bounds warning in tests/perf_event.c.

Signed-off-by: Sven Schnelle <svens at linux.ibm.com>
---
 src/perf.c              |  4 ++++
 src/perf_event_struct.h |  2 ++
 tests/perf_event_open.c | 10 +++++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/perf.c b/src/perf.c
index 76c4fab0833e..78681eceeaf5 100644
--- a/src/perf.c
+++ b/src/perf.c
@@ -434,6 +434,10 @@ print_perf_event_attr(struct tcb *const tcp, const kernel_ulong_t addr)
 	tprint_struct_next();
 	PRINT_FIELD_X(*attr, sig_data);
 
+	STRACE_PERF_CHECK_FIELD(config3);
+	tprint_struct_next();
+	PRINT_FIELD_X(*attr, config3);
+
 print_perf_event_attr_out:
 	if ((attr->size && (attr->size > size)) ||
 	    (!attr->size && (size < PERF_ATTR_SIZE_VER0))) {
diff --git a/src/perf_event_struct.h b/src/perf_event_struct.h
index d9020f6e928b..21113b376309 100644
--- a/src/perf_event_struct.h
+++ b/src/perf_event_struct.h
@@ -94,6 +94,8 @@ struct perf_event_attr {
 	/* End of ver 6 - 120 bytes */
 	uint64_t sig_data;
 	/* End of ver 7 - 128 bytes */
+	uint64_t config3;
+	/* End of ver 8 - 136 bytes */
 };
 
 struct perf_event_query_bpf {
diff --git a/tests/perf_event_open.c b/tests/perf_event_open.c
index 139d16ce511f..6a01c8186ad5 100644
--- a/tests/perf_event_open.c
+++ b/tests/perf_event_open.c
@@ -139,7 +139,7 @@ print_event_attr(struct perf_event_attr *attr_ptr, size_t size,
 	enum {
 		STRACE_PEA_ABBREV_SIZE =
 			offsetof(struct perf_event_attr, wakeup_events),
-		STRACE_PEA_SIZE = 128,
+		STRACE_PEA_SIZE = 136,
 	};
 
 	uint32_t read_size;
@@ -385,6 +385,14 @@ print_event_attr(struct perf_event_attr *attr_ptr, size_t size,
 	val = attr->sig_data;
 	printf(", sig_data=%#" PRIx64, (uint64_t) val);
 
+	if (size <= 128) {
+		cutoff = 128;
+		goto end;
+	}
+
+	val = attr->config3;
+	printf(", config3=%#" PRIx64, (uint64_t) val);
+
 	cutoff = STRACE_PEA_SIZE;
 
 end:
-- 
2.39.1



More information about the Strace-devel mailing list