Javi Merino | aace7c0 | 2015-08-10 14:10:47 +0100 | [diff] [blame] | 1 | # Copyright 2015-2015 ARM Limited |
Javi Merino | c47d2df | 2015-02-06 16:04:03 +0000 | [diff] [blame] | 2 | # |
Javi Merino | aace7c0 | 2015-08-10 14:10:47 +0100 | [diff] [blame] | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 16 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 17 | """Definitions of scheduler events registered by the Run class""" |
| 18 | |
Javi Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 19 | from trappy.base import Base |
| 20 | from trappy.dynamic import register_dynamic |
| 21 | from trappy.run import Run |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 22 | |
| 23 | class SchedLoadAvgSchedGroup(Base): |
| 24 | """Corresponds to Linux kernel trace event sched_load_avg_sched_group""" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 25 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 26 | unique_word = "sched_load_avg_sg:" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 27 | """The unique word that will be matched in a trace line""" |
| 28 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 29 | name = "sched_load_avg_sched_group" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 30 | """The name of the :mod:`pandas.DataFrame` member that will be created in a |
| 31 | :mod:`trappy.run.Run` object""" |
| 32 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 33 | _cpu_mask_column = "cpus" |
| 34 | |
Kapileshwar Singh | bd1a5c1 | 2015-11-19 14:53:59 +0000 | [diff] [blame^] | 35 | pivot = "cpus" |
| 36 | """The Pivot along which the data is orthogonal""" |
| 37 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame] | 38 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 39 | super(SchedLoadAvgSchedGroup, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 40 | unique_word=self.unique_word, |
| 41 | ) |
| 42 | |
| 43 | def finalize_object(self): |
| 44 | """This condition is necessary to force column 'cpus' to be printed |
| 45 | as 8 digits w/ leading 0 |
| 46 | """ |
| 47 | if self._cpu_mask_column in self.data_frame.columns: |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 48 | dfr = self.data_frame[self._cpu_mask_column].apply('{:0>8}'.format) |
| 49 | self.data_frame[self._cpu_mask_column] = dfr |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 50 | |
Javi Merino | 323bb8d | 2015-04-20 17:09:15 +0100 | [diff] [blame] | 51 | Run.register_class(SchedLoadAvgSchedGroup, "sched") |
| 52 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 53 | class SchedLoadAvgTask(Base): |
| 54 | """Corresponds to Linux kernel trace event sched_load_avg_task""" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 55 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 56 | unique_word = "sched_load_avg_task:" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 57 | """The unique word that will be matched in a trace line""" |
| 58 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 59 | name = "sched_load_avg_task" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 60 | """The name of the :mod:`pandas.DataFrame` member that will be created in a |
| 61 | :mod:`trappy.run.Run` object""" |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 62 | |
Kapileshwar Singh | bd1a5c1 | 2015-11-19 14:53:59 +0000 | [diff] [blame^] | 63 | pivot = "pid" |
| 64 | """The Pivot along which the data is orthogonal""" |
| 65 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame] | 66 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 67 | super(SchedLoadAvgTask, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 68 | unique_word=self.unique_word, |
| 69 | ) |
| 70 | |
| 71 | def get_pids(self, key=""): |
| 72 | """Returns a list of (comm, pid) that contain |
| 73 | 'key' in their 'comm'.""" |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 74 | dfr = self.data_frame.drop_duplicates(subset=['comm', 'pid']) |
| 75 | dfr = dfr.ix[:, ['comm', 'pid']] |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 76 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 77 | return dfr[dfr['comm'].str.contains(key)].values.tolist() |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 78 | |
Javi Merino | 323bb8d | 2015-04-20 17:09:15 +0100 | [diff] [blame] | 79 | Run.register_class(SchedLoadAvgTask, "sched") |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 80 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 81 | # pylint doesn't like globals that are not ALL_CAPS |
| 82 | # pylint: disable=invalid-name |
Kapileshwar Singh | ff2b31e | 2015-05-15 16:24:56 +0100 | [diff] [blame] | 83 | SchedLoadAvgCpu = register_dynamic("SchedLoadAvgCpu", |
| 84 | "sched_load_avg_cpu:", |
Kapileshwar Singh | bd1a5c1 | 2015-11-19 14:53:59 +0000 | [diff] [blame^] | 85 | "sched", pivot="cpu") |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 86 | """Load and Utilization Signals for CPUs""" |
Kapileshwar Singh | ff2b31e | 2015-05-15 16:24:56 +0100 | [diff] [blame] | 87 | |
| 88 | SchedContribScaleFactor = register_dynamic("SchedContribScaleFactor", |
| 89 | "sched_contrib_scale_f:", |
| 90 | "sched") |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 91 | """Event to register tracing of contrib factor""" |
Kapileshwar Singh | ff2b31e | 2015-05-15 16:24:56 +0100 | [diff] [blame] | 92 | |
Patrick Bellasi | 4ce5fe2 | 2015-11-13 18:35:19 +0000 | [diff] [blame] | 93 | class SchedCpuCapacity(Base): |
| 94 | """Corresponds to Linux kernel trace event sched/cpu_capacity""" |
| 95 | |
| 96 | unique_word = "cpu_capacity:" |
| 97 | """The unique word that will be matched in a trace line""" |
| 98 | |
| 99 | name = "sched_cpu_capacity" |
| 100 | """The name of the :mod:`pandas.DataFrame` member that will be created in a |
| 101 | :mod:`trappy.run.Run` object""" |
| 102 | |
Kapileshwar Singh | bd1a5c1 | 2015-11-19 14:53:59 +0000 | [diff] [blame^] | 103 | pivot = "cpu" |
| 104 | """The Pivot along which the data is orthogonal""" |
| 105 | |
Patrick Bellasi | 4ce5fe2 | 2015-11-13 18:35:19 +0000 | [diff] [blame] | 106 | def __init__(self): |
| 107 | super(SchedCpuCapacity, self).__init__( |
| 108 | unique_word=self.unique_word, |
| 109 | ) |
| 110 | |
| 111 | def finalize_object(self): |
| 112 | """This renaming is necessary because our cpu related pivot is 'cpu' |
| 113 | and not 'cpu_id'. Otherwise you cannot 'mix and match' with other |
| 114 | classes |
| 115 | """ |
| 116 | self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True) |
Patrick Bellasi | 8dd2417 | 2015-11-16 12:38:09 +0000 | [diff] [blame] | 117 | self.data_frame.rename(columns={'state' :'capacity'}, inplace=True) |
Patrick Bellasi | 4ce5fe2 | 2015-11-13 18:35:19 +0000 | [diff] [blame] | 118 | |
| 119 | Run.register_class(SchedCpuCapacity, "sched") |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 120 | |
Kapileshwar Singh | 8733fa6 | 2015-06-18 23:01:22 +0100 | [diff] [blame] | 121 | SchedSwitch = register_dynamic("SchedSwitch", |
| 122 | "sched_switch", |
| 123 | "sched", |
| 124 | parse_raw=True) |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 125 | """Register SchedSwitch Event""" |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 126 | # pylint: enable=invalid-name |
Kapileshwar Singh | 8733fa6 | 2015-06-18 23:01:22 +0100 | [diff] [blame] | 127 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 128 | class SchedCpuFrequency(Base): |
| 129 | """Corresponds to Linux kernel trace event power/cpu_frequency""" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 130 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 131 | unique_word = "cpu_frequency:" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 132 | """The unique word that will be matched in a trace line""" |
| 133 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 134 | name = "sched_cpu_frequency" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 135 | """The name of the :mod:`pandas.DataFrame` member that will be created in a |
| 136 | :mod:`trappy.run.Run` object""" |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 137 | |
Kapileshwar Singh | bd1a5c1 | 2015-11-19 14:53:59 +0000 | [diff] [blame^] | 138 | pivot = "cpu" |
| 139 | """The Pivot along which the data is orthogonal""" |
| 140 | |
Javi Merino | 6f34d90 | 2015-02-21 11:39:09 +0000 | [diff] [blame] | 141 | def __init__(self): |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 142 | super(SchedCpuFrequency, self).__init__( |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 143 | unique_word=self.unique_word, |
| 144 | ) |
| 145 | |
| 146 | def finalize_object(self): |
| 147 | """This renaming is necessary because our cpu related pivot is 'cpu' |
| 148 | and not 'cpu_id'. Otherwise you cannot 'mix and match' with other |
| 149 | classes |
| 150 | """ |
| 151 | self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True) |
Patrick Bellasi | 8dd2417 | 2015-11-16 12:38:09 +0000 | [diff] [blame] | 152 | self.data_frame.rename(columns={'state' :'frequency'}, inplace=True) |
Javi Merino | 323bb8d | 2015-04-20 17:09:15 +0100 | [diff] [blame] | 153 | |
| 154 | Run.register_class(SchedCpuFrequency, "sched") |