blob: 5b2cc28741a9a63f36de646f1e5fc9cc4d4abcc2 [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
Kapileshwar Singhff2b31e2015-05-15 16:24:56 +010060SchedLoadAvgCpu = register_dynamic("SchedLoadAvgCpu",
61 "sched_load_avg_cpu:",
62 "sched")
63
64SchedContribScaleFactor = register_dynamic("SchedContribScaleFactor",
65 "sched_contrib_scale_f:",
66 "sched")
67
68SchedCpuCapacity = register_dynamic("SchedCpuCapacity",
69 "sched_cpu_capacity:",
70 "sched")
Dietmar Eggemannf545f852014-12-30 11:56:22 +010071
Kapileshwar Singh8733fa62015-06-18 23:01:22 +010072SchedSwitch = register_dynamic("SchedSwitch",
73 "sched_switch",
74 "sched",
75 parse_raw=True)
76
Dietmar Eggemannf545f852014-12-30 11:56:22 +010077class SchedCpuFrequency(Base):
78 """Corresponds to Linux kernel trace event power/cpu_frequency"""
79 unique_word="cpu_frequency:"
80 name="sched_cpu_frequency"
81
Javi Merino6f34d902015-02-21 11:39:09 +000082 def __init__(self):
Dietmar Eggemannf545f852014-12-30 11:56:22 +010083 super(SchedCpuFrequency, self).__init__(
Dietmar Eggemannf545f852014-12-30 11:56:22 +010084 unique_word=self.unique_word,
85 )
86
87 def finalize_object(self):
88 """This renaming is necessary because our cpu related pivot is 'cpu'
89 and not 'cpu_id'. Otherwise you cannot 'mix and match' with other
90 classes
91 """
92 self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True)
Javi Merino323bb8d2015-04-20 17:09:15 +010093
94Run.register_class(SchedCpuFrequency, "sched")