linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Chun-Tse Shao <ctshao@google.com>
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	 Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	 Adrian Hunter <adrian.hunter@intel.com>,
	Liang@google.com, Kan <kan.liang@linux.intel.com>,
	 Ze Gao <zegao2021@gmail.com>,
	Yang Jihong <yangjihong1@huawei.com>,
	 Weilin Wang <weilin.wang@intel.com>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/3] perf: Reveal PMU type in fdinfo
Date: Fri, 1 Nov 2024 09:02:22 -0700	[thread overview]
Message-ID: <CAP-5=fVaD8GLhMmM=d4DqHnT24ZDHPAWU56mzSF5OXY=pTO3UA@mail.gmail.com> (raw)
In-Reply-To: <20241031223948.4179222-2-ctshao@google.com>

On Thu, Oct 31, 2024 at 3:39 PM Chun-Tse Shao <ctshao@google.com> wrote:
>
> It gives useful info on knowing which PMUs are reserved by this process.
> Also add extra attributes 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-orig_type:   0

nit: I think this should be:
perf_event-type:   0
this output was from an earlier version.

> perf_event-attr.config1:        0
> perf_event-attr.config2:        0
> perf_event-attr.config3:        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
> perf_event-attr.config1:        0
> perf_event-attr.config2:        0
> perf_event-attr.config3:        0
> ```
>
> Signed-off-by: Chun-Tse Shao <ctshao@google.com>
> ---
>  kernel/events/core.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index cdd09769e6c56..e0891c376fd9d 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -8,6 +8,7 @@
>   *  Copyright  ©  2009 Paul Mackerras, IBM Corp. <paulus@au1.ibm.com>
>   */
>
> +#include "linux/seq_file.h"

nit: I think you should use angle < > rather than quotes on the
include for consistency.

Thanks,
Ian

>  #include <linux/fs.h>
>  #include <linux/mm.h>
>  #include <linux/cpu.h>
> @@ -6820,6 +6821,17 @@ 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", event->attr.config);
> +       seq_printf(m, "perf_event-attr.config1:\t%llu\n", event->attr.config1);
> +       seq_printf(m, "perf_event-attr.config2:\t%llu\n", event->attr.config2);
> +       seq_printf(m, "perf_event-attr.config3:\t%llu\n", event->attr.config3);
> +}
> +
>  static const struct file_operations perf_fops = {
>         .release                = perf_release,
>         .read                   = perf_read,
> @@ -6828,6 +6840,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.163.g1226f6d8fa-goog
>

  reply	other threads:[~2024-11-01 16:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31 22:39 [PATCH 1/3] perf evsel: Improve the evsel__open_strerror for EBUSY Chun-Tse Shao
2024-10-31 22:39 ` [PATCH 2/3] perf: Reveal PMU type in fdinfo Chun-Tse Shao
2024-11-01 16:02   ` Ian Rogers [this message]
2024-11-01 21:24     ` Chun-Tse Shao
2024-11-05 12:24   ` Peter Zijlstra
2024-11-05 15:15     ` Ian Rogers
2024-10-31 22:39 ` [PATCH 3/3] perf evsel: Find process with busy PMUs for EBUSY Chun-Tse Shao
2024-11-01 16:14   ` Ian Rogers
2024-11-01 21:32     ` Chun-Tse Shao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP-5=fVaD8GLhMmM=d4DqHnT24ZDHPAWU56mzSF5OXY=pTO3UA@mail.gmail.com' \
    --to=irogers@google.com \
    --cc=Liang@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=ctshao@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=weilin.wang@intel.com \
    --cc=yangjihong1@huawei.com \
    --cc=zegao2021@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).