From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Rob Herring <robh@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@redhat.com>,
linux-kernel@vger.kernel.org, Will Deacon <will@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Itaru Kitayama <itaru.kitayama@gmail.com>
Subject: Re: [PATCH v8 4/4] libperf: Add support for user space counter access
Date: Tue, 20 Apr 2021 08:10:27 -0300 [thread overview]
Message-ID: <YH62o3A6DXQPiylT@kernel.org> (raw)
In-Reply-To: <20210414155412.3697605-4-robh@kernel.org>
Em Wed, Apr 14, 2021 at 11:07:39AM -0500, Rob Herring escreveu:
> 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.
>
> In order to support usersapce access, an event must be mmapped first
> with perf_evsel__mmap(). Then subsequent calls to perf_evsel__read()
> will use the fast path (assuming the arch supports it).
Had to apply this to fix the build on the other arches:
> +#if defined(__i386__) || defined(__x86_64__)
> +static u64 read_perf_counter(unsigned int counter)
> +{
> + unsigned int low, high;
> +
> + asm volatile("rdpmc" : "=a" (low), "=d" (high) : "c" (counter));
> +
> + return low | ((u64)high) << 32;
> +}
> +
> +static u64 read_timestamp(void)
> +{
> + unsigned int low, high;
> +
> + asm volatile("rdtsc" : "=a" (low), "=d" (high));
> +
> + return low | ((u64)high) << 32;
> +}
> +#else
> +static u64 read_perf_counter(unsigned int counter) { return 0; }
> +static u64 read_timestamp(void) { return 0; }
> +#endif
diff --git a/tools/lib/perf/mmap.c b/tools/lib/perf/mmap.c
index 915469f00cf4c3fb..c89dfa5f67b3a408 100644
--- a/tools/lib/perf/mmap.c
+++ b/tools/lib/perf/mmap.c
@@ -295,7 +295,7 @@ static u64 read_timestamp(void)
return low | ((u64)high) << 32;
}
#else
-static u64 read_perf_counter(unsigned int counter) { return 0; }
+static u64 read_perf_counter(unsigned int counter __maybe_unused) { return 0; }
static u64 read_timestamp(void) { return 0; }
#endif
next prev parent reply other threads:[~2021-04-20 11:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 15:54 [PATCH v8 0/4] libperf userspace counter access Rob Herring
2021-04-14 15:54 ` [PATCH v8 1/4] tools/include: Add an initial math64.h Rob Herring
2021-04-14 16:07 ` [PATCH v8 2/4] libperf: Add evsel mmap support Rob Herring
2021-04-14 16:41 ` Namhyung Kim
2021-04-14 16:53 ` Rob Herring
2021-04-14 17:45 ` Namhyung Kim
2021-04-14 18:02 ` Arnaldo Carvalho de Melo
2021-04-14 18:23 ` Arnaldo Carvalho de Melo
2021-04-14 19:14 ` Namhyung Kim
2021-04-15 19:37 ` Arnaldo Carvalho de Melo
2021-04-15 20:09 ` Rob Herring
2021-04-15 20:20 ` Arnaldo Carvalho de Melo
2021-04-14 16:07 ` [PATCH v8 3/4] libperf: tests: Add support for verbose printing Rob Herring
2021-04-14 16:07 ` [PATCH v8 4/4] libperf: Add support for user space counter access Rob Herring
2021-04-20 11:10 ` Arnaldo Carvalho de Melo [this message]
2021-04-14 19:20 ` [PATCH v8 0/4] libperf userspace " Jiri Olsa
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=YH62o3A6DXQPiylT@kernel.org \
--to=acme@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=itaru.kitayama@gmail.com \
--cc=jolsa@redhat.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 \
--cc=will@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