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 947dbe6ee09c2639c0cf2e8f0195a2614c1f09a1
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Nov 3 17:32:09 2026 +0100

    arch/arm/qemu: Give up_perf_init() the 1 GHz rate of the QEMU PMU.
    
    qemu_boot.c calls up_perf_init(0).  arm_perf.c then uses the rate of
    the generic timer (62.5 MHz), but QEMU counts the PMU cycle counter
    (PMCCNTR) at a fixed 1 GHz.  So perf_convert() and the CPU-time clocks
    of SCHED_CRITMONITOR run 16 times too fast on qemu-armv7a and
    qemu-armv7r.
    
    Give up_perf_init() 1 GHz.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 arch/arm/src/qemu/qemu_boot.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/arm/src/qemu/qemu_boot.c b/arch/arm/src/qemu/qemu_boot.c
index 4ba14140ffe..f1e51d8d65e 100644
--- a/arch/arm/src/qemu/qemu_boot.c
+++ b/arch/arm/src/qemu/qemu_boot.c
@@ -54,6 +54,14 @@
 
 #include <nuttx/syslog/syslog_rpmsg.h>
 
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* QEMU counts the PMU cycle counter (PMCCNTR) at 1 GHz */
+
+#define QEMU_PMU_CYCLES_PER_SEC  1000000000
+
 /****************************************************************************
  * Private Data
  ****************************************************************************/
@@ -79,7 +87,7 @@ void arm_boot(void)
 #ifdef CONFIG_ARCH_PERF_EVENTS
   /* Perf init */
 
-  up_perf_init(0);
+  up_perf_init((void *)QEMU_PMU_CYCLES_PER_SEC);
 #endif
 
 #ifdef CONFIG_ARCH_ARMV7A

Reply via email to