This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit e90b24d3daa59cac24b37e4d0752f9eddc94cec9
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Nov 3 21:43:17 2026 +0100

    arch/arm64/goldfish: Give up_perf_init() the 1 GHz rate of the QEMU PMU.
    
    The goldfish emulator is based on QEMU, which counts the PMU cycle
    counter (PMCCNTR_EL0) at a fixed 1 GHz with TCG and with HVF.
    goldfish_boot.c gives up_perf_init() 62.5 MHz, the rate of the generic
    timer, so perf_convert() and the CPU-time clocks of SCHED_CRITMONITOR
    run 16 times too fast.
    
    Give up_perf_init() 1 GHz.  CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC stays for
    CNTFRQ_EL0.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 arch/arm64/src/goldfish/goldfish_boot.c | 2 +-
 arch/arm64/src/goldfish/goldfish_boot.h | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/src/goldfish/goldfish_boot.c 
b/arch/arm64/src/goldfish/goldfish_boot.c
index 2c29d7ba682..820f2f2991e 100644
--- a/arch/arm64/src/goldfish/goldfish_boot.c
+++ b/arch/arm64/src/goldfish/goldfish_boot.c
@@ -175,7 +175,7 @@ void arm64_chip_boot(void)
 #endif
 
 #ifdef CONFIG_ARCH_PERF_EVENTS
-  up_perf_init((void *)CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
+  up_perf_init((void *)GOLDFISH_PMU_CYCLES_PER_SEC);
 #endif
 }
 
diff --git a/arch/arm64/src/goldfish/goldfish_boot.h 
b/arch/arm64/src/goldfish/goldfish_boot.h
index fb60b6f5481..9227ed2311d 100644
--- a/arch/arm64/src/goldfish/goldfish_boot.h
+++ b/arch/arm64/src/goldfish/goldfish_boot.h
@@ -40,6 +40,10 @@
 
 #define CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC  62500000
 
+/* The emulator (QEMU) counts the PMU cycle counter at 1 GHz */
+
+#define GOLDFISH_PMU_CYCLES_PER_SEC         1000000000
+
 /****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/

Reply via email to