[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJpZYjW0evv8SmPMwymjcFQExy+zVHe_6XW79bB_ErRXCwgzfA@mail.gmail.com>
Date: Thu, 14 Nov 2024 10:30:01 -0800
From: Chun-Tse Shao <ctshao@...gle.com>
To: Ian Rogers <irogers@...gle.com>
Cc: linux-kernel@...r.kernel.org, Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>, Kan Liang <kan.liang@...ux.intel.com>,
Ze Gao <zegao2021@...il.com>, Weilin Wang <weilin.wang@...el.com>,
linux-perf-users@...r.kernel.org
Subject: Re: [PATCH v3 2/3] perf: Reveal PMU type in fdinfo
Hi Ian,
On Thu, Nov 14, 2024 at 7:49 AM Ian Rogers <irogers@...gle.com> wrote:
>
> On Tue, Nov 5, 2024 at 4:30 PM Chun-Tse Shao <ctshao@...gle.com> wrote:
> >
> > It gives useful info on knowing which PMUs are reserved by this proceszs.
> > 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
> >
> > Signed-off-by: Chun-Tse Shao <ctshao@...gle.com>
>
> Reviewed-by: Ian Rogers <irogers@...gle.com>
>
> > Change-Id: Ibea5618aaf00bae6f48a9b2a6e7798ab2b7f23ce
> > ---
> > kernel/events/core.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > index cdd09769e6c56..398cac8b208b9 100644
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -55,6 +55,7 @@
> > #include <linux/pgtable.h>
> > #include <linux/buildid.h>
> > #include <linux/task_work.h>
> > +#include <linux/seq_file.h>
> >
> > #include "internal.h"
> >
> > @@ -6820,6 +6821,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);
>
> nit: is the cast necessary? I don't see __u64 listed on:
> https://www.kernel.org/doc/Documentation/printk-formats.txt
> so I'm unsure.
>
In this case I think it is safer to cast it to `unsigned long long`,
since I don't know if any architecture would have an exception on
__u64.
Thanks,
CT
> Thanks,
> Ian
>
> > +}
> > +
> > static const struct file_operations perf_fops = {
> > .release = perf_release,
> > .read = perf_read,
> > @@ -6828,6 +6837,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.47.0.199.ga7371fff76-goog
> >
Powered by blists - more mailing lists