<div><div style="font-family: "lucida Grande", Verdana, "Microsoft YaHei";">Hi,</div><div style="font-family: "lucida Grande", Verdana, "Microsoft YaHei";"><div>   1. "data->current_idle" and "data->idle" should be initialize (_Timestamp_Set_to_zero), or the " Load Average" will not be right.</div><div>   2. On z7020 board, SMP mode, the RPRI and CPRI of idle seems not reasonable.</div><div><br></div><div><div> ID         | NAME                | RPRI | CPRI   | TIME                | TOTAL   | CURRENT</div><div>------------+---------------------+---------------+---------------------+---------+--^^----</div><div> 0x<span t="7" data="09010001" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">09010001</span> | IDLE                |  <span t="7" data="2147483647" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">2147483647</span> |  <span t="7" data="2147483647" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">2147483647</span>   | 4.372973            |  53.157 |  99.998</div><div> 0x<span t="7" data="09010002" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">09010002</span> | IDLE                |  <span t="7" data="2147483647" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">2147483647</span> |  <span t="7" data="2147483647" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">2147483647</span>   | 3.620072            |  44.005 |  99.862</div></div><div><div> 0x0a<span t="7" data="010002" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">010002</span> | WDOG                |    3 |    3   | 0.<span t="7" data="000028" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">000028</span>            |   0.000 |   0.000</div><div> 0x0a<span t="7" data="010003" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">010003</span> | QSPI                |  100 |  100   | 0.228549            |   2.778 |   0.000</div><div> 0x0a<span t="7" data="010004" style="border-bottom: 1px dashed rgb(204, 204, 204); z-index: 1;">010004</span> | TIME                |   98 |   98   | 0.002924            |   0.035 |   0.132</div></div></div></div><div><div><br></div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From:</b> "Sebastian Huber"<sebastian.huber@embedded-brains.de>;</div><div><b>Date:</b> Fri, Dec 13, 2019 03:08 PM</div><div><b>To:</b> "rtems-devel"<rtems-devel@rtems.org>;<wbr></div><div></div><div><b>Subject:</b> [PATCH v2] libmisc/top: Fix the idle time and priorities on SMP</div></div><div><br></div>From: Chris Johns <chrisj@rtems.org><br><br>- This patch is based on the patch attached to #3552 submitted<br>  by jameszxj.<br><br>Closes #3552<br>---<br> cpukit/libmisc/cpuuse/cpuusagetop.c | 31 ++++++++++++++++++++++---------<br> 1 file changed, 22 insertions(+), 9 deletions(-)<br><br>diff --git a/cpukit/libmisc/cpuuse/cpuusagetop.c b/cpukit/libmisc/cpuuse/cpuusagetop.c<br>index 96e364bf93..146b9801a4 100644<br>--- a/cpukit/libmisc/cpuuse/cpuusagetop.c<br>+++ b/cpukit/libmisc/cpuuse/cpuusagetop.c<br>@@ -36,10 +36,12 @@<br> #include <rtems/malloc.h><br> #include <rtems/score/objectimpl.h><br> #include <rtems/score/protectedheap.h><br>+#include <rtems/score/schedulerimpl.h><br> #include <rtems/score/threadimpl.h><br> #include <rtems/score/todimpl.h><br> #include <rtems/score/watchdogimpl.h><br> #include <rtems/score/wkspace.h><br>+#include <rtems/rtems/tasksimpl.h><br> <br> #include "cpuuseimpl.h"<br> <br>@@ -194,10 +196,10 @@ task_usage(Thread_Control* thread, void* arg)<br>   _Timestamp_Add_to(&data->total, &usage);<br>   _Timestamp_Add_to(&data->current, &current);<br> <br>-  if (thread->Object.id == 0x09010001)<br>+  if (thread->is_idle)<br>   {<br>-    data->idle = usage;<br>-    data->current_idle = current;<br>+    data->idle += usage;<br>+    data->current_idle += current;<br>   }<br> <br>   /*<br>@@ -421,9 +423,13 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)<br> <br>     for (i = 0; i < data->task_count; i++)<br>     {<br>-      Thread_Control*   thread = data->tasks[i];<br>-      Timestamp_Control usage;<br>-      Timestamp_Control current_usage;<br>+      Thread_Control*          thread = data->tasks[i];<br>+      Timestamp_Control        usage;<br>+      Timestamp_Control        current_usage;<br>+      Thread_queue_Context     queue_context;<br>+      const Scheduler_Control *scheduler;<br>+      Priority_Control         real_priority;<br>+      Priority_Control         priority;<br> <br>       if (thread == NULL)<br>         break;<br>@@ -444,12 +450,19 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)<br>       if (name[0] == '\0')<br>         snprintf(name, sizeof(name) - 1, "(%p)", thread->Start.Entry.Kinds.Numeric.entry);<br> <br>+      _Thread_queue_Context_initialize(&queue_context);<br>+      _Thread_Wait_acquire(thread, &queue_context);<br>+      scheduler = _Thread_Scheduler_get_home(thread);<br>+      real_priority = thread->Real_priority.priority;<br>+      priority = _Thread_Get_priority(thread);<br>+      _Thread_Wait_release(thread, &queue_context);<br>+<br>       rtems_printf(data->printer,<br>-                   " 0x%08" PRIx32 " | %-19s |  %3" PRId64 " |  %3" PRId64 "   | ",<br>+                   " 0x%08" PRIx32 " | %-19s |  %3" PRId32 " |  %3" PRId32 "   | ",<br>                    thread->Object.id,<br>                    name,<br>-                   _Thread_Get_unmapped_real_priority(thread),<br>-                   _Thread_Get_unmapped_priority(thread));<br>+                   _RTEMS_Priority_From_core(scheduler, real_priority),<br>+                   _RTEMS_Priority_From_core(scheduler, priority));<br> <br>       usage = data->usage[i];<br>       current_usage = data->current_usage[i];<br>-- <br>2.16.4<br><br>_______________________________________________<br>devel mailing list<br>devel@rtems.org<br>http://lists.rtems.org/mailman/listinfo/devel<br></div>