casaroli commented on code in PR #21424:
URL: https://github.com/apache/nuttx/pull/21424#discussion_r4537522031
##########
sched/sched/sched_critmonitor.c:
##########
@@ -110,6 +110,14 @@
static spinlock_t g_crimonitor_lock = SP_UNLOCKED;
#endif
+/* The time of the last CPU load update of each CPU. The run time of the
+ * threads (run_start, run_time) is only changed by their own CPU.
+ */
+
+#ifdef CONFIG_SCHED_CPULOAD_CRITMONITOR
+static clock_t g_cpuload_start[CONFIG_SMP_NCPUS];
Review Comment:
Done.
##########
sched/sched/sched_critmonitor.c:
##########
@@ -137,49 +145,27 @@ clock_t g_busywait_total[CONFIG_SMP_NCPUS];
* Name: nxsched_critmon_cpuload
*
* Description:
- * Update the running time of all running threads when switching threads
+ * Give the running thread of a CPU the CPU load ticks since the last
+ * update of that CPU.
*
* 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.
+ * tcb - The thread that runs on the CPU.
+ * cpu - The CPU.
+ * current - The current time.
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_SCHED_CPULOAD_CRITMONITOR
-static void nxsched_critmon_cpuload(FAR struct tcb_s *tcb, clock_t current,
- clock_t tick)
+static void nxsched_critmon_cpuload(FAR struct tcb_s *tcb, int cpu,
+ clock_t current)
{
- int i;
-
- UNUSED(i);
-
- /* Update the cpuload of the thread ready to be suspended */
-
- nxsched_process_taskload_ticks(tcb, tick);
+ clock_t elapsed = current - g_cpuload_start[cpu];
- /* 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;
Review Comment:
Done.
##########
sched/sched/sched_critmonitor.c:
##########
@@ -137,49 +145,27 @@ clock_t g_busywait_total[CONFIG_SMP_NCPUS];
* Name: nxsched_critmon_cpuload
*
* Description:
- * Update the running time of all running threads when switching threads
+ * Give the running thread of a CPU the CPU load ticks since the last
+ * update of that CPU.
*
* 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.
+ * tcb - The thread that runs on the CPU.
+ * cpu - The CPU.
+ * current - The current time.
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_SCHED_CPULOAD_CRITMONITOR
-static void nxsched_critmon_cpuload(FAR struct tcb_s *tcb, clock_t current,
- clock_t tick)
+static void nxsched_critmon_cpuload(FAR struct tcb_s *tcb, int cpu,
+ clock_t current)
{
- int i;
-
- UNUSED(i);
-
- /* Update the cpuload of the thread ready to be suspended */
-
- nxsched_process_taskload_ticks(tcb, tick);
+ clock_t elapsed = current - g_cpuload_start[cpu];
Review Comment:
Done.
--
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]