Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[arm] Use CNTVCT_EL0 as profiling timestamp
The raw cycle counter at PMCCNTR_EL0 works in qemu but seems to always
read as zero on physical hardware (tested on Juno r1 and Cavium
ThunderX), even after ensuring that PMCR_EL0.E and PMCNTENSET_EL0.C
are both enabled.

Use CNTVCT_EL0 instead; this seems to count at a lower resolution
(tens of CPU cycles), but is usable for profiling.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed May 12, 2016
1 parent 6164741 commit 6017066
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/arch/arm64/include/bits/profile.h
Expand Up @@ -21,9 +21,7 @@ profile_timestamp ( void ) {
uint64_t cycles;

/* Read cycle counter */
__asm__ __volatile__ ( "msr PMCR_EL0, %1\n\t"
"mrs %0, PMCCNTR_EL0\n\t"
: "=r" ( cycles ) : "r" ( 1 ) );
__asm__ __volatile__ ( "mrs %0, CNTVCT_EL0\n\t" : "=r" ( cycles ) );
return cycles;
}

Expand Down

0 comments on commit 6017066

Please sign in to comment.