Output last process priority in cputop
authorAntoine Busque <abusque@efficios.com>
Fri, 6 Nov 2015 22:37:42 +0000 (17:37 -0500)
committerAntoine Busque <abusque@efficios.com>
Mon, 9 Nov 2015 00:28:14 +0000 (19:28 -0500)
Signed-off-by: Antoine Busque <abusque@efficios.com>
lttnganalyses/cli/cputop.py
lttnganalyses/core/cputop.py

index 23a2404db53a914abda3fc22f229f7da2802bda7..ca90c4fba459f63935142180a76990b78a6bde6a 100644 (file)
@@ -45,6 +45,7 @@ class Cputop(Command):
             'Per-TID top CPU usage', [
                 ('process', 'Process', mi.Process),
                 ('migrations', 'Migration count', mi.Integer, 'migrations'),
+                ('priority', 'Priority', mi.Integer),
                 ('usage', 'CPU usage', mi.Ratio),
             ]
         ),
@@ -116,6 +117,7 @@ class Cputop(Command):
             result_table.append_row(
                 process=mi.Process(tid.comm, tid=tid.tid),
                 migrations=mi.Integer(tid.migrate_count),
+                priority=mi.Integer(tid.prio),
                 usage=mi.Ratio.from_percentage(tid.usage_percent)
             )
             count += 1
@@ -171,7 +173,12 @@ class Cputop(Command):
         for row in result_table.rows:
             process_do = row.process
             migration_count = row.migrations.value
-            output_str = '%s (%d)' % (process_do.name, process_do.tid)
+            if row.priority.value is not None:
+                prio_str = 'prio: %d' % row.priority.value
+            else:
+                prio_str = 'prio: ?'
+            output_str = '%s (%d) (%s)' % (process_do.name, process_do.tid,
+                                            prio_str)
 
             if migration_count > 0:
                 output_str += ', %d migrations' % (migration_count)
index f1a7ea2a771ecaaed974ee7df15debf78645e7b0..9b058dd1a6d36fff1a75062ac67c689e82f7b8e0 100644 (file)
@@ -111,6 +111,7 @@ class Cputop(Analysis):
         prev_tid = kwargs['prev_tid']
         next_tid = kwargs['next_tid']
         next_comm = kwargs['next_comm']
+        next_prio = kwargs['next_prio']
 
         if not self._filter_cpu(cpu_id):
             return
@@ -131,6 +132,7 @@ class Cputop(Analysis):
 
         next_proc = self.tids[next_tid]
         next_proc.last_sched_ts = timestamp
+        next_proc.prio  = next_prio
 
     def _process_sched_migrate_task(self, **kwargs):
         cpu_id = kwargs['cpu_id']
@@ -184,6 +186,8 @@ class ProcessCpuStats():
     def __init__(self, tid, comm):
         self.tid = tid
         self.comm = comm
+        # Currently only the latest prio is tracked
+        self.prio = None
         # CPU Time and timestamp in nanoseconds (ns)
         self.total_cpu_time = 0
         self.last_sched_ts = None
This page took 0.026137 seconds and 5 git commands to generate.