Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 1 | #!/usr/bin/python |
Javi Merino | c47d2df | 2015-02-06 16:04:03 +0000 | [diff] [blame] | 2 | # $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 Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 16 | |
| 17 | from base import Base |
Javi Merino | 323bb8d | 2015-04-20 17:09:15 +0100 | [diff] [blame] | 18 | from cr2.dynamic import register_dynamic |
| 19 | from cr2.run import Run |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 20 | |
| 21 | class 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 Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame] | 27 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 28 | super(SchedLoadAvgSchedGroup, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 29 | 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 Merino | 323bb8d | 2015-04-20 17:09:15 +0100 | [diff] [blame] | 39 | Run.register_class(SchedLoadAvgSchedGroup, "sched") |
| 40 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 41 | class 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 Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame] | 46 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 47 | super(SchedLoadAvgTask, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 48 | 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 Merino | 323bb8d | 2015-04-20 17:09:15 +0100 | [diff] [blame] | 58 | Run.register_class(SchedLoadAvgTask, "sched") |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 59 | |
Kapileshwar Singh | ff2b31e | 2015-05-15 16:24:56 +0100 | [diff] [blame^] | 60 | SchedLoadAvgCpu = register_dynamic("SchedLoadAvgCpu", |
| 61 | "sched_load_avg_cpu:", |
| 62 | "sched") |
| 63 | |
| 64 | SchedContribScaleFactor = register_dynamic("SchedContribScaleFactor", |
| 65 | "sched_contrib_scale_f:", |
| 66 | "sched") |
| 67 | |
| 68 | SchedCpuCapacity = register_dynamic("SchedCpuCapacity", |
| 69 | "sched_cpu_capacity:", |
| 70 | "sched") |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 71 | |
| 72 | class SchedCpuFrequency(Base): |
| 73 | """Corresponds to Linux kernel trace event power/cpu_frequency""" |
| 74 | unique_word="cpu_frequency:" |
| 75 | name="sched_cpu_frequency" |
| 76 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame] | 77 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 78 | super(SchedCpuFrequency, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 79 | unique_word=self.unique_word, |
| 80 | ) |
| 81 | |
| 82 | def finalize_object(self): |
| 83 | """This renaming is necessary because our cpu related pivot is 'cpu' |
| 84 | and not 'cpu_id'. Otherwise you cannot 'mix and match' with other |
| 85 | classes |
| 86 | """ |
| 87 | self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True) |
Javi Merino | 323bb8d | 2015-04-20 17:09:15 +0100 | [diff] [blame] | 88 | |
| 89 | Run.register_class(SchedCpuFrequency, "sched") |