[PATCH 05/24] gtrace: Introduce some PMU format attributes
Zane Leung
liangzhen at linux.spacemit.com
Thu Oct 22 20:14:46 PDT 2026
Add new PMU format attributes to support timestamp, context, and
synchronization controls. This allows userspace tools like perf to
pass detailed hardware configurations down to the gtrace framework.
Signed-off-by: Zane Leung <liangzhen at linux.spacemit.com>
---
drivers/hwtracing/gtrace/gtrace-perf.c | 12 ++++++++++++
include/linux/gtrace.h | 7 +++++++
2 files changed, 19 insertions(+)
diff --git a/drivers/hwtracing/gtrace/gtrace-perf.c b/drivers/hwtracing/gtrace/gtrace-perf.c
index 56713c8ee850..703c12b95665 100644
--- a/drivers/hwtracing/gtrace/gtrace-perf.c
+++ b/drivers/hwtracing/gtrace/gtrace-perf.c
@@ -323,9 +323,21 @@ static void gtrace_event_del(struct perf_event *event, int mode)
}
PMU_FORMAT_ATTR(event, "config:0-0");
+PMU_FORMAT_ATTR(context, "config:1-1");
+PMU_FORMAT_ATTR(syncmode, "config:2-3");
+PMU_FORMAT_ATTR(syncmax, "config:4-7");
+PMU_FORMAT_ATTR(timestamp, "config:8-8");
+PMU_FORMAT_ATTR(tsmode, "config:9-11");
+PMU_FORMAT_ATTR(tsprescale, "config:12-13");
static struct attribute *gtrace_pmu_formats_attr[] = {
&format_attr_event.attr,
+ &format_attr_context.attr,
+ &format_attr_syncmode.attr,
+ &format_attr_syncmax.attr,
+ &format_attr_timestamp.attr,
+ &format_attr_tsmode.attr,
+ &format_attr_tsprescale.attr,
NULL,
};
diff --git a/include/linux/gtrace.h b/include/linux/gtrace.h
index 0a017f1f888d..76b1aa9cfe79 100644
--- a/include/linux/gtrace.h
+++ b/include/linux/gtrace.h
@@ -14,6 +14,13 @@
#include <linux/property.h>
#include <linux/types.h>
+#define GTRACE_PMU_ATTR_CFG_CONTEXT_SHIFT 1
+#define GTRACE_PMU_ATTR_CFG_SYNCMODE_MASK GENMASK(3, 2)
+#define GTRACE_PMU_ATTR_CFG_SYNCMAX_MASK GENMASK(7, 4)
+#define GTRACE_PMU_ATTR_CFG_TIMESTAMP_SHIFT 8
+#define GTRACE_PMU_ATTR_CFG_TSMODE_MASK GENMASK(11, 9)
+#define GTRACE_PMU_ATTR_CFG_TSPRESCALE_MASK GENMASK(13, 12)
+
extern struct mutex gtrace_mutex;
/*
--
2.34.1
More information about the linux-riscv
mailing list