[PATCH v2] libmisc/top: Fix the idle time and priorities on SMP
jameszxj
jameszxj at gmail.com
Fri Dec 13 07:48:39 UTC 2019
Hi,
1. "data->current_idle" and "data->idle" should be initialize (_Timestamp_Set_to_zero), or the " Load Average" will not be right.
2. On z7020 board, SMP mode, the RPRI and CPRI of idle seems not reasonable.
ID | NAME | RPRI | CPRI | TIME | TOTAL | CURRENT
------------+---------------------+---------------+---------------------+---------+--^^----
0x09010001 | IDLE | 2147483647 | 2147483647 | 4.372973 | 53.157 | 99.998
0x09010002 | IDLE | 2147483647 | 2147483647 | 3.620072 | 44.005 | 99.862
0x0a010002 | WDOG | 3 | 3 | 0.000028 | 0.000 | 0.000
0x0a010003 | QSPI | 100 | 100 | 0.228549 | 2.778 | 0.000
0x0a010004 | TIME | 98 | 98 | 0.002924 | 0.035 | 0.132
------------------ Original ------------------
From: "Sebastian Huber"<sebastian.huber at embedded-brains.de>;
Date: Fri, Dec 13, 2019 03:08 PM
To: "rtems-devel"<rtems-devel at rtems.org>;
Subject: [PATCH v2] libmisc/top: Fix the idle time and priorities on SMP
From: Chris Johns <chrisj at rtems.org>
- This patch is based on the patch attached to #3552 submitted
by jameszxj.
Closes #3552
---
cpukit/libmisc/cpuuse/cpuusagetop.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/cpukit/libmisc/cpuuse/cpuusagetop.c b/cpukit/libmisc/cpuuse/cpuusagetop.c
index 96e364bf93..146b9801a4 100644
--- a/cpukit/libmisc/cpuuse/cpuusagetop.c
+++ b/cpukit/libmisc/cpuuse/cpuusagetop.c
@@ -36,10 +36,12 @@
#include <rtems/malloc.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/protectedheap.h>
+#include <rtems/score/schedulerimpl.h>
#include <rtems/score/threadimpl.h>
#include <rtems/score/todimpl.h>
#include <rtems/score/watchdogimpl.h>
#include <rtems/score/wkspace.h>
+#include <rtems/rtems/tasksimpl.h>
#include "cpuuseimpl.h"
@@ -194,10 +196,10 @@ task_usage(Thread_Control* thread, void* arg)
_Timestamp_Add_to(&data->total, &usage);
_Timestamp_Add_to(&data->current, ¤t);
- if (thread->Object.id == 0x09010001)
+ if (thread->is_idle)
{
- data->idle = usage;
- data->current_idle = current;
+ data->idle += usage;
+ data->current_idle += current;
}
/*
@@ -421,9 +423,13 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
for (i = 0; i < data->task_count; i++)
{
- Thread_Control* thread = data->tasks[i];
- Timestamp_Control usage;
- Timestamp_Control current_usage;
+ Thread_Control* thread = data->tasks[i];
+ Timestamp_Control usage;
+ Timestamp_Control current_usage;
+ Thread_queue_Context queue_context;
+ const Scheduler_Control *scheduler;
+ Priority_Control real_priority;
+ Priority_Control priority;
if (thread == NULL)
break;
@@ -444,12 +450,19 @@ rtems_cpuusage_top_thread (rtems_task_argument arg)
if (name[0] == '\0')
snprintf(name, sizeof(name) - 1, "(%p)", thread->Start.Entry.Kinds.Numeric.entry);
+ _Thread_queue_Context_initialize(&queue_context);
+ _Thread_Wait_acquire(thread, &queue_context);
+ scheduler = _Thread_Scheduler_get_home(thread);
+ real_priority = thread->Real_priority.priority;
+ priority = _Thread_Get_priority(thread);
+ _Thread_Wait_release(thread, &queue_context);
+
rtems_printf(data->printer,
- " 0x%08" PRIx32 " | %-19s | %3" PRId64 " | %3" PRId64 " | ",
+ " 0x%08" PRIx32 " | %-19s | %3" PRId32 " | %3" PRId32 " | ",
thread->Object.id,
name,
- _Thread_Get_unmapped_real_priority(thread),
- _Thread_Get_unmapped_priority(thread));
+ _RTEMS_Priority_From_core(scheduler, real_priority),
+ _RTEMS_Priority_From_core(scheduler, priority));
usage = data->usage[i];
current_usage = data->current_usage[i];
--
2.16.4
_______________________________________________
devel mailing list
devel at rtems.org
http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20191213/4e63d7f2/attachment.html>
More information about the devel
mailing list