Skip to content

Commit c688d40

Browse files
Addressing review comments
1 parent 16b2870 commit c688d40

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/tools/llvm-exegesis/lib/RISCV/RISCVCounters.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ namespace exegesis {
2222

2323
inline uint64_t getRISCVCpuCyclesCount() {
2424
#if defined(__riscv) && defined(__linux__)
25-
uint32_t Cycle;
26-
size_t Length = sizeof(Cycle);
27-
if (!sysctlbyname("kernel.perf_user_access", &Cycle, &Length, NULL, 0) ||
28-
Cycle != 1)
29-
report_fatal_error(
30-
"Please write 'sudo echo 1 > /proc/sys/kernel/perf_user_access'");
3125
#if __riscv_xlen == 32
3226
uint32_t cycles_lo, cycles_hi0, cycles_hi1;
3327
asm volatile("rdcycleh %0\n"
@@ -68,6 +62,14 @@ class RISCVCpuCyclesCounter : public pfm::CounterGroup {
6862

6963
RISCVCpuCyclesCounter::RISCVCpuCyclesCounter(pfm::PerfEvent &&Event)
7064
: CounterGroup(std::move(Event), {}) {
65+
#if defined(__riscv) && defined(__linux__)
66+
uint32_t Cycle;
67+
size_t Length = sizeof(Cycle);
68+
if (!sysctlbyname("kernel.perf_user_access", &Cycle, &Length, NULL, 0) ||
69+
Cycle != 1)
70+
report_fatal_error(
71+
"Please write 'sudo echo 1 > /proc/sys/kernel/perf_user_access'");
72+
#endif
7173
StartValue = getRISCVCpuCyclesCount();
7274
EndValue = getRISCVCpuCyclesCount();
7375
MeasurementCycles = EndValue - StartValue;

0 commit comments

Comments
 (0)