mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 09:49:21 +08:00
sched/cpuload: fix SMP situation CPULOAD statistics are inaccurate
When statistics when sched_cpuload_critMonitor, thread switching only calculates the current CPU's running time. Other CPU running threads are updated for updates Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
38f0056dcd
commit
f88afa5825
1 changed files with 53 additions and 0 deletions
|
@ -153,6 +153,59 @@ static void nxsched_critmon_cpuload(FAR struct tcb_s *tcb, clock_t current,
|
|||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsched_critmon_cpuload
|
||||
*
|
||||
* Description:
|
||||
* Update the running time of all running threads when switching threads
|
||||
*
|
||||
* Input Parameters:
|
||||
* tcb - The task that we are performing the load operations on.
|
||||
* current - The current time
|
||||
* tick - The ticks that we process in this cpuload.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SCHED_CPULOAD_CRITMONITOR
|
||||
static void nxsched_critmon_cpuload(FAR struct tcb_s *tcb, clock_t current,
|
||||
clock_t tick)
|
||||
{
|
||||
int i;
|
||||
UNUSED(i);
|
||||
|
||||
/* Update the cpuload of the thread ready to be suspended */
|
||||
|
||||
nxsched_process_taskload_ticks(tcb, tick);
|
||||
|
||||
/* Update the cpuload of threads running on other CPUs */
|
||||
|
||||
# ifdef CONFIG_SMP
|
||||
for (i = 0; i < CONFIG_SMP_NCPUS; i++)
|
||||
{
|
||||
FAR struct tcb_s *rtcb = current_task(i);
|
||||
|
||||
if (tcb->cpu == rtcb->cpu)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
nxsched_process_taskload_ticks(rtcb, tick);
|
||||
|
||||
/* Update start time, avoid repeated statistics when the next call */
|
||||
|
||||
rtcb->run_start = current;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
Loading…
Reference in a new issue