Brendan Jackman | e81fdcb | 2017-01-04 17:10:29 +0000 | [diff] [blame] | 1 | # Copyright 2015-2017 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 | c26a323 | 2015-12-11 18:00:30 +0000 | [diff] [blame] | 17 | """Definitions of scheduler events registered by the FTrace class""" |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 18 | |
Javi Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 19 | from trappy.base import Base |
Javi Merino | 094e742 | 2016-03-22 11:53:55 +0000 | [diff] [blame] | 20 | from trappy.dynamic import register_ftrace_parser, register_dynamic_ftrace |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 21 | |
| 22 | class SchedLoadAvgSchedGroup(Base): |
| 23 | """Corresponds to Linux kernel trace event sched_load_avg_sched_group""" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 24 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 25 | unique_word = "sched_load_avg_sg:" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 26 | """The unique word that will be matched in a trace line""" |
| 27 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 28 | _cpu_mask_column = "cpus" |
| 29 | |
Kapileshwar Singh | bd1a5c1 | 2015-11-19 14:53:59 +0000 | [diff] [blame] | 30 | pivot = "cpus" |
| 31 | """The Pivot along which the data is orthogonal""" |
| 32 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 33 | def finalize_object(self): |
| 34 | """This condition is necessary to force column 'cpus' to be printed |
| 35 | as 8 digits w/ leading 0 |
| 36 | """ |
| 37 | if self._cpu_mask_column in self.data_frame.columns: |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 38 | dfr = self.data_frame[self._cpu_mask_column].apply('{:0>8}'.format) |
| 39 | self.data_frame[self._cpu_mask_column] = dfr |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 40 | |
Javi Merino | 094e742 | 2016-03-22 11:53:55 +0000 | [diff] [blame] | 41 | register_ftrace_parser(SchedLoadAvgSchedGroup, "sched") |
Javi Merino | 323bb8d | 2015-04-20 17:09:15 +0100 | [diff] [blame] | 42 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 43 | class SchedLoadAvgTask(Base): |
| 44 | """Corresponds to Linux kernel trace event sched_load_avg_task""" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 45 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 46 | unique_word = "sched_load_avg_task:" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 47 | """The unique word that will be matched in a trace line""" |
| 48 | |
Kapileshwar Singh | bd1a5c1 | 2015-11-19 14:53:59 +0000 | [diff] [blame] | 49 | pivot = "pid" |
| 50 | """The Pivot along which the data is orthogonal""" |
| 51 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 52 | def get_pids(self, key=""): |
| 53 | """Returns a list of (comm, pid) that contain |
| 54 | 'key' in their 'comm'.""" |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 55 | dfr = self.data_frame.drop_duplicates(subset=['comm', 'pid']) |
| 56 | dfr = dfr.ix[:, ['comm', 'pid']] |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 57 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 58 | return dfr[dfr['comm'].str.contains(key)].values.tolist() |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 59 | |
Javi Merino | 094e742 | 2016-03-22 11:53:55 +0000 | [diff] [blame] | 60 | register_ftrace_parser(SchedLoadAvgTask, "sched") |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 61 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 62 | # pylint doesn't like globals that are not ALL_CAPS |
| 63 | # pylint: disable=invalid-name |
Javi Merino | fecb267 | 2015-12-21 18:34:57 +0000 | [diff] [blame] | 64 | SchedLoadAvgCpu = register_dynamic_ftrace("SchedLoadAvgCpu", |
| 65 | "sched_load_avg_cpu:", "sched", |
| 66 | pivot="cpu") |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 67 | """Load and Utilization Signals for CPUs""" |
Kapileshwar Singh | ff2b31e | 2015-05-15 16:24:56 +0100 | [diff] [blame] | 68 | |
Javi Merino | fecb267 | 2015-12-21 18:34:57 +0000 | [diff] [blame] | 69 | SchedContribScaleFactor = register_dynamic_ftrace("SchedContribScaleFactor", |
| 70 | "sched_contrib_scale_f:", |
| 71 | "sched") |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 72 | """Event to register tracing of contrib factor""" |
Kapileshwar Singh | ff2b31e | 2015-05-15 16:24:56 +0100 | [diff] [blame] | 73 | |
Patrick Bellasi | 4ce5fe2 | 2015-11-13 18:35:19 +0000 | [diff] [blame] | 74 | class SchedCpuCapacity(Base): |
| 75 | """Corresponds to Linux kernel trace event sched/cpu_capacity""" |
| 76 | |
| 77 | unique_word = "cpu_capacity:" |
| 78 | """The unique word that will be matched in a trace line""" |
| 79 | |
Kapileshwar Singh | bd1a5c1 | 2015-11-19 14:53:59 +0000 | [diff] [blame] | 80 | pivot = "cpu" |
| 81 | """The Pivot along which the data is orthogonal""" |
| 82 | |
Patrick Bellasi | 4ce5fe2 | 2015-11-13 18:35:19 +0000 | [diff] [blame] | 83 | def finalize_object(self): |
| 84 | """This renaming is necessary because our cpu related pivot is 'cpu' |
| 85 | and not 'cpu_id'. Otherwise you cannot 'mix and match' with other |
| 86 | classes |
| 87 | """ |
| 88 | self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True) |
Patrick Bellasi | 8dd2417 | 2015-11-16 12:38:09 +0000 | [diff] [blame] | 89 | self.data_frame.rename(columns={'state' :'capacity'}, inplace=True) |
Patrick Bellasi | 4ce5fe2 | 2015-11-13 18:35:19 +0000 | [diff] [blame] | 90 | |
Javi Merino | 094e742 | 2016-03-22 11:53:55 +0000 | [diff] [blame] | 91 | register_ftrace_parser(SchedCpuCapacity, "sched") |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 92 | |
Patrick Bellasi | 6234247 | 2016-02-03 16:14:11 +0000 | [diff] [blame] | 93 | SchedWakeup = register_dynamic_ftrace("SchedWakeup", "sched_wakeup:", "sched", |
| 94 | parse_raw=True) |
| 95 | """Register SchedWakeup Event""" |
| 96 | |
| 97 | SchedWakeupNew = register_dynamic_ftrace("SchedWakeupNew", "sched_wakeup_new:", |
| 98 | "sched", parse_raw=True) |
| 99 | """Register SchedWakeupNew Event""" |
| 100 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 101 | # pylint: enable=invalid-name |
Kapileshwar Singh | 8733fa6 | 2015-06-18 23:01:22 +0100 | [diff] [blame] | 102 | |
Javi Merino | 0341082 | 2016-03-24 10:50:03 +0000 | [diff] [blame] | 103 | class SchedSwitch(Base): |
| 104 | """Parse sched_switch""" |
| 105 | |
| 106 | unique_word = "sched_switch:" |
Chris Redpath | 55c3922 | 2017-06-17 16:25:49 +0100 | [diff] [blame] | 107 | parse_raw = True |
Javi Merino | 0341082 | 2016-03-24 10:50:03 +0000 | [diff] [blame] | 108 | |
| 109 | def __init__(self): |
Chris Redpath | 55c3922 | 2017-06-17 16:25:49 +0100 | [diff] [blame] | 110 | super(SchedSwitch, self).__init__(parse_raw=self.parse_raw) |
Javi Merino | 0341082 | 2016-03-24 10:50:03 +0000 | [diff] [blame] | 111 | |
| 112 | def create_dataframe(self): |
| 113 | self.data_array = [line.replace(" ==> ", " ", 1) |
| 114 | for line in self.data_array] |
| 115 | |
| 116 | super(SchedSwitch, self).create_dataframe() |
| 117 | |
| 118 | register_ftrace_parser(SchedSwitch, "sched") |
| 119 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 120 | class SchedCpuFrequency(Base): |
| 121 | """Corresponds to Linux kernel trace event power/cpu_frequency""" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 122 | |
Javi Merino | 81cbdd8 | 2015-06-19 16:47:44 +0100 | [diff] [blame] | 123 | unique_word = "cpu_frequency:" |
Kapileshwar Singh | 34825fa | 2015-09-09 14:52:16 +0100 | [diff] [blame] | 124 | """The unique word that will be matched in a trace line""" |
| 125 | |
Kapileshwar Singh | bd1a5c1 | 2015-11-19 14:53:59 +0000 | [diff] [blame] | 126 | pivot = "cpu" |
| 127 | """The Pivot along which the data is orthogonal""" |
| 128 | |
Dietmar Eggemann | f545f85 | 2014-12-30 11:56:22 +0100 | [diff] [blame] | 129 | def finalize_object(self): |
| 130 | """This renaming is necessary because our cpu related pivot is 'cpu' |
| 131 | and not 'cpu_id'. Otherwise you cannot 'mix and match' with other |
| 132 | classes |
| 133 | """ |
| 134 | self.data_frame.rename(columns={'cpu_id':'cpu'}, inplace=True) |
Patrick Bellasi | 8dd2417 | 2015-11-16 12:38:09 +0000 | [diff] [blame] | 135 | self.data_frame.rename(columns={'state' :'frequency'}, inplace=True) |
Javi Merino | 323bb8d | 2015-04-20 17:09:15 +0100 | [diff] [blame] | 136 | |
Javi Merino | 094e742 | 2016-03-22 11:53:55 +0000 | [diff] [blame] | 137 | register_ftrace_parser(SchedCpuFrequency, "sched") |
Javi Merino | 35042e2 | 2016-09-08 11:25:04 +0100 | [diff] [blame] | 138 | |
Javi Merino | 4989982 | 2016-09-13 14:28:16 +0100 | [diff] [blame] | 139 | register_dynamic_ftrace("SchedMigrateTask", "sched_migrate_task:", "sched") |