linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Rob Herring <robh@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: Re: [RFC] libperf: Add support for user space counter access
Date: Wed, 12 Aug 2020 15:05:17 +0200	[thread overview]
Message-ID: <20200812130517.GB4872@krava.homenet.telecomitalia.it> (raw)
In-Reply-To: <CAL_Jsq+tsTrYCddSSb5d2vC7TTKUZTgjBQr4FHXBKCePo-beZQ@mail.gmail.com>

On Tue, Aug 11, 2020 at 10:49:30AM -0600, Rob Herring wrote:
> On Tue, Aug 11, 2020 at 4:50 AM Jiri Olsa <jolsa@redhat.com> wrote:
> >
> > On Mon, Aug 10, 2020 at 12:11:23PM -0600, Rob Herring wrote:
> > > On Sat, Aug 8, 2020 at 4:22 AM Jiri Olsa <jolsa@redhat.com> wrote:
> > > >
> > > > On Fri, Aug 07, 2020 at 05:05:17PM -0600, Rob Herring wrote:
> > > > > x86 and arm64 can both support direct access of event counters in
> > > > > userspace. The access sequence is less than trivial and currently exists
> > > > > in perf test code (tools/perf/arch/x86/tests/rdpmc.c) with copies in
> > > > > projects such as PAPI and libpfm4.
> > > > >
> > > > > Patches to add arm64 userspace support are pending[1].
> > > > >
> > > > > For this RFC, looking for a yes, seems like a good idea, or no, go away we
> > > > > don't want this in libperf.
> > > >
> > > > hi,
> > > > looks great!
> > > >
> > > > I wanted to add this for very long time.. so yes, we want this ;-)
> > >
> > > Thanks for the quick feedback. Would this be better implemented as a
> > > fast path for perf_evsel__read()? If so, how to get the mmap data
> >
> > if it works for all events, which I'm not sure of
> >
> > > which is associated with a evlist rather than a evsel?
> >
> > not sure what you mean, you can mmap evsel, not evlist
> 
> While yes the mmap is created from an evsel fd, they are ultimately
> associated with the evlist struct and are per thread or cpu. If
> there's more than 1 evsel, then the additional ones are set to the 1st
> mmap with PERF_EVENT_IOC_SET_OUTPUT. Which I now realize means this
> RFC only works for the first evsel. So I guess the API needs to work
> something like this:
> 
> threads = perf_thread_map__new_dummy();
> perf_thread_map__set_pid(threads, 0, 0);
> 
> evsel = perf_evsel__new(&attr);
> perf_evsel__open(evsel, NULL, threads);
> 

hum, I wonder we should remove maps from perf_evsel__open
args and factor out some perf_evsel__set_map function..

> perf_evsel__mmap(evsel);    <--- *new*

.. because you'll need those maps in here, right?

> 
> perf_evsel__read(evsel, 0, 0, &counts);  // If we have an mmap, then
> try a direct read
> 
> 
> Perhaps some refactoring of the mmap code in evlist.c will be needed,
> but the usage seems pretty orthogonal. I'd propose that mmapping via
> perf_evlist__mmap() behavior remain unchanged and direct access is not
> supported in that case.

seems ok to me, perf_evlist__mmap and perf_evsel__mmap would
mean to mutually exclusive usages

thanks,
jirka


  reply	other threads:[~2020-08-12 13:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 23:05 [RFC] libperf: Add support for user space counter access Rob Herring
2020-08-08 10:22 ` Jiri Olsa
2020-08-10 18:11   ` Rob Herring
2020-08-11 10:50     ` Jiri Olsa
2020-08-11 11:02       ` peterz
2020-08-11 16:49       ` Rob Herring
2020-08-12 13:05         ` Jiri Olsa [this message]
2020-08-10 20:24 ` Peter Zijlstra

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=20200812130517.GB4872@krava.homenet.telecomitalia.it \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=robh@kernel.org \
    /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).