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 |
| 18 | |
| 19 | class SchedLoadAvgSchedGroup(Base): |
| 20 | """Corresponds to Linux kernel trace event sched_load_avg_sched_group""" |
| 21 | unique_word="sched_load_avg_sg:" |
| 22 | name="sched_load_avg_sched_group" |
| 23 | _cpu_mask_column = "cpus" |
| 24 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame^] | 25 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 26 | super(SchedLoadAvgSchedGroup, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 27 | unique_word=self.unique_word, |
| 28 | ) |
| 29 | |
| 30 | def finalize_object(self): |
| 31 | """This condition is necessary to force column 'cpus' to be printed |
| 32 | as 8 digits w/ leading 0 |
| 33 | """ |
| 34 | if self._cpu_mask_column in self.data_frame.columns: |
| 35 | self.data_frame[self._cpu_mask_column] = self.data_frame[self._cpu_mask_column].apply('{:0>8}'.format) |
| 36 | |
| 37 | class SchedLoadAvgTask(Base): |
| 38 | """Corresponds to Linux kernel trace event sched_load_avg_task""" |
| 39 | unique_word="sched_load_avg_task:" |
| 40 | name="sched_load_avg_task" |
| 41 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame^] | 42 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 43 | super(SchedLoadAvgTask, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 44 | unique_word=self.unique_word, |
| 45 | ) |
| 46 | |
| 47 | def get_pids(self, key=""): |
| 48 | """Returns a list of (comm, pid) that contain |
| 49 | 'key' in their 'comm'.""" |
| 50 | df = self.data_frame.drop_duplicates(subset=['comm','pid']).ix[:,['comm','pid']] |
| 51 | |
| 52 | return df[df['comm'].str.contains(key)].values.tolist() |
| 53 | |
| 54 | class SchedLoadAvgCpu(Base): |
| 55 | """Corresponds to Linux kernel trace event sched_load_avg_cpu""" |
| 56 | unique_word="sched_load_avg_cpu:" |
| 57 | name="sched_load_avg_cpu" |
| 58 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame^] | 59 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 60 | super(SchedLoadAvgCpu, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 61 | unique_word=self.unique_word, |
| 62 | ) |
| 63 | |
| 64 | class SchedContribScaleFactor(Base): |
| 65 | """Corresponds to Linux kernel trace event sched_contrib_scale_factor""" |
| 66 | unique_word="sched_contrib_scale_f:" |
| 67 | name="sched_contrib_scale_factor" |
| 68 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame^] | 69 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 70 | super(SchedContribScaleFactor, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 71 | unique_word=self.unique_word, |
| 72 | ) |
| 73 | |
| 74 | class SchedCpuCapacity(Base): |
| 75 | """Corresponds to Linux kernel trace event sched_cpu_capacity""" |
| 76 | unique_word="sched_cpu_capacity:" |
| 77 | name="sched_cpu_capacity" |
| 78 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame^] | 79 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 80 | super(SchedCpuCapacity, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 81 | unique_word=self.unique_word, |
| 82 | ) |
| 83 | |
| 84 | class SchedCpuFrequency(Base): |
| 85 | """Corresponds to Linux kernel trace event power/cpu_frequency""" |
| 86 | unique_word="cpu_frequency:" |
| 87 | name="sched_cpu_frequency" |
| 88 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame^] | 89 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 90 | super(SchedCpuFrequency, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 91 | unique_word=self.unique_word, |
| 92 | ) |
| 93 | |
| 94 | def finalize_object(self): |
| 95 | """This renaming is necessary because our cpu related pivot is 'cpu' |
| 96 | and not 'cpu_id'. Otherwise you cannot 'mix and match' with other |
| 97 | classes |
| 98 | """ |
| 99 | self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True) |