[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251121230951.3240124-1-ctshao@google.com>
Date: Fri, 21 Nov 2025 15:09:11 -0800
From: Chun-Tse Shao <ctshao@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: Chun-Tse Shao <ctshao@...gle.com>, Ian Rogers <irogers@...gle.com>, peterz@...radead.org,
mingo@...hat.com, acme@...nel.org, namhyung@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org, adrian.hunter@...el.com,
thomas.falcon@...el.com, kan.liang@...ux.intel.com, howardchu95@...il.com,
linux-perf-users@...r.kernel.org
Subject: [PATCH v5 1/2] perf: Reveal PMU type in fdinfo
It gives useful info on knowing which PMUs are reserved by this process.
Also add config which would be useful.
Testing cycles:
$ ./perf stat -e cycles &
$ cat /proc/`pidof perf`/fdinfo/3
pos: 0
flags: 02000002
mnt_id: 16
ino: 3081
perf_event_attr.type: 0
perf_event_attr.config: 0x0
perf_event_attr.config1: 0x0
perf_event_attr.config2: 0x0
perf_event_attr.config3: 0x0
Testing L1-dcache-load-misses:
$ ./perf stat -e L1-dcache-load-misses &
$ cat /proc/`pidof perf`/fdinfo/3
pos: 0
flags: 02000002
mnt_id: 16
ino: 1072
perf_event_attr.type: 3
perf_event_attr.config: 0x10000
perf_event_attr.config1: 0x0
perf_event_attr.config2: 0x0
perf_event_attr.config3: 0x0
Reviewed-by: Ian Rogers <irogers@...gle.com>
Signed-off-by: Chun-Tse Shao <ctshao@...gle.com>
---
v5:
Added config1, config2 and config3 and print output in hex.
v4:
lore.kernel.org/20250603181634.1362626-1-ctshao@...gle.com/
Removed the first patch in v3 since it is merged.
Retested to make sure the patch still work.
v3: lore.kernel.org/20241106003007.2112584-3-ctshao@...gle.com/
kernel/events/core.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 7541f6f85fcb..17a71fe1d538 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -56,6 +56,7 @@
#include <linux/buildid.h>
#include <linux/task_work.h>
#include <linux/percpu-rwsem.h>
+#include <linux/seq_file.h>
#include "internal.h"
@@ -7212,6 +7213,20 @@ static int perf_fasync(int fd, struct file *filp, int on)
return 0;
}
+static void perf_show_fdinfo(struct seq_file *m, struct file *f)
+{
+ struct perf_event *event = f->private_data;
+
+ seq_printf(m, "perf_event_attr.type:\t%u\n", event->orig_type);
+ seq_printf(m, "perf_event_attr.config:\t0x%llx\n", (unsigned long long)event->attr.config);
+ seq_printf(m, "perf_event_attr.config1:\t0x%llx\n",
+ (unsigned long long)event->attr.config1);
+ seq_printf(m, "perf_event_attr.config2:\t0x%llx\n",
+ (unsigned long long)event->attr.config2);
+ seq_printf(m, "perf_event_attr.config3:\t0x%llx\n",
+ (unsigned long long)event->attr.config3);
+}
+
static const struct file_operations perf_fops = {
.release = perf_release,
.read = perf_read,
@@ -7220,6 +7235,7 @@ static const struct file_operations perf_fops = {
.compat_ioctl = perf_compat_ioctl,
.mmap = perf_mmap,
.fasync = perf_fasync,
+ .show_fdinfo = perf_show_fdinfo,
};
/*
--
2.52.0.rc2.455.g230fcf2819-goog
Powered by blists - more mailing lists