xiaoxiang781216 commented on PR #21424:
URL: https://github.com/apache/nuttx/pull/21424#issuecomment-6796710912

   > On SMP with arm64, the run-time accounting of critmonitor subtracts a PMU 
cycle count of one CPU from a stamp that another CPU took 
(nxsched_update_critmon(), nxsched_critmon_runtime(); master does the same in 
nxsched_update_critmon()). The PMU cycle counters of the CPUs are not 
synchronized: on qemu-armv8a:nsh_smp they differ by about 3 ms (each secondary 
CPU resets PMCCNTR when it starts), and CLOCK_THREAD_CPUTIME_ID goes back by up 
to 3 ms, thousands of times in 10 s; the CPU load of `ps` is wrong too. With 
CNTVCT_EL0 as the time base, the same test gives 0 steps back. Which fix do you 
prefer?
   > 
   > 1. With SMP, every CPU accounts only its own thread: other CPUs account 
through an async SMP call, and a reader adds the running slice only for a 
thread on its own CPU (a lag of up to one sample period).
   > 2. An arch declares a per-CPU perf counter, and with SMP critmonitor uses 
a counter that is the same on all CPUs for the run time and the CPU load 
(CNTVCT_EL0 on arm64).
   >    I will fix it in a separate PR before this one.
   
   it's better to fix the difference in the arch specific code since:
   
   1. Not all arch PMU expose this issue
   2. Other perf count backend (e.g. arch timer/alarm) don't have this problem
   


-- 
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