blob: 8d7078ca306d98a306c5f7d9488a12f3b58d74b7 [file] [log] [blame]
Dietmar Eggemannf545f852014-12-30 11:56:22 +01001#!/usr/bin/python
Javi Merinoc47d2df2015-02-06 16:04:03 +00002# $Copyright:
3# ----------------------------------------------------------------
4# This confidential and proprietary software may be used only as
5# authorised by a licensing agreement from ARM Limited
6# (C) COPYRIGHT 2015 ARM Limited
7# ALL RIGHTS RESERVED
8# The entire notice above must be reproduced on all authorised
9# copies and copies may only be made to the extent permitted
10# by a licensing agreement from ARM Limited.
11# ----------------------------------------------------------------
12# File: sched.py
13# ----------------------------------------------------------------
14# $
15#
Dietmar Eggemannf545f852014-12-30 11:56:22 +010016
17from base import Base
Javi Merino323bb8d2015-04-20 17:09:15 +010018from cr2.dynamic import register_dynamic
19from cr2.run import Run
Dietmar Eggemannf545f852014-12-30 11:56:22 +010020
21class SchedLoadAvgSchedGroup(Base):
22 """Corresponds to Linux kernel trace event sched_load_avg_sched_group"""
23 unique_word="sched_load_avg_sg:"
24 name="sched_load_avg_sched_group"
25 _cpu_mask_column = "cpus"
26
Javi Merino6f34d902015-02-21 11:39:09 +000027 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010028 super(SchedLoadAvgSchedGroup, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010029 unique_word=self.unique_word,
30 )
31
32 def finalize_object(self):
33 """This condition is necessary to force column 'cpus' to be printed
34 as 8 digits w/ leading 0
35 """
36 if self._cpu_mask_column in self.data_frame.columns:
37 self.data_frame[self._cpu_mask_column] = self.data_frame[self._cpu_mask_column].apply('{:0>8}'.format)
38
Javi Merino323bb8d2015-04-20 17:09:15 +010039Run.register_class(SchedLoadAvgSchedGroup, "sched")
40
Dietmar Eggemannf545f852014-12-30 11:56:22 +010041class SchedLoadAvgTask(Base):
42 """Corresponds to Linux kernel trace event sched_load_avg_task"""
43 unique_word="sched_load_avg_task:"
44 name="sched_load_avg_task"
45
Javi Merino6f34d902015-02-21 11:39:09 +000046 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010047 super(SchedLoadAvgTask, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010048 unique_word=self.unique_word,
49 )
50
51 def get_pids(self, key=""):
52 """Returns a list of (comm, pid) that contain
53 'key' in their 'comm'."""
54 df = self.data_frame.drop_duplicates(subset=['comm','pid']).ix[:,['comm','pid']]
55
56 return df[df['comm'].str.contains(key)].values.tolist()
57
Javi Merino323bb8d2015-04-20 17:09:15 +010058Run.register_class(SchedLoadAvgTask, "sched")
Dietmar Eggemannf545f852014-12-30 11:56:22 +010059
Javi Merino323bb8d2015-04-20 17:09:15 +010060register_dynamic("SchedLoadAvgCpu", "sched_load_avg_cpu:", "sched")
61register_dynamic("SchedContribScaleFactor", "sched_contrib_scale_f:", "sched")
62register_dynamic("SchedCpuCapacity", "sched_cpu_capacity:", "sched")
Dietmar Eggemannf545f852014-12-30 11:56:22 +010063
64class SchedCpuFrequency(Base):
65 """Corresponds to Linux kernel trace event power/cpu_frequency"""
66 unique_word="cpu_frequency:"
67 name="sched_cpu_frequency"
68
Javi Merino6f34d902015-02-21 11:39:09 +000069 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010070 super(SchedCpuFrequency, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010071 unique_word=self.unique_word,
72 )
73
74 def finalize_object(self):
75 """This renaming is necessary because our cpu related pivot is 'cpu'
76 and not 'cpu_id'. Otherwise you cannot 'mix and match' with other
77 classes
78 """
79 self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True)
Javi Merino323bb8d2015-04-20 17:09:15 +010080
81Run.register_class(SchedCpuFrequency, "sched")