[Patch v9 02/10] perf util: Add missed fields in _attr__fprintf() and __attr_swap()

From: Dapeng Mi

Date: Sun Jul 05 2026 - 22:41:18 EST


Some new introduced perf_event_attr fields, like config3 and config4,
are forgotten to add into perf_event_attr__fprintf() and
perf_event__attr_swap() helpers. Add these missed fields into these 2
helpers.

The aux_action is an exception. aux_action aliases bitfields
(e.g. aux_start_paused) in a union. Bitfields and plain u32 fields
follow different endian rules, so both views cannot be swapped
correctly at the same time. Leave aux_action unswapped until the ABI
is represented in a byte-order-safe form.

Signed-off-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
---
tools/perf/util/perf_event_attr_fprintf.c | 4 ++++
tools/perf/util/session.c | 10 ++++++++++
2 files changed, 14 insertions(+)

diff --git a/tools/perf/util/perf_event_attr_fprintf.c b/tools/perf/util/perf_event_attr_fprintf.c
index 3933639d76c5..cc817294ad3d 100644
--- a/tools/perf/util/perf_event_attr_fprintf.c
+++ b/tools/perf/util/perf_event_attr_fprintf.c
@@ -405,6 +405,10 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,
PRINT_ATTRf_bf(aux_pause, p_unsigned);
PRINT_ATTRf_bf(aux_resume, p_unsigned);
}
+ if (attr_size >= offsetof(struct perf_event_attr, config4))
+ PRINT_ATTRf(config3, p_hex);
+ if (attr_size > offsetof(struct perf_event_attr, config4))
+ PRINT_ATTRf(config4, p_hex);

return ret;
}
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 3237870a1a34..212506aa8baa 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -629,6 +629,16 @@ do { \
bswap_field_32(aux_watermark);
bswap_field_16(sample_max_stack);
bswap_field_32(aux_sample_size);
+ /*
+ * aux_action aliases bitfields (e.g. aux_start_paused) in a union.
+ * Bitfields and plain u32 fields follow different endian rules, so
+ * both views cannot be swapped correctly at the same time.
+ * Leave aux_action unswapped until the ABI is represented in a
+ * byte-order-safe form.
+ */
+ bswap_field_64(sig_data);
+ bswap_field_64(config3);
+ bswap_field_64(config4);

/*
* After read_format are bitfields. Check read_format because
--
2.34.1