[PATCH 2/2] ps: Add support to "ps -m" to display process list with timestamp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sometimes "ps -m" options cannot display all processes with timestamp value.

crash> ps -m
ps: last-run timestamps do not exist in this kernel
Usage:
  ps [-k|-u|-G] [-s] [-p|-c|-t|-[l|m][-C cpu]|-a|-g|-r|-S]
     [pid | task | command] ...
Enter "help ps" for details.

This is because output of 'ps -m' depends on task_struct.sched_info.last_arrival.
Without CONFIG_SCHED_STAT or CONFIG_SCHED_INFO, 'sched_info.last_arrival' field 
is not included in task_struct.

So we make 'ps -m' option to access 'exec_start' field of sched_entity.
where 'exec_start' is task_struct.se.exec_start.

With this patch, "ps -m" option works well without CONFIG_SCHED_STAT or
CONFIG_SCHED_INFO.

The history of CONFIG_SCHED_INFO and CONFIG_SCHED_STAT is as below;

  - CONFIG_SCHED_INFO: KERNEL_VERSION >= LINUX(4,2,0)
  - CONFIG_SCHED_STAT: KERNEL_VERSION < LINUX(4,2,0)

Signed-off-by: Austin Kim <austindh.kim@xxxxxxxxx>
---
 task.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/task.c b/task.c
index e6fde74..55e2312 100644
--- a/task.c
+++ b/task.c
@@ -3565,7 +3565,8 @@ cmd_ps(void)
 		case 'm':
 			if (INVALID_MEMBER(task_struct_last_run) &&
 			    INVALID_MEMBER(task_struct_timestamp) &&
-			    INVALID_MEMBER(sched_info_last_arrival)) {
+			    INVALID_MEMBER(sched_info_last_arrival) &&
+			    INVALID_MEMBER(se_exec_start)) {
 				error(INFO, 
                             "last-run timestamps do not exist in this kernel\n");
 				argerrs++;
-- 
2.20.1

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux