Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf tsc: Add rdtsc() for Arm64

The system register CNTVCT_EL0 can be used to retrieve the counter from
user space. Add rdtsc() for Arm64.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kemeng Shi <shikemeng@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Gasson <nick.gasson@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Remi Bernon <rbernon@codeweavers.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Steve Maclean <steve.maclean@microsoft.com>
Cc: Will Deacon <will@kernel.org>
Cc: Zou Wei <zou_wei@huawei.com>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lore.kernel.org/lkml/20200914115311.2201-3-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Leo Yan and committed by
Arnaldo Carvalho de Melo
4979e861 03fca3af

+22
+1
tools/perf/arch/arm64/util/Build
··· 1 1 perf-y += header.o 2 2 perf-y += machine.o 3 3 perf-y += perf_regs.o 4 + perf-y += tsc.o 4 5 perf-$(CONFIG_DWARF) += dwarf-regs.o 5 6 perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o 6 7 perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
+21
tools/perf/arch/arm64/util/tsc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/types.h> 4 + 5 + #include "../../../util/tsc.h" 6 + 7 + u64 rdtsc(void) 8 + { 9 + u64 val; 10 + 11 + /* 12 + * According to ARM DDI 0487F.c, from Armv8.0 to Armv8.5 inclusive, the 13 + * system counter is at least 56 bits wide; from Armv8.6, the counter 14 + * must be 64 bits wide. So the system counter could be less than 64 15 + * bits wide and it is attributed with the flag 'cap_user_time_short' 16 + * is true. 17 + */ 18 + asm volatile("mrs %0, cntvct_el0" : "=r" (val)); 19 + 20 + return val; 21 + }