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