You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/05/31 04:57:49 UTC

[incubator-nuttx] branch master updated: cpuload: use correct pm cpuload tick.

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 656f851f20 cpuload: use correct pm cpuload tick.
656f851f20 is described below

commit 656f851f20c828b4154b97856d68227386666cf9
Author: zhuyanlin <zh...@xiaomi.com>
AuthorDate: Wed May 25 23:06:24 2022 +0800

    cpuload: use correct pm cpuload tick.
    
    Signed-off-by: zhuyanlin <zh...@xiaomi.com>
    Signed-off-by: ligd <li...@xiaomi.com>
---
 sched/sched/sched_cpuload_oneshot.c | 15 +++++++++++----
 sched/sched/sched_cpuload_period.c  | 15 +++++++++++----
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/sched/sched/sched_cpuload_oneshot.c b/sched/sched/sched_cpuload_oneshot.c
index c81bc1cca1..769853ff73 100644
--- a/sched/sched/sched_cpuload_oneshot.c
+++ b/sched/sched/sched_cpuload_oneshot.c
@@ -71,7 +71,14 @@
  * nominal = (1,000,000 usec/sec) / Frequency cycles/sec) = Period usec/cycle
  */
 
-#define CPULOAD_ONESHOT_NOMINAL      (1000000 / CONFIG_SCHED_CPULOAD_TICKSPERSEC)
+#define CPULOAD_ONESHOT_NOMINAL (1000000 / CONFIG_SCHED_CPULOAD_TICKSPERSEC)
+
+/* Calculate the systick for one cpuload tick:
+ *
+ * tick = (Tick_per_sec) / Cpuload tick_per_sec) = Systick for one cpuload
+ */
+
+#define CPULOAD_ONESHOT_TICKS   (TICK_PER_SEC / CONFIG_SCHED_CPULOAD_TICKSPERSEC)
 
 #if CPULOAD_ONESHOT_NOMINAL < 1 || CPULOAD_ONESHOT_NOMINAL > 0x7fffffff
 #  error CPULOAD_ONESHOT_NOMINAL is out of range
@@ -242,12 +249,12 @@ static void nxsched_oneshot_pmnotify(FAR struct pm_callback_s *cb,
           g_sched_oneshot.idle_ticks +=
             clock_systime_ticks() - g_sched_oneshot.idle_start;
 
-          if (g_sched_oneshot.idle_ticks >= CPULOAD_ONESHOT_NOMINAL)
+          if (g_sched_oneshot.idle_ticks >= CPULOAD_ONESHOT_TICKS)
             {
               nxsched_process_cpuload_ticks(
-                g_sched_oneshot.idle_ticks / CPULOAD_ONESHOT_NOMINAL);
+                g_sched_oneshot.idle_ticks / CPULOAD_ONESHOT_TICKS);
 
-              g_sched_oneshot.idle_ticks %= CPULOAD_ONESHOT_NOMINAL;
+              g_sched_oneshot.idle_ticks %= CPULOAD_ONESHOT_TICKS;
             }
 
           nxsched_oneshot_start();
diff --git a/sched/sched/sched_cpuload_period.c b/sched/sched/sched_cpuload_period.c
index 045b5935d6..76470661e2 100644
--- a/sched/sched/sched_cpuload_period.c
+++ b/sched/sched/sched_cpuload_period.c
@@ -68,7 +68,14 @@
  * nominal = (1,000,000 usec/sec) / Frequency cycles/sec) = Period usec/cycle
  */
 
-#define CPULOAD_PERIOD_NOMINAL       (1000000 / CONFIG_SCHED_CPULOAD_TICKSPERSEC)
+#define CPULOAD_PERIOD_NOMINAL (1000000 / CONFIG_SCHED_CPULOAD_TICKSPERSEC)
+
+/* Calculate the systick for one cpuload tick:
+ *
+ * tick = (Tick_per_sec) / Cpuload tick_per_sec) = Systick for one cpuload
+ */
+
+#define CPULOAD_PERIOD_TICKS   (TICK_PER_SEC / CONFIG_SCHED_CPULOAD_TICKSPERSEC)
 
 #if CPULOAD_PERIOD_NOMINAL < 1 || CPULOAD_PERIOD_NOMINAL > 0x7fffffff
 #  error CPULOAD_PERIOD_NOMINAL is out of range
@@ -203,12 +210,12 @@ static void nxsched_period_pmnotify(FAR struct pm_callback_s *cb, int domain,
           g_sched_period.idle_ticks +=
             clock_systime_ticks() - g_sched_period.idle_start;
 
-          if (g_sched_period.idle_ticks >= CPULOAD_PERIOD_NOMINAL)
+          if (g_sched_period.idle_ticks >= CPULOAD_PERIOD_TICKS)
             {
               nxsched_process_cpuload_ticks(
-                  g_sched_period.idle_ticks / CPULOAD_PERIOD_NOMINAL);
+                  g_sched_period.idle_ticks / CPULOAD_PERIOD_TICKS);
 
-              g_sched_period.idle_ticks %= CPULOAD_PERIOD_NOMINAL;
+              g_sched_period.idle_ticks %= CPULOAD_PERIOD_TICKS;
             }
 
           g_sched_period.lower->ops->start(g_sched_period.lower);