casaroli opened a new pull request, #21433:
URL: https://github.com/apache/nuttx/pull/21433

   ## Summary
   
   The goldfish emulator is based on QEMU, which counts the PMU cycle counter 
(PMCCNTR) at a fixed 1 GHz with TCG and with HVF. The goldfish chips give 
up_perf_init() a lower rate: arm64 gives 62.5 MHz 
(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, the rate of the generic timer), and arm 
gives 0, so arm_perf.c uses the rate of the generic timer.
   
   As a result, perf_convert() and the CPU-time clocks of SCHED_CRITMONITOR run 
too fast. #21425 fixes the same problem for the qemu boards (measured there: a 
busy loop of 200 ms gives 3200 ms of CPU time).
   
   This PR gives up_perf_init() 1 GHz on arch/arm64/src/goldfish and 
arch/arm/src/goldfish (one commit each). On arm64, 
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC stays for CNTFRQ_EL0.
   
   ## Impact
   
   Only the goldfish chips with ARCH_PERF_EVENTS (the default with 
SCHED_CRITMONITOR, SCHED_IRQMONITOR, RPMSG_PING and SEGGER_SYSVIEW). Perf times 
are now correct when the emulator runs with TCG or HVF. No API change.
   
   With KVM the counter is the cycle counter of the host, whose rate NuttX does 
not know. This PR does not change that case.
   
   No documentation change: Documentation/ gives no rate for goldfish.
   
   ## Testing
   
   The tree has no goldfish board configuration, and the goldfish emulator is 
not available here, so this PR is compile-tested only:
   
   | file | check | result |
   |---|---|---|
   | arch/arm64/src/goldfish/goldfish_boot.c | compiled with the flags of 
qemu-armv8a:nsh (SCHED_CRITMONITOR, ARCH_PERF_EVENTS, -Werror) | OK |
   | arch/arm/src/goldfish/goldfish_boot.c | compiled with the flags of 
qemu-armv7a:nsh (SCHED_CRITMONITOR, ARCH_PERF_EVENTS, -Werror) | OK |
   
   The same 1 GHz rate on qemu-armv8a and qemu-armv7a (#21425) gives the 
correct CPU time under QEMU TCG and HVF (200 ms for a 200 ms busy loop).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to