Re: [PATCH v4 1/2] perf: Reveal PMU type in fdinfo

From: Ian Rogers

Date: Wed Apr 01 2026 - 12:53:30 EST


On Wed, Nov 12, 2025 at 8:59 AM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> On Mon, Sep 29, 2025 at 8:12 PM Mi, Dapeng <dapeng1.mi@xxxxxxxxxxxxxxx> wrote:
> >
> >
> > On 6/4/2025 2:15 AM, Chun-Tse Shao wrote:
> > > 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: 0
> > >
> > > 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: 65536
> > >
> > > Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
> > > Signed-off-by: Chun-Tse Shao <ctshao@xxxxxxxxxx>
> > > ---
> > > v4:
> > > Removed the first patch in v3 since it is merged.
> > > Retested to make sure the patch still work.
> > >
> > > v3: lore.kernel.org/20241106003007.2112584-2-ctshao@xxxxxxxxxx
> > >
> > > kernel/events/core.c | 10 ++++++++++
> > > 1 file changed, 10 insertions(+)
> > >
> > > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > > index 95e703891b24..bad563692d63 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"
> > >
> > > @@ -7077,6 +7078,14 @@ 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:\t%llu\n", (unsigned long long)event->attr.config);
> >
> > Could we print the config field with hexadecimal format? It makes the event
> > is more easily recognized. Thanks.
>
> I think this is a reasonable suggestion. I think it would also be
> useful to dump the config1, config2 and config3 values. I also think
> the state of the event would be useful for debugging.

Any updates on this? It seems to have been forgotten about.

Thanks,
Ian

> Thanks,
> Ian
>
> > > +}
> > > +
> > > static const struct file_operations perf_fops = {
> > > .release = perf_release,
> > > .read = perf_read,
> > > @@ -7085,6 +7094,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.49.0.1204.g71687c7c1d-goog
> > >
> > >