├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── examples ├── frame_stats.py ├── parse_core_frequencies.py ├── power_perf_tool.py └── thermal_engine.py ├── ftrace ├── __init__.py ├── atrace.py ├── audio.py ├── common.py ├── components │ ├── __init__.py │ ├── android.py │ ├── audio.py │ ├── bus.py │ ├── camera.py │ ├── clock.py │ ├── cluster.py │ ├── cpu.py │ ├── disk.py │ ├── gpu.py │ └── thermal.py ├── composites.py ├── event.py ├── ftrace.py ├── globals.py ├── interval.py ├── io.py ├── parsers │ ├── __init__.py │ ├── binder.py │ ├── binder_command.py │ ├── binder_ioctl.py │ ├── binder_ioctl_done.py │ ├── binder_lock.py │ ├── binder_locked.py │ ├── binder_read_done.py │ ├── binder_return.py │ ├── binder_transaction.py │ ├── binder_transaction_alloc_buf.py │ ├── binder_transaction_buffer_release.py │ ├── binder_transaction_fd.py │ ├── binder_transaction_node_to_ref.py │ ├── binder_transaction_received.py │ ├── binder_transaction_ref_to_node.py │ ├── binder_transaction_ref_to_ref.py │ ├── binder_unlock.py │ ├── binder_update_page_range.py │ ├── binder_wait_for_work.py │ ├── binder_write_done.py │ ├── block_rq_complete.py │ ├── block_rq_insert.py │ ├── block_rq_issue.py │ ├── bus_update_request.py │ ├── clock_disable.py │ ├── clock_enable.py │ ├── clock_set_rate.py │ ├── cluster_enter.py │ ├── cluster_exit.py │ ├── cpu_capacity.py │ ├── cpu_frequency.py │ ├── cpu_frequency_switch_end.py │ ├── cpu_frequency_switch_start.py │ ├── cpu_idle.py │ ├── cpu_idle_enter.py │ ├── cpu_idle_exit.py │ ├── cpufreq_interactive_already.py │ ├── cpufreq_interactive_setspeed.py │ ├── cpufreq_interactive_target.py │ ├── cpufreq_sched_request_opp.py │ ├── cpufreq_sched_update_capacity.py │ ├── ext4_da_write_begin.py │ ├── ext4_da_write_end.py │ ├── ext4_sync_file_enter.py │ ├── ext4_sync_file_exit.py │ ├── f2fs_sync_file_enter.py │ ├── f2fs_sync_file_exit.py │ ├── f2fs_write_begin.py │ ├── f2fs_write_end.py │ ├── gpu_sched_switch.py │ ├── irq_handler_entry.py │ ├── irq_handler_exit.py │ ├── kgsl_bus.py │ ├── kgsl_buslevel.py │ ├── kgsl_clk.py │ ├── kgsl_gpubusy.py │ ├── kgsl_irq.py │ ├── kgsl_pwr_set_state.py │ ├── kgsl_pwrlevel.py │ ├── kgsl_rail.py │ ├── mali_job_slots_event.py │ ├── mali_pm_power_off.py │ ├── mali_pm_power_on.py │ ├── mali_pm_status.py │ ├── memory_bus_usage.py │ ├── register.py │ ├── sched_boost_cpu.py │ ├── sched_contrib_scale_f.py │ ├── sched_hmp_migrate.py │ ├── sched_load_avg_cpu.py │ ├── sched_load_avg_task.py │ ├── sched_migrate_task.py │ ├── sched_rq_nr_running.py │ ├── sched_rq_runnable_load.py │ ├── sched_rq_runnable_ratio.py │ ├── sched_switch.py │ ├── sched_task_load.py │ ├── sched_task_load_contrib.py │ ├── sched_task_runnable_ratio.py │ ├── sched_task_usage_ratio.py │ ├── sched_wakeup.py │ ├── softirq_entry.py │ ├── softirq_exit.py │ ├── softirq_raise.py │ ├── sync_pt.py │ ├── sync_timeline.py │ ├── sync_wait.py │ ├── tracing_mark_write.py │ ├── tsens_read.py │ ├── tsens_threshold_clear.py │ ├── tsens_threshold_hit.py │ ├── workqueue_activate_work.py │ ├── workqueue_execute_end.py │ ├── workqueue_execute_start.py │ └── workqueue_queue_work.py ├── sched_hmp.py ├── task.py ├── third_party │ ├── __init__.py │ ├── cnamedtuple │ │ ├── LICENSE.txt │ │ ├── __init__.py │ │ └── _namedtuple.c │ ├── enum │ │ ├── LICENSE │ │ ├── __init__.py │ │ └── enum.py │ └── histogram.py ├── utils │ ├── __init__.py │ └── decorators.py └── version.py └── setup.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ftrace 2 | 3 | Ftrace is a Python library for parsing and analyzing performance/power of Linux-based platform (e.g.Android). 4 | It relies on Function Tracer (Ftrace) - an internal tracing framework introduced in Linux kernel (>= 2.6.27). 5 | For complete documentation, see [here](http://elinux.org/Ftrace). 6 | 7 | Android devices are shipped with ```atrace``` binary that utilizes Ftrace and supports enabling and profiling 8 | of useful android events. In addition, [Systrace](developer.android.com/tools/help/systrace.html) tool 9 | - Python/HTML-based wrapper - was developed by Google for profiling and visualizing via ```chrome://tracing/``` on Chrome browser. 10 | 11 | # Prerequisites 12 | 13 | ## Ftrace 14 | Ftrace must be configured/enabled in the kernel. This requires CONFIG_FTRACE and other Ftrace options. 15 | 16 | ## debugfs 17 | Requires a kernel with CONFIG_DEBUG_FS option enabled (debugfs was added in 2.6.10-rc3). 18 | The debugfs needs to be mounted: 19 | 20 | ``` 21 | # mount -t debugfs nodev /sys/kernel/debug 22 | ``` 23 | > Most non-rooted (production) devices ship with some support for Ftrace and restrictions on what can be traced. 24 | 25 | # Quick Start 26 | 27 | Ftrace parsing library provides API for in-depth analysis of both performance/power related issues. 28 | A version of this tool was used at Qualcomm (by previous employer) for development of big.LITTLE scheduler, 29 | UX analysis (application launch time), HMP usage and much more. To get started, lets load a trace file. 30 | 31 | ### Loading a trace file. 32 | ```python 33 | trace = Ftrace(r'/some/path/to/trace.html') 34 | # how long is this trace (in seconds) 35 | print trace.interval 36 | print trace.duration 37 | ``` 38 | 39 | ### CPU API examples 40 | ```python 41 | 42 | # Task intervals 43 | print trace.cpu.task_intervals(cpu=0) # you can filter to specific task with task argument 44 | 45 | # Idle/busy times for CPU0 46 | print trace.cpu.idle_intervals(cpu=0) 47 | print trace.cpu.idle_time(cpu=0) 48 | print trace.cpu.busy_intervals(cpu=0) 49 | print trace.cpu.busy_time(cpu=0) 50 | 51 | # Run-Queue information for CPU0 52 | print trace.cpu.runqueue_depth_time(cpu=0, rq_depth=3) # time we has 3 things runnable in queue 53 | print trace.cpu.runqueue_interval(cpu=0) 54 | 55 | # Low Power Modes (LPM) for CPU0 56 | print trace.cpu.lpm_time(cpu=0) 57 | print trace.cpu.lpm_intervals(cpu=0) 58 | 59 | # Simultaneously busy cores 60 | print trace.cpu.simultaneously_busy_time(num_cores=2) # time when 2 cores were busy 61 | print trace.cpu.simultaneously_busy_intervals(num_cores=2, cpus=[0,1,2,3]) # when 2 or more cpus in list were busy 62 | 63 | # Frequency intervals 64 | print trace.cpu.frequency_intervals(cpu=0) 65 | ``` 66 | 67 | ### Android API examples 68 | ```python 69 | # Android events intervals. There are 3 types (sync context, async context and counters) 70 | print trace.android.event_intervals(name='postFramebuffer') # postFramebuffer events only. 71 | # Dump events seen 72 | print trace.android.names 73 | 74 | # Get launch-time for an app (assuming an app was launched during trace) 75 | print trace.android.app_launch_latency() 76 | ``` 77 | 78 | ### Clk API examples 79 | ```python 80 | # Dump clks seen 81 | print trace.clk.names 82 | # Clock intervals 83 | print trace.clk.frequency_intervals(clk='oxili_gfx3d_clk') # for Adreno GPU on Qualcomm Snapdragon 84 | ``` 85 | -------------------------------------------------------------------------------- /examples/frame_stats.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import os 3 | import sys 4 | import ftrace 5 | from ftrace import Ftrace, Interval 6 | from pandas import Series 7 | 8 | if __name__ == '__main__': 9 | 10 | parser = argparse.ArgumentParser(description='Per-core frequencies') 11 | parser.add_argument('-f', '--file', dest='file', 12 | help='File to parse') 13 | args = parser.parse_args() 14 | 15 | trace = Ftrace(args.file) 16 | 17 | frame_durations = Series((event.interval.duration for event in trace.android.render_frame_intervals(interval=None))) 18 | frame_durations = frame_durations * 1000. # to milliseconds 19 | summary = frame_durations.describe() 20 | summary['90%'] = frame_durations.quantile(.9) 21 | summary['Janks'] = trace.android.num_janks(interval=None) 22 | summary['Janks Per Second'] = summary['Janks']/trace.duration 23 | summary['Average FPS'] = trace.android.framerate(interval=None) 24 | summary.to_csv(r'frame_stats.csv') 25 | -------------------------------------------------------------------------------- /examples/parse_core_frequencies.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import ftrace 3 | from ftrace import Ftrace 4 | from pandas import DataFrame 5 | 6 | LITTLE_CLUSTER_MASK = 0x0F 7 | BIG_CLUSTER_MASK = 0xF0 8 | 9 | LITTLE_CPUS = ftrace.common.unpack_bitmap(LITTLE_CLUSTER_MASK) 10 | BIG_CPUS = ftrace.common.unpack_bitmap(BIG_CLUSTER_MASK) 11 | ALL_CPUS = LITTLE_CPUS.union(BIG_CPUS) 12 | 13 | parser = argparse.ArgumentParser(description='Per-core frequencies') 14 | 15 | parser.add_argument('-f', '--file', dest='file', 16 | help='File to parse') 17 | 18 | args = parser.parse_args() 19 | 20 | trace = Ftrace(args.file) 21 | 22 | df_freq = DataFrame( index = ALL_CPUS, columns=FREQ_ALL_CORES) 23 | df_freq.fillna(0, inplace=True) 24 | for cpu in ALL_CPUS: 25 | for busy_interval in trace.cpu.busy_intervals(cpu=cpu): 26 | for freq in trace.cpu.frequency_intervals(cpu=cpu, interval=busy_interval.interval): 27 | df_freq.loc[cpu, freq.frequency] += freq.interval.duration 28 | 29 | print df_freq -------------------------------------------------------------------------------- /examples/thermal_engine.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import os 3 | import sys 4 | from pandas import Series, DataFrame, MultiIndex, Timestamp 5 | from pandas.tseries.offsets import Micro 6 | import ftrace 7 | from ftrace import Ftrace, Interval 8 | 9 | 10 | THERMAL_TIMELINE_RESOLUTION = '200L' # Resample to this Milliseconds 11 | 12 | 13 | LITTLE_CLUSTER_MASK = 0x0F 14 | BIG_CLUSTER_MASK = 0xF0 15 | 16 | LITTLE_CPUS = ftrace.common.unpack_bitmap(LITTLE_CLUSTER_MASK) 17 | BIG_CPUS = ftrace.common.unpack_bitmap(BIG_CLUSTER_MASK) 18 | ALL_CPUS = LITTLE_CPUS.union(BIG_CPUS) 19 | 20 | # Valid for 8994 only. 21 | TSENS_ALIAS = { 22 | "tsens_tz_sensor2": "pop_mem", 23 | "tsens_tz_sensor6": "cpu7", 24 | "tsens_tz_sensor7": "cpu0", 25 | "tsens_tz_sensor8": "cpu1", 26 | "tsens_tz_sensor9": "cpu2", 27 | "tsens_tz_sensor10": "cpu3", 28 | "tsens_tz_sensor12": "gpu", 29 | "tsens_tz_sensor13": "cpu4", 30 | "tsens_tz_sensor14": "cpu5", 31 | "tsens_tz_sensor15": "cpu6", 32 | } 33 | 34 | CLKS =['a57_clk', 'a53_clk', 'oxili_gfx3d_clk'] 35 | 36 | start = Timestamp('1/1/1970') 37 | 38 | 39 | if __name__ == '__main__': 40 | 41 | trace = Ftrace(filepath, ['tsens_threshold_hit', 'tsens_read', 'tsens_threshold_clear', 'clock_set_rate']) 42 | 43 | # duration 44 | total_duration = trace.duration 45 | 46 | # Thermal 47 | NAMES = [TSENS_ALIAS[tsens] for tsens in trace.thermal.names if tsens in TSENS_ALIAS] + CLKS 48 | df_therm = DataFrame(columns=NAMES) 49 | for tsens in trace.thermal.names: 50 | for therm in trace.thermal.temp_intervals(tsens=tsens, interval=None): 51 | df_therm.loc[start + Micro(therm.interval.start*1e6), TSENS_ALIAS[tsens]] = therm.temp 52 | 53 | # lets look at clocks. 54 | for clk in CLKS: 55 | for freq_event in trace.clock.frequency_intervals(clock=clk, interval=None): 56 | i_start=start + Micro(freq_event.interval.start*1e6) 57 | i_end=start + Micro(freq_event.interval.end*1e6) 58 | try: 59 | df_therm.loc[i_start:i_end, clk] = freq_event.frequency 60 | except KeyError: 61 | print "Error logging " + str(freq_event) 62 | df_therm[start + Micro(freq_event.interval.start*1e6):start + Micro(freq_event.interval.end*1e6), clk] = freq_event.frequency 63 | for clk_event in trace.clock.clock_intervals(clock=clk, state=ftrace.clock.ClockState.DISABLED, interval=None): 64 | df_therm.loc[start + Micro(clk_event.interval.start*1e6): start + Micro(clk_event.interval.end*1e6), clk] = 0 65 | 66 | df_therm.sort(inplace=True) 67 | df_therm = df_therm.asfreq(THERMAL_TIMELINE_RESOLUTION, method='ffill').fillna(method='ffill').fillna(-1) 68 | df_therm.to_csv(r'thermal_timeline.csv') 69 | -------------------------------------------------------------------------------- /ftrace/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | # This is *not* a place to dump arbitrary classes/modules for convenience, 22 | # it is a place to expose the public interfaces. 23 | 24 | from . parsers import PARSERS 25 | from . interval import Interval 26 | from . task import Task 27 | from . event import Event, EventList 28 | from . interval import Interval, IntervalList 29 | from . task import Task 30 | from . event import Event 31 | from . components import * 32 | from . ftrace import Ftrace 33 | 34 | __all__ = ['Ftrace', 'Interval', 'Task', 'EventList', 'IntervalList'] -------------------------------------------------------------------------------- /ftrace/atrace.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | """ 22 | AtraceTag: Atrace tags 23 | """ 24 | from .common import ConstantBase 25 | 26 | # See system/core/include/cutils/trace.h 27 | # For non-async context 28 | # tracing_mark_write: B|pid|section_name (non-async) 29 | # tracing_mark_write: E 30 | 31 | # For async event tracing start/finish 32 | # tracing_mark_write: S|pid|section_name|cookie 33 | # tracing_mark_write: F|pid|section_name|cookie 34 | 35 | # For counter event 36 | # tracing_mark_write: C|pid|counter_name|value (non-async) 37 | 38 | class AtraceTag(ConstantBase): 39 | CONTEXT_BEGIN = () 40 | CONTEXT_END = () 41 | ASYNC_BEGIN = () 42 | ASYNC_END = () 43 | COUNTER = () 44 | 45 | AtraceTagMapping = { 46 | 'B': AtraceTag.CONTEXT_BEGIN, 47 | 'S': AtraceTag.ASYNC_BEGIN, 48 | 'E': AtraceTag.CONTEXT_END, 49 | 'F': AtraceTag.ASYNC_END, 50 | 'C': AtraceTag.COUNTER 51 | } 52 | -------------------------------------------------------------------------------- /ftrace/audio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | """ 22 | GlitchType: Possible glitch types. 23 | """ 24 | from .common import ConstantBase 25 | 26 | class GlitchType(ConstantBase): 27 | UNDERRUN_FULL = () # framesReady() is full frame count, no underrun 28 | UNDERRUN_PARTIAL = () # framesReady() is non-zero but < full frame count 29 | UNDERRUN_EMPTY = () # framesReady() is zero, total underrun 30 | OVERRUN = () 31 | UNKNOWN = () 32 | 33 | @classmethod 34 | def underruns(cls): 35 | return [cls.UNDERRUN_PARTIAL, cls.UNDERRUN_EMPTY] -------------------------------------------------------------------------------- /ftrace/components/__init__.py: -------------------------------------------------------------------------------- 1 | from .cpu import CPU 2 | from .gpu import GPU 3 | from .clock import Clock 4 | from .cluster import Cluster 5 | from .android import Android 6 | from .disk import Disk 7 | from .camera import Camera 8 | from .audio import Audio 9 | from .thermal import Thermal 10 | from .bus import Bus -------------------------------------------------------------------------------- /ftrace/composites.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import heapq 22 | from .event import EventList 23 | from .interval import IntervalList 24 | from .common import FtraceError 25 | 26 | def _decorate_items(iterable): 27 | 28 | if isinstance(iterable, EventList): 29 | for item in iterable: 30 | yield (item.timestamp, item) 31 | elif isinstance(iterable, IntervalList): 32 | for item in iterable: 33 | yield (item.interval.start, item) 34 | else: 35 | raise FtraceError(msg='Unsupported iterable: {}'.format(type(iterable))) 36 | 37 | def sorted_items(iterables): 38 | sorted_iterable = heapq.merge(*(_decorate_items(s) for s in iterables)) 39 | 40 | for _, item in sorted_iterable: 41 | yield item -------------------------------------------------------------------------------- /ftrace/globals.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | 22 | # Required for Task Load Esimation in Qualcomm's HMP scheduler 23 | # check "adb shell cat /proc/cmdline | grep sched_ravg_window" 24 | SCHED_RAVG_WINDOW = 10000000 -------------------------------------------------------------------------------- /ftrace/io.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | """ 22 | DiskIOType: Possible disk I/Os 23 | DiskCommand: Disk commands 24 | """ 25 | from collections import namedtuple 26 | from .common import ConstantBase 27 | 28 | 29 | class DiskIOType(ConstantBase): 30 | DISCARD = () 31 | WRITE = () 32 | READ = () 33 | NONE = () 34 | 35 | class DiskCommand(ConstantBase): 36 | FUA = () # Forced Unit Access 37 | AHEAD = () 38 | SYNC = () 39 | META = () 40 | FLUSH = () 41 | 42 | DiskIOTypeMapping = { 43 | 'D': DiskIOType.DISCARD, 44 | 'W': DiskIOType.WRITE, 45 | 'R': DiskIOType.READ, 46 | 'N': DiskIOType.NONE, 47 | } 48 | 49 | 50 | DiskCommandMapping = { 51 | 'F': DiskCommand.FUA, 52 | 'A': DiskCommand.AHEAD, 53 | 'S': DiskCommand.SYNC, 54 | 'M': DiskCommand.META 55 | } 56 | 57 | RWBS = namedtuple('RWBS', ['io_type', 'commands']) -------------------------------------------------------------------------------- /ftrace/parsers/binder_command.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_command' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_command: cmd=0x40046303 BC_FREE_BUFFER 12 | 13 | BinderCommandBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'cmd', 16 | 'mode', 17 | 'result' 18 | ] 19 | ) 20 | 21 | class BinderCommand(BinderCommandBase): 22 | __slots__ = () 23 | def __new__(cls, cmd, result): 24 | 25 | (cmd, mode) = parse_binder_cmd (int (cmd, base=16)) 26 | 27 | # Decoded command and text output must be consistent 28 | if cmd != result: 29 | return "Invalid command (%s != %s)" % (cmd, result) 30 | 31 | return super(cls, BinderCommand).__new__( 32 | cls, 33 | cmd=cmd, 34 | mode=mode, 35 | result=result 36 | ) 37 | 38 | binder_command_pattern = re.compile( 39 | r""" 40 | cmd=(0x[0-9a-f]+)\s+ 41 | BC_([A-Z_]+) 42 | """, 43 | re.X|re.M 44 | ) 45 | 46 | @register_parser 47 | def binder_command(payload): 48 | """Parser for `binder_command`""" 49 | try: 50 | match = re.match(binder_command_pattern, payload) 51 | if match: 52 | match_group_dict = match.groupdict() 53 | return BinderCommand(match.group(1), match.group(2)) 54 | except Exception as e: 55 | raise ParserError(e.message) 56 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_ioctl.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_ioctl' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_ioctl: cmd=0xc0186201 arg=0xbea7dc28 12 | 13 | BinderIoctlBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'cmd', 16 | 'mode', 17 | 'arg', 18 | ] 19 | ) 20 | 21 | class BinderIoctl(BinderIoctlBase): 22 | __slots__ = () 23 | def __new__(cls, cmd, arg): 24 | 25 | (cmd, mode) = parse_binder_cmd (int(cmd, base=16)) 26 | arg = int(arg, base=16) 27 | 28 | return super(cls, BinderIoctl).__new__( 29 | cls, 30 | cmd=cmd, 31 | mode=mode, 32 | arg=hex(arg), 33 | ) 34 | 35 | binder_ioctl_pattern = re.compile( 36 | r""" 37 | cmd=(0x[0-9a-f]+)\s+ 38 | arg=(0x[0-9a-f]+) 39 | """, 40 | re.X|re.M 41 | ) 42 | 43 | @register_parser 44 | def binder_ioctl(payload): 45 | """Parser for `binder_ioctl`""" 46 | try: 47 | match = re.match(binder_ioctl_pattern, payload) 48 | if match: 49 | match_group_dict = match.groupdict() 50 | return BinderIoctl(match.group(1), match.group(2)) 51 | except Exception as e: 52 | raise ParserError(e.message) 53 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_ioctl_done.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_ioctl_done' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_ioctl_done: ret=0 12 | 13 | BinderIoctlDoneBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'ret' 16 | ] 17 | ) 18 | 19 | class BinderIoctlDone(BinderIoctlDoneBase): 20 | __slots__ = () 21 | def __new__(cls, ret): 22 | 23 | return super(cls, BinderIoctlDone).__new__( 24 | cls, 25 | ret=ret 26 | ) 27 | 28 | binder_ioctl_done_pattern = re.compile( 29 | r""" 30 | ret=(\d+) 31 | """, 32 | re.X|re.M 33 | ) 34 | 35 | @register_parser 36 | def binder_ioctl_done(payload): 37 | """Parser for `binder_ioctl_done`""" 38 | try: 39 | match = re.match(binder_ioctl_done_pattern, payload) 40 | if match: 41 | match_group_dict = match.groupdict() 42 | return BinderIoctlDone(int(match.group(1))) 43 | except Exception as e: 44 | raise ParserError(e.message) 45 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_lock.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from collections import namedtuple 5 | 6 | TRACEPOINT = 'binder_lock' 7 | 8 | __all__ = [TRACEPOINT] 9 | 10 | #binder_lock: tag=binder_ioctl 11 | 12 | BinderLockBase = namedtuple(TRACEPOINT, 13 | [ 14 | 'tag' 15 | ] 16 | ) 17 | 18 | class BinderLock(BinderLockBase): 19 | __slots__ = () 20 | def __new__(cls, tag): 21 | return super(cls, BinderLock).__new__( 22 | cls, 23 | tag=tag 24 | ) 25 | 26 | binder_lock_pattern = re.compile( 27 | r""" 28 | tag=([^\s]+) 29 | """, 30 | re.X|re.M 31 | ) 32 | 33 | @register_parser 34 | def binder_lock(payload): 35 | """Parser for `binder_lock`""" 36 | try: 37 | match = re.match(binder_lock_pattern, payload) 38 | if match: 39 | match_group_dict = match.groupdict() 40 | return BinderLock(match.group(1)) 41 | except Exception as e: 42 | raise ParserError(e.message) 43 | 44 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_locked.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from collections import namedtuple 5 | 6 | TRACEPOINT = 'binder_locked' 7 | 8 | __all__ = [TRACEPOINT] 9 | 10 | #binder_locked: tag=binder_ioctl 11 | 12 | BinderLockedBase = namedtuple(TRACEPOINT, 13 | [ 14 | 'tag' 15 | ] 16 | ) 17 | 18 | class BinderLocked(BinderLockedBase): 19 | __slots__ = () 20 | def __new__(cls, tag): 21 | return super(cls, BinderLocked).__new__( 22 | cls, 23 | tag=tag 24 | ) 25 | 26 | binder_locked_pattern = re.compile( 27 | r""" 28 | tag=([^\s]+) 29 | """, 30 | re.X|re.M 31 | ) 32 | 33 | @register_parser 34 | def binder_locked(payload): 35 | """Parser for `binder_locked`""" 36 | try: 37 | match = re.match(binder_locked_pattern, payload) 38 | if match: 39 | match_group_dict = match.groupdict() 40 | return BinderLocked(match.group(1)) 41 | except Exception as e: 42 | raise ParserError(e.message) 43 | 44 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_read_done.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_read_done' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_read_done: ret=0 12 | 13 | BinderReadDoneBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'ret' 16 | ] 17 | ) 18 | 19 | class BinderReadDone(BinderReadDoneBase): 20 | __slots__ = () 21 | def __new__(cls, ret): 22 | 23 | return super(cls, BinderReadDone).__new__( 24 | cls, 25 | ret=ret 26 | ) 27 | 28 | binder_read_done_pattern = re.compile( 29 | r""" 30 | ret=(\d+) 31 | """, 32 | re.X|re.M 33 | ) 34 | 35 | @register_parser 36 | def binder_read_done(payload): 37 | """Parser for `binder_read_done`""" 38 | try: 39 | match = re.match(binder_read_done_pattern, payload) 40 | if match: 41 | match_group_dict = match.groupdict() 42 | return BinderReadDone(int(match.group(1))) 43 | except Exception as e: 44 | raise ParserError(e.message) 45 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_return.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_return' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_return: cmd=0x80287203 BR_REPLY 12 | 13 | BinderReturnBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'cmd', 16 | 'mode', 17 | 'result', 18 | ] 19 | ) 20 | 21 | class BinderReturn(BinderReturnBase): 22 | __slots__ = () 23 | def __new__(cls, cmd, result): 24 | 25 | (cmd, mode) = parse_binder_cmd (int (cmd, base=16)) 26 | 27 | return super(cls, BinderReturn).__new__( 28 | cls, 29 | cmd=cmd, 30 | mode=mode, 31 | result=result 32 | ) 33 | 34 | binder_return_pattern = re.compile( 35 | r""" 36 | cmd=(0x[0-9a-f]+)\s+ 37 | BR_([A-Z]+) 38 | """, 39 | re.X|re.M 40 | ) 41 | 42 | @register_parser 43 | def binder_return(payload): 44 | """Parser for `binder_return`""" 45 | try: 46 | match = re.match(binder_return_pattern, payload) 47 | if match: 48 | match_group_dict = match.groupdict() 49 | return BinderReturn(match.group(1), match.group(2)) 50 | except Exception as e: 51 | raise ParserError(e.message) 52 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_transaction.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_transaction' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_transaction: transaction=135931 dest_node=133235 dest_proc=280 dest_thread=0 reply=0 flags=0x10 code=0x2 12 | 13 | BinderTransactionBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'transaction', 16 | 'dest_node', 17 | 'dest_proc', 18 | 'dest_thread', 19 | 'reply', 20 | 'flags', 21 | 'code' 22 | ] 23 | ) 24 | 25 | def decode_transaction_flags (flags): 26 | 27 | result = set() 28 | 29 | # this is a one-way call: async, no return 30 | if flags & 0x01: result.add ('TF_ONE_WAY') 31 | 32 | # contents are the component's root object 33 | if flags & 0x04: result.add ('TF_ROOT_OBJECT') 34 | 35 | # contents are a 32-bit status code 36 | if flags & 0x08: result.add ('TF_STATUS_CODE') 37 | 38 | # allow replies with file descriptors 39 | if flags & 0x10: result.add ('TF_ACCEPT_FDS') 40 | 41 | # Check for missing flags 42 | remain = flags & 0xffffffe2 43 | if remain: result.add ('UNKNOWN_FLAGS_%x' % remain) 44 | 45 | return result 46 | 47 | 48 | class BinderTransaction(BinderTransactionBase): 49 | __slots__ = () 50 | def __new__(cls, transaction, dest_node, dest_proc, dest_thread, reply, flags, code): 51 | 52 | return super(cls, BinderTransaction).__new__( 53 | cls, 54 | transaction=transaction, 55 | dest_node=dest_node, 56 | dest_proc=dest_proc, 57 | dest_thread=dest_thread, 58 | reply=reply, 59 | flags=flags, 60 | code=code 61 | ) 62 | 63 | binder_transaction_pattern = re.compile( 64 | r""" 65 | transaction=(\d+)\s+ 66 | dest_node=(\d+)\s+ 67 | dest_proc=(\d+)\s+ 68 | dest_thread=(\d+)\s+ 69 | reply=(\d+)\s+ 70 | flags=(0x[0-9a-f]+)\s+ 71 | code=(0x[0-9a-f]+) 72 | """, 73 | re.X|re.M 74 | ) 75 | 76 | @register_parser 77 | def binder_transaction(payload): 78 | """Parser for `binder_transaction`""" 79 | try: 80 | match = re.match(binder_transaction_pattern, payload) 81 | if match: 82 | match_group_dict = match.groupdict() 83 | return BinderTransaction(int(match.group(1)), 84 | int(match.group(2)), 85 | int(match.group(3)), 86 | int(match.group(4)), 87 | int(match.group(5)), 88 | decode_transaction_flags (int(match.group(6), base=16)), 89 | int(match.group(7), base=16)) 90 | except Exception as e: 91 | raise ParserError(e.message) 92 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_transaction_alloc_buf.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_transaction_alloc_buf' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_transaction_alloc_buf: transaction=135931 data_size=96 offsets_size=0 12 | 13 | BinderTransactionAllocBufBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'transaction', 16 | 'data_size', 17 | 'offsets_size' 18 | ] 19 | ) 20 | 21 | class BinderTransactionAllocBuf(BinderTransactionAllocBufBase): 22 | __slots__ = () 23 | def __new__(cls, transaction, data_size, offsets_size): 24 | 25 | return super(cls, BinderTransactionAllocBuf).__new__( 26 | cls, 27 | transaction=transaction, 28 | data_size=data_size, 29 | offsets_size=offsets_size 30 | ) 31 | 32 | binder_transaction_alloc_buf_pattern = re.compile( 33 | r""" 34 | transaction=(\d+)\s+ 35 | data_size=(\d+)\s+ 36 | offsets_size=(\d+) 37 | """, 38 | re.X|re.M 39 | ) 40 | 41 | @register_parser 42 | def binder_transaction_alloc_buf(payload): 43 | """Parser for `binder_transaction_alloc_buf`""" 44 | try: 45 | match = re.match(binder_transaction_alloc_buf_pattern, payload) 46 | if match: 47 | match_group_dict = match.groupdict() 48 | return BinderTransactionAllocBuf(int(match.group(1)), int(match.group(2)), int(match.group(3))) 49 | except Exception as e: 50 | raise ParserError(e.message) 51 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_transaction_buffer_release.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_transaction_buffer_release' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_transaction_buffer_release: transaction=135918 data_size=28 offsets_size=0 12 | 13 | BinderTransactionBufferReleaseBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'transaction', 16 | 'data_size', 17 | 'offsets_size' 18 | ] 19 | ) 20 | 21 | class BinderTransactionBufferRelease(BinderTransactionBufferReleaseBase): 22 | __slots__ = () 23 | def __new__(cls, transaction, data_size, offsets_size): 24 | 25 | return super(cls, BinderTransactionBufferRelease).__new__( 26 | cls, 27 | transaction=transaction, 28 | data_size=data_size, 29 | offsets_size=offsets_size 30 | ) 31 | 32 | binder_transaction_buffer_release_pattern = re.compile( 33 | r""" 34 | transaction=(\d+)\s+ 35 | data_size=(\d+)\s+ 36 | offsets_size=(\d+) 37 | """, 38 | re.X|re.M 39 | ) 40 | 41 | @register_parser 42 | def binder_transaction_buffer_release(payload): 43 | """Parser for `binder_transaction_buffer_release`""" 44 | try: 45 | match = re.match(binder_transaction_buffer_release_pattern, payload) 46 | if match: 47 | match_group_dict = match.groupdict() 48 | return BinderTransactionBufferRelease(int(match.group(1)), int(match.group(2)), int(match.group(3))) 49 | except Exception as e: 50 | raise ParserError(e.message) 51 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_transaction_fd.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_transaction_fd' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_transaction_fd: transaction=135945 src_fd=63 ==> dest_fd=30 12 | 13 | BinderTransactionFdBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'transaction', 16 | 'src_fd', 17 | 'dest_fd' 18 | ] 19 | ) 20 | 21 | class BinderTransactionFd(BinderTransactionFdBase): 22 | __slots__ = () 23 | def __new__(cls, transaction, src_fd, dest_fd): 24 | 25 | return super(cls, BinderTransactionFd).__new__( 26 | cls, 27 | transaction=transaction, 28 | src_fd=src_fd, 29 | dest_fd=dest_fd 30 | ) 31 | 32 | binder_transaction_fd_pattern = re.compile( 33 | r""" 34 | transaction=(\d+)\s+ 35 | src_fd=(\d+)\s+ 36 | ==>\s+ 37 | dest_fd=(\d+) 38 | """, 39 | re.X|re.M 40 | ) 41 | 42 | @register_parser 43 | def binder_transaction_fd(payload): 44 | """Parser for `binder_transaction_fd`""" 45 | try: 46 | match = re.match(binder_transaction_fd_pattern, payload) 47 | if match: 48 | match_group_dict = match.groupdict() 49 | return BinderTransactionFd(int(match.group(1)), 50 | int(match.group(2)), 51 | int(match.group(3))) 52 | except Exception as e: 53 | raise ParserError(e.message) 54 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_transaction_node_to_ref.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_transaction_node_to_ref' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_transaction_node_to_ref: transaction=136064 node=135403 src_ptr=0x00000000b2eacc40 ==> dest_ref=135404 dest_desc=525 12 | 13 | BinderTransactionNodeToRefBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'transaction', 16 | 'node', 17 | 'src_ptr', 18 | 'dest_ref', 19 | 'dest_desc' 20 | ] 21 | ) 22 | 23 | class BinderTransactionNodeToRef(BinderTransactionNodeToRefBase): 24 | __slots__ = () 25 | def __new__(cls, transaction, node, src_ptr, dest_ref, dest_desc): 26 | 27 | return super(cls, BinderTransactionNodeToRef).__new__( 28 | cls, 29 | transaction=transaction, 30 | node=node, 31 | src_ptr=src_ptr, 32 | dest_ref=dest_ref, 33 | dest_desc=dest_desc 34 | ) 35 | 36 | binder_transaction_node_to_ref_pattern = re.compile( 37 | r""" 38 | transaction=(\d+)\s+ 39 | node=(\d+)\s+ 40 | src_ptr=(0x[0-9a-f]+)\s+ 41 | ==>\s+ 42 | dest_ref=(\d+)\s+ 43 | dest_desc=(\d+) 44 | """, 45 | re.X|re.M 46 | ) 47 | 48 | @register_parser 49 | def binder_transaction_node_to_ref(payload): 50 | """Parser for `binder_transaction_node_to_ref`""" 51 | try: 52 | match = re.match(binder_transaction_node_to_ref_pattern, payload) 53 | if match: 54 | match_group_dict = match.groupdict() 55 | return BinderTransactionNodeToRef(int(match.group(1)), 56 | int(match.group(2)), 57 | int(match.group(3), base=16), 58 | int(match.group(4)), 59 | int(match.group(5))) 60 | except Exception as e: 61 | raise ParserError(e.message) 62 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_transaction_received.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_transaction_received' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_transaction_received: transaction=135934 12 | 13 | BinderTransactionReceivedBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'transaction', 16 | ] 17 | ) 18 | 19 | class BinderTransactionReceived(BinderTransactionReceivedBase): 20 | __slots__ = () 21 | def __new__(cls, transaction): 22 | 23 | return super(cls, BinderTransactionReceived).__new__( 24 | cls, 25 | transaction=transaction 26 | ) 27 | 28 | binder_transaction_received_pattern = re.compile( 29 | r""" 30 | transaction=(\d+) 31 | """, 32 | re.X|re.M 33 | ) 34 | 35 | @register_parser 36 | def binder_transaction_received(payload): 37 | """Parser for `binder_transaction_received`""" 38 | try: 39 | match = re.match(binder_transaction_received_pattern, payload) 40 | if match: 41 | match_group_dict = match.groupdict() 42 | return BinderTransactionReceived(int(match.group(1))) 43 | except Exception as e: 44 | raise ParserError(e.message) 45 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_transaction_ref_to_node.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_transaction_ref_to_node' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_transaction_ref_to_node: transaction=135943 node=135186 src_ref=135187 src_desc=27 ==> dest_ptr=0x00000000941a4840 12 | 13 | BinderTransactionRefToNodeBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'transaction', 16 | 'node', 17 | 'src_ref', 18 | 'src_desc', 19 | 'dest_ptr' 20 | ] 21 | ) 22 | 23 | class BinderTransactionRefToNode(BinderTransactionRefToNodeBase): 24 | __slots__ = () 25 | def __new__(cls, transaction, node, src_ref, src_desc, dest_ptr): 26 | 27 | return super(cls, BinderTransactionRefToNode).__new__( 28 | cls, 29 | transaction=transaction, 30 | node=node, 31 | src_ref=src_ref, 32 | src_desc=src_desc, 33 | dest_ptr=dest_ptr 34 | ) 35 | 36 | binder_transaction_ref_to_node_pattern = re.compile( 37 | r""" 38 | transaction=(\d+)\s+ 39 | node=(\d+)\s+ 40 | src_ref=(\d+)\s+ 41 | src_desc=(\d+)\s+ 42 | ==>\s+ 43 | dest_ptr=(0x[0-9a-f]+) 44 | """, 45 | re.X|re.M 46 | ) 47 | 48 | @register_parser 49 | def binder_transaction_ref_to_node(payload): 50 | """Parser for `binder_transaction_ref_to_node`""" 51 | try: 52 | match = re.match(binder_transaction_ref_to_node_pattern, payload) 53 | if match: 54 | match_group_dict = match.groupdict() 55 | return BinderTransactionRefToNode(int(match.group(1)), 56 | int(match.group(2)), 57 | int(match.group(3)), 58 | int(match.group(4)), 59 | int(match.group(5), base=16)) 60 | except Exception as e: 61 | raise ParserError(e.message) 62 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_transaction_ref_to_ref.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_transaction_ref_to_ref' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_transaction_ref_to_ref: transaction=136308 node=11089 src_ref=11090 src_desc=121 ==> dest_ref=136262 dest_desc=549 12 | 13 | BinderTransactionRefToRefBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'transaction', 16 | 'node', 17 | 'src_ref', 18 | 'src_desc', 19 | 'dest_ref', 20 | 'dest_desc' 21 | ] 22 | ) 23 | 24 | class BinderTransactionRefToRef(BinderTransactionRefToRefBase): 25 | __slots__ = () 26 | def __new__(cls, transaction, node, src_ref, src_desc, dest_ref, dest_desc): 27 | 28 | return super(cls, BinderTransactionRefToRef).__new__( 29 | cls, 30 | transaction=transaction, 31 | node=node, 32 | src_ref=src_ref, 33 | src_desc=src_desc, 34 | dest_ref=dest_ref, 35 | dest_desc=dest_desc 36 | ) 37 | 38 | binder_transaction_ref_to_ref_pattern = re.compile( 39 | r""" 40 | transaction=(\d+)\s+ 41 | node=(\d+)\s+ 42 | src_ref=(\d+)\s+ 43 | src_desc=(\d+)\s+ 44 | ==>\s+ 45 | dest_ref=(\d+)\s+ 46 | dest_desc=(\d+) 47 | """, 48 | re.X|re.M 49 | ) 50 | 51 | @register_parser 52 | def binder_transaction_ref_to_ref(payload): 53 | """Parser for `binder_transaction_ref_to_ref`""" 54 | try: 55 | match = re.match(binder_transaction_ref_to_ref_pattern, payload) 56 | if match: 57 | match_group_dict = match.groupdict() 58 | return BinderTransactionRefToRef(int(match.group(1)), 59 | int(match.group(2)), 60 | int(match.group(3)), 61 | int(match.group(4)), 62 | int(match.group(5)), 63 | int(match.group(6))) 64 | except Exception as e: 65 | raise ParserError(e.message) 66 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_unlock.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from collections import namedtuple 5 | 6 | TRACEPOINT = 'binder_unlock' 7 | 8 | __all__ = [TRACEPOINT] 9 | 10 | #binder_unlock: tag=binder_ioctl 11 | 12 | BinderUnlockBase = namedtuple(TRACEPOINT, 13 | [ 14 | 'tag' 15 | ] 16 | ) 17 | 18 | class BinderUnlock(BinderUnlockBase): 19 | __slots__ = () 20 | def __new__(cls, tag): 21 | return super(cls, BinderUnlock).__new__( 22 | cls, 23 | tag=tag 24 | ) 25 | 26 | binder_unlock_pattern = re.compile( 27 | r""" 28 | tag=([^\s]+) 29 | """, 30 | re.X|re.M 31 | ) 32 | 33 | @register_parser 34 | def binder_unlock(payload): 35 | """Parser for `binder_unlock`""" 36 | try: 37 | match = re.match(binder_unlock_pattern, payload) 38 | if match: 39 | match_group_dict = match.groupdict() 40 | return BinderUnlock(match.group(1)) 41 | except Exception as e: 42 | raise ParserError(e.message) 43 | 44 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_update_page_range.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_update_page_range' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_update_page_range: proc=3624 allocate=1 offset=4096 size=8192 12 | 13 | BinderUpdatePageRangeBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'proc', 16 | 'allocate', 17 | 'offset', 18 | 'size' 19 | ] 20 | ) 21 | 22 | class BinderUpdatePageRange(BinderUpdatePageRangeBase): 23 | __slots__ = () 24 | def __new__(cls, proc, allocate, offset, size): 25 | 26 | return super(cls, BinderUpdatePageRange).__new__( 27 | cls, 28 | proc=proc, 29 | allocate=allocate, 30 | offset=offset, 31 | size=size 32 | ) 33 | 34 | binder_update_page_range_pattern = re.compile( 35 | r""" 36 | proc=(\d+)\s+ 37 | allocate=(\d+)\s+ 38 | offset=(\d+)\s+ 39 | size=(\d+) 40 | """, 41 | re.X|re.M 42 | ) 43 | 44 | @register_parser 45 | def binder_update_page_range(payload): 46 | """Parser for `binder_update_page_range`""" 47 | try: 48 | match = re.match(binder_update_page_range_pattern, payload) 49 | if match: 50 | match_group_dict = match.groupdict() 51 | return BinderUpdatePageRange(int(match.group(1)), int(match.group(2)), int(match.group(3)), int(match.group(4))) 52 | except Exception as e: 53 | raise ParserError(e.message) 54 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_wait_for_work.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_wait_for_work' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_wait_for_work: proc_work=0 transaction_stack=1 thread_todo=0 12 | 13 | BinderWaitForWorkBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'proc_work', 16 | 'transaction_stack', 17 | 'thread_todo' 18 | ] 19 | ) 20 | 21 | class BinderWaitForWork(BinderWaitForWorkBase): 22 | __slots__ = () 23 | def __new__(cls, proc_work, transaction_stack, thread_todo): 24 | 25 | return super(cls, BinderWaitForWork).__new__( 26 | cls, 27 | proc_work=proc_work, 28 | transaction_stack=transaction_stack, 29 | thread_todo=thread_todo 30 | ) 31 | 32 | binder_wait_for_work_pattern = re.compile( 33 | r""" 34 | proc_work=(\d+)\s+ 35 | transaction_stack=(\d+)\s+ 36 | thread_todo=(\d+) 37 | """, 38 | re.X|re.M 39 | ) 40 | 41 | @register_parser 42 | def binder_wait_for_work(payload): 43 | """Parser for `binder_wait_for_work`""" 44 | try: 45 | match = re.match(binder_wait_for_work_pattern, payload) 46 | if match: 47 | match_group_dict = match.groupdict() 48 | return BinderWaitForWork(int(match.group(1)), int(match.group(2)), int(match.group(3))) 49 | except Exception as e: 50 | raise ParserError(e.message) 51 | -------------------------------------------------------------------------------- /ftrace/parsers/binder_write_done.py: -------------------------------------------------------------------------------- 1 | import re 2 | from ftrace.common import ParserError 3 | from .register import register_parser 4 | from .binder import parse_binder_cmd 5 | from collections import namedtuple 6 | 7 | TRACEPOINT = 'binder_write_done' 8 | 9 | __all__ = [TRACEPOINT] 10 | 11 | #binder_write_done: ret=0 12 | 13 | BinderWriteDoneBase = namedtuple(TRACEPOINT, 14 | [ 15 | 'ret' 16 | ] 17 | ) 18 | 19 | class BinderWriteDone(BinderWriteDoneBase): 20 | __slots__ = () 21 | def __new__(cls, ret): 22 | 23 | return super(cls, BinderWriteDone).__new__( 24 | cls, 25 | ret=ret 26 | ) 27 | 28 | binder_write_done_pattern = re.compile( 29 | r""" 30 | ret=(\d+) 31 | """, 32 | re.X|re.M 33 | ) 34 | 35 | @register_parser 36 | def binder_write_done(payload): 37 | """Parser for `binder_write_done`""" 38 | try: 39 | match = re.match(binder_write_done_pattern, payload) 40 | if match: 41 | match_group_dict = match.groupdict() 42 | return BinderWriteDone(int(match.group(1))) 43 | except Exception as e: 44 | raise ParserError(e.message) 45 | -------------------------------------------------------------------------------- /ftrace/parsers/block_rq_complete.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from ftrace.io import DiskCommand, DiskIOTypeMapping, DiskCommandMapping, RWBS 24 | from .register import register_parser 25 | from collections import namedtuple 26 | #from ftrace.third_party.cnamedtuple import namedtuple 27 | 28 | TRACEPOINT = 'block_rq_complete' 29 | 30 | 31 | __all__ = [TRACEPOINT] 32 | 33 | #block IO operation completed by device driver 34 | #block_rq_complete: 179,0 WASM () 6455304 + 8 [0] 35 | BlockRQCompleteBase = namedtuple(TRACEPOINT, 36 | [ 37 | 'dev_major', 38 | 'dev_minor', 39 | 'sector', 40 | 'nr_sector', 41 | 'cmd', 42 | 'errors', 43 | 'rwbs', 44 | ] 45 | ) 46 | 47 | class BlockRQComplete(BlockRQCompleteBase): 48 | __slots__ = () 49 | def __new__(cls, dev_major, dev_minor, sector, nr_sector, cmd, errors, rwbs): 50 | dev_major = int(dev_major) 51 | dev_minor = int(dev_minor) 52 | sector=int(sector) 53 | nr_sector=int(nr_sector) 54 | errors=int(errors) 55 | 56 | return super(cls, BlockRQComplete).__new__( 57 | cls, 58 | dev_major=dev_major, 59 | dev_minor=dev_minor, 60 | sector=sector, 61 | nr_sector=nr_sector, 62 | errors=errors, 63 | cmd=cmd, 64 | rwbs=rwbs, 65 | ) 66 | 67 | block_rq_complete_pattern = re.compile( 68 | r""" 69 | (?P\d+), 70 | (?P\d+)\s+ 71 | (?P\w+)\s+ 72 | \((?P.*)\)\s+ 73 | (?P\d+)\s+\+\s+ 74 | (?P\d+)\s+ 75 | \[(?P\d+)\] 76 | """, 77 | re.X|re.M 78 | ) 79 | 80 | @register_parser 81 | def block_rq_complete(payload): 82 | """Parser for `block_rq_complete` tracepoint""" 83 | try: 84 | match = re.match(block_rq_complete_pattern, payload) 85 | if match: 86 | match_group_dict = match.groupdict() 87 | rwbs_command = match_group_dict['rwbs'] 88 | io_type=DiskIOTypeMapping[rwbs_command[0]] 89 | commands = set(DiskCommandMapping[c] for c in rwbs_command[1:]) 90 | match_group_dict['rwbs'] = RWBS(io_type=io_type, commands=commands) 91 | return BlockRQComplete(**match_group_dict) 92 | except Exception, e: 93 | raise ParserError(e.message) 94 | -------------------------------------------------------------------------------- /ftrace/parsers/bus_update_request.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'bus_update_request' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | #bus_update_request: time= 15618.608339249 name=sdhc1 index=6 src=78 dest=512 ab=400000000 ib=800000000 33 | 34 | BusUpdateRequestBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'timestamp', 37 | 'name', 38 | 'src', 39 | 'dest', 40 | 'ab', # average bw 41 | 'ib', # instantenous bw 42 | 'active', 43 | ] 44 | ) 45 | 46 | class BusUpdateRequest(BusUpdateRequestBase): 47 | __slots__ = () 48 | def __new__(cls, timestamp, name, src, dest, ab, ib, active): 49 | timestamp = float(timestamp) 50 | src = int(src) 51 | dest = int(dest) 52 | ab = float(ab) 53 | ib = float(ib) 54 | active = int(active) 55 | 56 | return super(cls, BusUpdateRequest).__new__( 57 | cls, 58 | timestamp=timestamp, 59 | name=name, 60 | src=src, 61 | dest=dest, 62 | ab=ab, 63 | ib=ib, 64 | active=active, 65 | ) 66 | 67 | bus_update_request_pattern = re.compile( 68 | r""" 69 | time[=|:](?P.+)\s+ 70 | name[=|:](?P.+)\s+ 71 | src[=|:](?P\d+)\s+ 72 | dest[=|:](?P\d+)\s+ 73 | ab[=|:](?P\d+)\s+ 74 | ib[=|:](?P\d+)\s+ 75 | active[=|:](?P\d+) 76 | """, 77 | re.X|re.M 78 | ) 79 | 80 | @register_parser 81 | def bus_update_request(payload): 82 | """Parser for `bus_update_request` tracepoint""" 83 | try: 84 | match = re.match(bus_update_request_pattern, payload) 85 | if match: 86 | match_group_dict = match.groupdict() 87 | return BusUpdateRequest(**match_group_dict) 88 | except Exception, e: 89 | raise ParserError(e.message) 90 | -------------------------------------------------------------------------------- /ftrace/parsers/clock_disable.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'clock_disable' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | 33 | ClockDisableBase = namedtuple(TRACEPOINT, 34 | [ 35 | 'clk', # Clock name 36 | 'state', # Frequency 37 | 'cpu_id', # Target cpu 38 | ] 39 | ) 40 | 41 | class ClockDisable(ClockDisableBase): 42 | __slots__ = () 43 | def __new__(cls, clk, state, cpu_id): 44 | state = int(state) 45 | cpu_id = int(cpu_id) 46 | 47 | return super(cls, ClockDisable).__new__( 48 | cls, 49 | clk=clk, 50 | state=state, 51 | cpu_id=cpu_id, 52 | ) 53 | 54 | clock_disable_pattern = re.compile( 55 | r""" 56 | (?P.+)\s+ 57 | state=(?P\d+)\s+ 58 | cpu_id=(?P\d+) 59 | """, 60 | re.X|re.M 61 | ) 62 | 63 | @register_parser 64 | def clock_disable(payload): 65 | """Parser for `clock_disable` tracepoint""" 66 | try: 67 | match = re.match(clock_disable_pattern, payload) 68 | if match: 69 | match_group_dict = match.groupdict() 70 | return ClockDisable(**match_group_dict) 71 | except Exception, e: 72 | raise ParserError(e.message) 73 | -------------------------------------------------------------------------------- /ftrace/parsers/clock_enable.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'clock_enable' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | 33 | ClockEnableBase = namedtuple(TRACEPOINT, 34 | [ 35 | 'clk', # Clock name 36 | 'state', # Frequency 37 | 'cpu_id', # Target cpu 38 | ] 39 | ) 40 | 41 | class ClockEnable(ClockEnableBase): 42 | __slots__ = () 43 | def __new__(cls, clk, state, cpu_id): 44 | state = int(state) 45 | cpu_id = int(cpu_id) 46 | 47 | return super(cls, ClockEnable).__new__( 48 | cls, 49 | clk=clk, 50 | state=state, 51 | cpu_id=cpu_id, 52 | ) 53 | 54 | clock_enable_pattern = re.compile( 55 | r""" 56 | (?P.+)\s+ 57 | state=(?P\d+)\s+ 58 | cpu_id=(?P\d+) 59 | """, 60 | re.X|re.M 61 | ) 62 | 63 | @register_parser 64 | def clock_enable(payload): 65 | """Parser for `clock_enable` tracepoint""" 66 | try: 67 | match = re.match(clock_enable_pattern, payload) 68 | if match: 69 | match_group_dict = match.groupdict() 70 | return ClockEnable(**match_group_dict) 71 | except Exception, e: 72 | raise ParserError(e.message) 73 | -------------------------------------------------------------------------------- /ftrace/parsers/clock_set_rate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'clock_set_rate' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # clock_set_rate: krait1_pri_mux_clk state=300000000 cpu_id=0 33 | 34 | ClockSetRateBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'clk', # Clock name 37 | 'state', # Frequency 38 | 'cpu_id', # Target cpu 39 | ] 40 | ) 41 | 42 | class ClockSetRate(ClockSetRateBase): 43 | __slots__ = () 44 | def __new__(cls, clk, state, cpu_id): 45 | state = int(state) 46 | cpu_id = int(cpu_id) 47 | 48 | return super(cls, ClockSetRate).__new__( 49 | cls, 50 | clk=clk, 51 | state=state, 52 | cpu_id=cpu_id, 53 | ) 54 | 55 | clock_set_rate_pattern = re.compile( 56 | r""" 57 | (?P.+)\s+ 58 | state=(?P\d+)\s+ 59 | cpu_id=(?P\d+) 60 | """, 61 | re.X|re.M 62 | ) 63 | 64 | @register_parser 65 | def clock_set_rate(payload): 66 | """Parser for `clock_set_rate` tracepoint""" 67 | try: 68 | match = re.match(clock_set_rate_pattern, payload) 69 | if match: 70 | match_group_dict = match.groupdict() 71 | return ClockSetRate(**match_group_dict) 72 | except Exception, e: 73 | raise ParserError(e.message) 74 | -------------------------------------------------------------------------------- /ftrace/parsers/cluster_enter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cluster_enter' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # TODO: Unpsck from bitfield to set/tuple 33 | 34 | ClusterEnterBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'name', 37 | 'idx', 38 | 'sync', # unpack to tuple or set 39 | 'child', # unpack to tuple or set 40 | 'idle', 41 | ] 42 | ) 43 | 44 | 45 | class ClusterEnter(ClusterEnterBase): 46 | __slots__ = () 47 | def __new__(cls, name, idx, sync, child, idle): 48 | idx=int(idx) 49 | idle=int(idle) 50 | 51 | return super(cls, ClusterEnter).__new__( 52 | cls, 53 | name=name, 54 | idx=idx, 55 | sync=sync, 56 | child=child, 57 | idle=idle, 58 | ) 59 | 60 | cluster_enter_pattern = re.compile( 61 | r"""cluster_name:(?P.+)\s+ 62 | idx:(?P\d+)\s+ 63 | sync:(?P\w+)\s+ 64 | child:(?P\w+)\s+ 65 | idle:(?P\d+) 66 | """, 67 | re.X|re.M 68 | ) 69 | 70 | @register_parser 71 | def cluster_enter(payload): 72 | """Parser for `cluster_enter` tracepoint""" 73 | try: 74 | match = re.match(cluster_enter_pattern, payload) 75 | if match: 76 | match_group_dict = match.groupdict() 77 | return ClusterEnter(**match_group_dict) 78 | except Exception, e: 79 | raise ParserError(e.message) 80 | -------------------------------------------------------------------------------- /ftrace/parsers/cluster_exit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cluster_exit' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # TODO: Unpsck from bitfield to set/tuple 33 | 34 | ClusterExitBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'name', 37 | 'idx', 38 | 'sync', # unpack to tuple or set 39 | 'child', # unpack to tuple or set 40 | 'idle', 41 | ] 42 | ) 43 | 44 | 45 | class ClusterExit(ClusterExitBase): 46 | __slots__ = () 47 | def __new__(cls, name, idx, sync, child, idle): 48 | idx=int(idx) 49 | idle=int(idle) 50 | 51 | return super(cls, ClusterExit).__new__( 52 | cls, 53 | name=name, 54 | idx=idx, 55 | sync=sync, 56 | child=child, 57 | idle=idle, 58 | ) 59 | 60 | cluster_exit_pattern = re.compile( 61 | r"""cluster_name:(?P.+)\s+ 62 | idx:(?P\d+)\s+ 63 | sync:(?P\w+)\s+ 64 | child:(?P\w+)\s+ 65 | idle:(?P\d+) 66 | """, 67 | re.X|re.M 68 | ) 69 | 70 | @register_parser 71 | def cluster_exit(payload): 72 | """Parser for `cluster_exit` tracepoint""" 73 | try: 74 | match = re.match(cluster_exit_pattern, payload) 75 | if match: 76 | match_group_dict = match.groupdict() 77 | return ClusterExit(**match_group_dict) 78 | except Exception, e: 79 | raise ParserError(e.message) 80 | -------------------------------------------------------------------------------- /ftrace/parsers/cpu_capacity.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | try: 26 | from ftrace.third_party.cnamedtuple import namedtuple 27 | except ImportError: 28 | from collections import namedtuple 29 | 30 | TRACEPOINT = 'cpu_capacity' 31 | 32 | 33 | __all__ = [TRACEPOINT] 34 | 35 | 36 | CpuCapacityBase = namedtuple(TRACEPOINT, 37 | [ 38 | 'capacity', # CPU frequency 39 | 'cpu_id', # Target cpu 40 | ] 41 | ) 42 | 43 | class CpuCapacity(CpuCapacityBase): 44 | __slots__ = () 45 | def __new__(cls, capacity, cpu_id): 46 | capacity = int(capacity) 47 | cpu_id = int(cpu_id) 48 | 49 | return super(cls, CpuCapacity).__new__( 50 | cls, 51 | capacity=capacity, 52 | cpu_id=cpu_id, 53 | ) 54 | 55 | cpu_capacity_pattern = re.compile( 56 | r""" 57 | capacity=(?P\d+)\s+ 58 | cpu_id=(?P\d+) 59 | """, 60 | re.X|re.M 61 | ) 62 | 63 | @register_parser 64 | def cpu_capacity(payload): 65 | """Parser for `cpu_capacity` tracepoint""" 66 | try: 67 | match = re.match(cpu_capacity_pattern, payload) 68 | if match: 69 | match_group_dict = match.groupdict() 70 | return CpuCapacity(**match_group_dict) 71 | except Exception, e: 72 | raise ParserError(e.message) 73 | -------------------------------------------------------------------------------- /ftrace/parsers/cpu_frequency.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cpu_frequency' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # cpu_frequency: state=1190400 cpu_id=0 33 | 34 | CpuFrequencyBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'state', # CPU frequency 37 | 'cpu_id', # Target cpu 38 | ] 39 | ) 40 | 41 | class CpuFrequency(CpuFrequencyBase): 42 | __slots__ = () 43 | def __new__(cls, state, cpu_id): 44 | state = int(state) 45 | cpu_id = int(cpu_id) 46 | 47 | return super(cls, CpuFrequency).__new__( 48 | cls, 49 | state=state, 50 | cpu_id=cpu_id, 51 | ) 52 | 53 | cpu_frequency_pattern = re.compile( 54 | r""" 55 | state=(?P\d+)\s+ 56 | cpu_id=(?P\d+) 57 | """, 58 | re.X|re.M 59 | ) 60 | 61 | @register_parser 62 | def cpu_frequency(payload): 63 | """Parser for `cpu_frequency` tracepoint""" 64 | try: 65 | match = re.match(cpu_frequency_pattern, payload) 66 | if match: 67 | match_group_dict = match.groupdict() 68 | return CpuFrequency(**match_group_dict) 69 | except Exception, e: 70 | raise ParserError(e.message) 71 | -------------------------------------------------------------------------------- /ftrace/parsers/cpu_frequency_switch_end.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cpu_frequency_switch_end' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # cpu_frequency_switch_end: cpu_id=0 33 | 34 | CpuFrequencySwitchEndBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'cpu_id', # Target cpu 37 | ] 38 | ) 39 | 40 | class CpuFrequencySwitchEnd(CpuFrequencySwitchEndBase): 41 | __slots__ = () 42 | def __new__(cls, cpu_id): 43 | cpu_id = int(cpu_id) 44 | 45 | return super(cls, CpuFrequencySwitchEnd).__new__( 46 | cls, 47 | cpu_id=cpu_id, 48 | ) 49 | 50 | cpu_frequency_switch_end_pattern = re.compile( 51 | r""" 52 | cpu_id=(?P\d+) 53 | """, 54 | re.X|re.M 55 | ) 56 | 57 | @register_parser 58 | def cpu_frequency_switch_end(payload): 59 | """Parser for `cpu_frequency_switch_end` tracepoint""" 60 | try: 61 | match = re.match(cpu_frequency_switch_end_pattern, payload) 62 | if match: 63 | match_group_dict = match.groupdict() 64 | return CpuFrequencySwitchEnd(**match_group_dict) 65 | except Exception, e: 66 | raise ParserError(e.message) 67 | -------------------------------------------------------------------------------- /ftrace/parsers/cpu_frequency_switch_start.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cpu_frequency_switch_start' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # cpu_frequency_switch_start: start=1344000 end=384000 cpu_id=0 33 | 34 | CpuFrequencySwitchStartBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'start', # CPU frequency start 37 | 'end', # CPU frequency end 38 | 'cpu_id', # Target cpu 39 | ] 40 | ) 41 | 42 | class CpuFrequencySwitchStart(CpuFrequencySwitchStartBase): 43 | __slots__ = () 44 | def __new__(cls, start, end, cpu_id): 45 | start = int(start) 46 | end = int(end) 47 | cpu_id = int(cpu_id) 48 | 49 | return super(cls, CpuFrequencySwitchStart).__new__( 50 | cls, 51 | start=start, 52 | end=end, 53 | cpu_id=cpu_id, 54 | ) 55 | 56 | cpu_frequency_switch_start_pattern = re.compile( 57 | r""" 58 | start=(?P\d+)\s+ 59 | end=(?P\d+)\s+ 60 | cpu_id=(?P\d+) 61 | """, 62 | re.X|re.M 63 | ) 64 | 65 | @register_parser 66 | def cpu_frequency_switch_start(payload): 67 | """Parser for `cpu_frequency_switch_start` tracepoint""" 68 | try: 69 | match = re.match(cpu_frequency_switch_start_pattern, payload) 70 | if match: 71 | match_group_dict = match.groupdict() 72 | return CpuFrequencySwitchStart(**match_group_dict) 73 | except Exception, e: 74 | raise ParserError(e.message) 75 | -------------------------------------------------------------------------------- /ftrace/parsers/cpu_idle.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cpu_idle' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # cpu_idle: state=1190400 cpu_id=0 33 | 34 | CpuIdleBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'state', # CPU idle state 37 | 'cpu_id', # Target cpu 38 | ] 39 | ) 40 | 41 | class CpuIdle(CpuIdleBase): 42 | __slots__ = () 43 | def __new__(cls, state, cpu_id): 44 | state = int(state) 45 | cpu_id = int(cpu_id) 46 | 47 | return super(cls, CpuIdle).__new__( 48 | cls, 49 | state=state, 50 | cpu_id=cpu_id, 51 | ) 52 | 53 | cpu_idle_pattern = re.compile( 54 | r""" 55 | state=(?P\d+)\s+ 56 | cpu_id=(?P\d+) 57 | """, 58 | re.X|re.M 59 | ) 60 | 61 | @register_parser 62 | def cpu_idle(payload): 63 | """Parser for `cpu_idle` tracepoint""" 64 | try: 65 | match = re.match(cpu_idle_pattern, payload) 66 | if match: 67 | match_group_dict = match.groupdict() 68 | return CpuIdle(**match_group_dict) 69 | except Exception, e: 70 | raise ParserError(e.message) 71 | -------------------------------------------------------------------------------- /ftrace/parsers/cpu_idle_enter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cpu_idle_enter' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | 33 | CpuIdleEnterBase = namedtuple(TRACEPOINT, 34 | [ 35 | 'idx' 36 | ] 37 | ) 38 | 39 | 40 | class CpuIdleEnter(CpuIdleEnterBase): 41 | __slots__ = () 42 | def __new__(cls, idx): 43 | idx = int(idx) 44 | 45 | return super(cls, CpuIdleEnter).__new__( 46 | cls, 47 | idx=idx, 48 | ) 49 | 50 | cpu_idle_enter_pattern = re.compile( 51 | r"""idx:(?P\d+) 52 | """, 53 | re.X|re.M 54 | ) 55 | 56 | @register_parser 57 | def cpu_idle_enter(payload): 58 | """Parser for `cpu_idle_enter` tracepoint""" 59 | try: 60 | match = re.match(cpu_idle_enter_pattern, payload) 61 | if match: 62 | match_group_dict = match.groupdict() 63 | return CpuIdleEnter(**match_group_dict) 64 | except Exception, e: 65 | raise ParserError(e.message) 66 | -------------------------------------------------------------------------------- /ftrace/parsers/cpu_idle_exit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cpu_idle_exit' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | 33 | CpuIdleExitBase = namedtuple(TRACEPOINT, 34 | [ 35 | 'idx', 36 | 'success' 37 | ] 38 | ) 39 | 40 | 41 | class CpuIdleExit(CpuIdleExitBase): 42 | __slots__ = () 43 | def __new__(cls, idx, success): 44 | idx = int(idx) 45 | success = int(success) 46 | 47 | return super(cls, CpuIdleExit).__new__( 48 | cls, 49 | idx=idx, 50 | success=success, 51 | ) 52 | 53 | cpu_idle_exit_pattern = re.compile( 54 | r"""idx:(?P\d+)\s+ 55 | success:(?P\d+) 56 | """, 57 | re.X|re.M 58 | ) 59 | 60 | @register_parser 61 | def cpu_idle_exit(payload): 62 | """Parser for `cpu_idle_exit` tracepoint""" 63 | try: 64 | match = re.match(cpu_idle_exit_pattern, payload) 65 | if match: 66 | match_group_dict = match.groupdict() 67 | return CpuIdleExit(**match_group_dict) 68 | except Exception, e: 69 | raise ParserError(e.message) 70 | -------------------------------------------------------------------------------- /ftrace/parsers/cpufreq_interactive_already.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cpufreq_interactive_already' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # cpufreq_interactive_already: cpu=2 load=30 cur=384000 actual=768000 targ=384000 33 | 34 | CPUFreqInteractiveAlreadyBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'cpu', # CPU 37 | 'load', # Load 38 | 'cur', # Current Target Frequency 39 | 'targ', # New Target Frequency 40 | 'actual', # Actual frequency 41 | ] 42 | ) 43 | 44 | class CPUFreqInteractiveAlready(CPUFreqInteractiveAlreadyBase): 45 | __slots__ = () 46 | def __new__(cls, cpu, load, cur, actual, targ): 47 | cpu = int(cpu) 48 | load = int(load) 49 | cur = int(cur) 50 | actual = int(actual) 51 | targ = int(targ) 52 | 53 | return super(cls, CPUFreqInteractiveAlready).__new__( 54 | cls, 55 | cpu=cpu, 56 | load=load, 57 | cur=cur, 58 | actual=actual, 59 | targ=targ, 60 | ) 61 | 62 | cpufreq_interactive_already_pattern = re.compile( 63 | r""" 64 | cpu=(?P\d+)\s+ 65 | load=(?P\d+)\s+ 66 | cur=(?P\d+)\s+ 67 | actual=(?P\d+)\s+ 68 | targ=(?P\d+) 69 | """, 70 | re.X|re.M 71 | ) 72 | 73 | @register_parser 74 | def cpufreq_interactive_already(payload): 75 | """Parser for `cpufreq_interactive_already` tracepoint""" 76 | try: 77 | match = re.match(cpufreq_interactive_already_pattern, payload) 78 | if match: 79 | match_group_dict = match.groupdict() 80 | return CPUFreqInteractiveAlready(**match_group_dict) 81 | except Exception, e: 82 | raise ParserError(e.message) 83 | -------------------------------------------------------------------------------- /ftrace/parsers/cpufreq_interactive_setspeed.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cpufreq_interactive_setspeed' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # cpufreq_interactive_setspeed: cpu=0 targ=600000 actual=768000 33 | 34 | CPUFreqInteractiveSetSpeedBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'cpu', # CPU 37 | 'targ', # Target Frequency 38 | 'actual', # Actual frequency 39 | ] 40 | ) 41 | 42 | class CPUFreqInteractiveSetSpeed(CPUFreqInteractiveSetSpeedBase): 43 | __slots__ = () 44 | def __new__(cls, cpu, targ, actual): 45 | cpu = int(cpu) 46 | targ = int(targ) 47 | actual = int(actual) 48 | 49 | return super(cls, CPUFreqInteractiveSetSpeed).__new__( 50 | cls, 51 | cpu=cpu, 52 | targ=targ, 53 | actual=actual, 54 | ) 55 | 56 | cpufreq_interactive_setspeed_pattern = re.compile( 57 | r""" 58 | cpu=(?P\d+)\s+ 59 | targ=(?P\d+)\s+ 60 | actual=(?P\d+) 61 | """, 62 | re.X|re.M 63 | ) 64 | 65 | @register_parser 66 | def cpufreq_interactive_setspeed(payload): 67 | """Parser for `cpufreq_interactive_setspeed` tracepoint""" 68 | try: 69 | match = re.match(cpufreq_interactive_setspeed_pattern, payload) 70 | if match: 71 | match_group_dict = match.groupdict() 72 | return CPUFreqInteractiveSetSpeed(**match_group_dict) 73 | except Exception, e: 74 | raise ParserError(e.message) 75 | -------------------------------------------------------------------------------- /ftrace/parsers/cpufreq_interactive_target.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'cpufreq_interactive_target' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # cpufreq_interactive_target: cpu=2 load=30 cur=384000 actual=768000 targ=384000 33 | 34 | CPUFreqInteractiveTargetBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'cpu', # CPU 37 | 'load', # Load 38 | 'cur', # Current Target Frequency 39 | 'targ', # New Target Frequency 40 | 'actual', # Actual frequency 41 | ] 42 | ) 43 | 44 | class CPUFreqInteractiveTarget(CPUFreqInteractiveTargetBase): 45 | __slots__ = () 46 | def __new__(cls, cpu, load, cur, actual, targ): 47 | cpu = int(cpu) 48 | load = int(load) 49 | cur = int(cur) 50 | actual = int(actual) 51 | targ = int(targ) 52 | 53 | return super(cls, CPUFreqInteractiveTarget).__new__( 54 | cls, 55 | cpu=cpu, 56 | load=load, 57 | cur=cur, 58 | actual=actual, 59 | targ=targ, 60 | ) 61 | 62 | cpufreq_interactive_target_pattern = re.compile( 63 | r""" 64 | cpu=(?P\d+)\s+ 65 | load=(?P\d+)\s+ 66 | cur=(?P\d+)\s+ 67 | actual=(?P\d+)\s+ 68 | targ=(?P\d+) 69 | """, 70 | re.X|re.M 71 | ) 72 | 73 | @register_parser 74 | def cpufreq_interactive_target(payload): 75 | """Parser for `cpufreq_interactive_target` tracepoint""" 76 | try: 77 | match = re.match(cpufreq_interactive_target_pattern, payload) 78 | if match: 79 | match_group_dict = match.groupdict() 80 | return CPUFreqInteractiveTarget(**match_group_dict) 81 | except Exception, e: 82 | raise ParserError(e.message) 83 | -------------------------------------------------------------------------------- /ftrace/parsers/cpufreq_sched_request_opp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | try: 25 | from ftrace.third_party.cnamedtuple import namedtuple 26 | except ImportError: 27 | from collections import namedtuple 28 | 29 | 30 | TRACEPOINT = 'cpufreq_sched_request_opp' 31 | 32 | __all__ = [TRACEPOINT] 33 | 34 | CpufreqSchedRequestOppBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'cpu' 37 | 'capacity', 38 | 'freq_new', 39 | 'requested_freq' 40 | ] 41 | ) 42 | 43 | class CpufreqSchedRequestOpp(CpufreqSchedRequestOppBase): 44 | __slots__ = () 45 | def __new__(cls, cpu, capacity, freq_new, requested_freq): 46 | cpu = int(cpu) 47 | capacity = int(capacity) 48 | freq_new = int(freq_new) 49 | requested_freq = int(requested_freq) 50 | 51 | return super(cls, CpufreqSchedRequestOpp).__new__( 52 | cls, 53 | cpu=cpu, 54 | capacity=capacity, 55 | freq_new=freq_new, 56 | requested_freq=requested_freq, 57 | ) 58 | 59 | cpufreq_sched_request_opp_pattern = re.compile( 60 | r""" 61 | cpu (?P\d+)\s+ 62 | cap change, cluster cap request (?P\d+)\s+ 63 | => OPP (?P\d+) \(cur (?P\d+) 64 | """, 65 | re.X|re.M 66 | ) 67 | 68 | @register_parser 69 | def cpufreq_sched_request_opp(payload): 70 | """Parser for `cpufreq_sched_request_opp` tracepoint""" 71 | try: 72 | match = re.match(cpufreq_sched_request_opp_pattern, payload) 73 | if match: 74 | match_group_dict = match.groupdict() 75 | return CpufreqSchedRequestOpp(**match_group_dict) 76 | except Exception, e: 77 | raise ParserError(e.message) 78 | -------------------------------------------------------------------------------- /ftrace/parsers/cpufreq_sched_update_capacity.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | try: 25 | from ftrace.third_party.cnamedtuple import namedtuple 26 | except ImportError: 27 | from collections import namedtuple 28 | 29 | 30 | TRACEPOINT = 'cpufreq_sched_update_capacity' 31 | 32 | __all__ = [TRACEPOINT] 33 | 34 | CpufreqSchedUpdateCapacityBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'cpu' 37 | 'request', 38 | 'cfs', # fair tasks 39 | 'rt', # real-time 40 | 'dl', 41 | 'total', 42 | 'new_total', 43 | ] 44 | ) 45 | 46 | class CpufreqSchedUpdateCapacity(CpufreqSchedUpdateCapacityBase): 47 | __slots__ = () 48 | def __new__(cls, cpu, request, cfs, rt, dl, total, new_total): 49 | cpu = int(cpu) 50 | request = bool(request) 51 | cfs = int(cfs) 52 | rt = int(rt) 53 | dl = int(dl) 54 | total = int(total) 55 | new_total = int(new_total) 56 | 57 | return super(cls, CpufreqSchedUpdateCapacity).__new__( 58 | cls, 59 | cpu=cpu, 60 | request=request, 61 | cfs=cfs, 62 | rt=rt, 63 | dl=dl, 64 | total=total, 65 | new_total=new_total 66 | ) 67 | 68 | cpufreq_sched_update_capacity_pattern = re.compile( 69 | r""" 70 | cpu=(?P\d+)\s+ 71 | set_cap=(?P\d+)\s+ 72 | cfs=(?P\d+)\s+ 73 | rt=(?P\d+)\s+ 74 | dl=(?P
\d+)\s+ 75 | old_tot=(?P\d+)\s+ 76 | new_tot=(?P\d+) 77 | """, 78 | re.X|re.M 79 | ) 80 | 81 | @register_parser 82 | def cpufreq_sched_update_capacity(payload): 83 | """Parser for `cpufreq_sched_update_capacity` tracepoint""" 84 | try: 85 | match = re.match(cpufreq_sched_update_capacity_pattern, payload) 86 | if match: 87 | match_group_dict = match.groupdict() 88 | return CpufreqSchedUpdateCapacity(**match_group_dict) 89 | except Exception, e: 90 | raise ParserError(e.message) 91 | -------------------------------------------------------------------------------- /ftrace/parsers/ext4_da_write_begin.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'ext4_da_write_begin' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | Ext4DAWriteBeginBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'dev_major', 35 | 'dev_minor', 36 | 'ino', 37 | 'pos', 38 | 'len', 39 | 'flags', 40 | ] 41 | ) 42 | 43 | class Ext4DAWriteBegin(Ext4DAWriteBeginBase): 44 | __slots__ = () 45 | def __new__(cls, dev_major, dev_minor, ino, pos, _len, flags): 46 | dev_major = int(dev_major) 47 | dev_minor = int(dev_minor) 48 | ino=int(ino) 49 | pos=int(pos) 50 | _len=int(_len) 51 | return super(cls, Ext4DAWriteBegin).__new__( 52 | cls, 53 | dev_major=dev_major, 54 | dev_minor=dev_minor, 55 | ino=ino, 56 | pos=pos, 57 | len=_len, 58 | flags=flags, 59 | ) 60 | 61 | ext4_da_write_begin_pattern = re.compile( 62 | r""" 63 | dev\s+(?P\d+), 64 | (?P\d+)\s+ 65 | ino\s+(?P\d+)\s+ 66 | pos\s+(?P\d+)\s+ 67 | len\s+(?P\d+)\s+ 68 | flags\s+(?P.+) 69 | """, 70 | re.X|re.M 71 | ) 72 | 73 | @register_parser 74 | def ext4_da_write_begin(payload): 75 | """Parser for `ext4_da_write_begin` tracepoint""" 76 | try: 77 | match = re.match(ext4_da_write_begin_pattern, payload) 78 | if match: 79 | match_group_dict = match.groupdict() 80 | return Ext4DAWriteBegin(**match_group_dict) 81 | except Exception, e: 82 | raise ParserError(e.message) 83 | -------------------------------------------------------------------------------- /ftrace/parsers/ext4_da_write_end.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'ext4_da_write_end' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | Ext4DAWriteEndBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'dev_major', 35 | 'dev_minor', 36 | 'ino', 37 | 'pos', 38 | 'len', 39 | 'copied', 40 | ] 41 | ) 42 | 43 | class Ext4DAWriteEnd(Ext4DAWriteEndBase): 44 | __slots__ = () 45 | def __new__(cls, dev_major, dev_minor, ino, pos, _len, copied): 46 | dev_major = int(dev_major) 47 | dev_minor = int(dev_minor) 48 | ino=int(ino) 49 | pos=int(pos) 50 | _len=int(_len) 51 | copied=int(copied) 52 | 53 | return super(cls, Ext4DAWriteEnd).__new__( 54 | cls, 55 | dev_major=dev_major, 56 | dev_minor=dev_minor, 57 | ino=ino, 58 | pos=pos, 59 | len=_len, 60 | copied=copied, 61 | ) 62 | 63 | ext4_da_write_end_pattern = re.compile( 64 | r""" 65 | dev\s+(?P\d+), 66 | (?P\d+)\s+ 67 | ino\s+(?P\d+)\s+ 68 | pos\s+(?P\d+)\s+ 69 | len\s+(?P\d+)\s+ 70 | copied\s+(?P\d+) 71 | """, 72 | re.X|re.M 73 | ) 74 | 75 | @register_parser 76 | def ext4_da_write_end(payload): 77 | """Parser for `ext4_da_write_end` tracepoint""" 78 | try: 79 | match = re.match(ext4_da_write_end_pattern, payload) 80 | if match: 81 | match_group_dict = match.groupdict() 82 | return Ext4DAWriteEnd(**match_group_dict) 83 | except Exception, e: 84 | raise ParserError(e.message) 85 | -------------------------------------------------------------------------------- /ftrace/parsers/ext4_sync_file_enter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'ext4_sync_file_enter' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | Ext4SyncFileEnterBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'dev_major', 35 | 'dev_minor', 36 | 'ino', 37 | 'parent', 38 | 'datasync', 39 | ] 40 | ) 41 | 42 | class Ext4SyncFileEnter(Ext4SyncFileEnterBase): 43 | __slots__ = () 44 | def __new__(cls, dev_major, dev_minor, ino, parent, datasync): 45 | dev_major = int(dev_major) 46 | dev_minor = int(dev_minor) 47 | ino=int(ino) 48 | 49 | return super(cls, Ext4SyncFileEnter).__new__( 50 | cls, 51 | dev_major=dev_major, 52 | dev_minor=dev_minor, 53 | ino=ino, 54 | parent=parent, 55 | datasync=datasync, 56 | ) 57 | 58 | ext4_sync_file_enter_pattern = re.compile( 59 | r""" 60 | dev\s+(?P\d+), 61 | (?P\d+)\s+ 62 | ino\s+(?P\d+)\s+ 63 | parent\s+(?P\d+)\s+ 64 | datasync\s+(?P\d+) 65 | """, 66 | re.X|re.M 67 | ) 68 | 69 | @register_parser 70 | def ext4_sync_file_enter(payload): 71 | """Parser for `ext4_sync_file_enter` tracepoint""" 72 | try: 73 | match = re.match(ext4_sync_file_enter_pattern, payload) 74 | if match: 75 | match_group_dict = match.groupdict() 76 | return Ext4SyncFileEnter(**match_group_dict) 77 | except Exception, e: 78 | raise ParserError(e.message) 79 | -------------------------------------------------------------------------------- /ftrace/parsers/ext4_sync_file_exit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'ext4_sync_file_exit' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | Ext4DAWriteEndBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'dev_major', 35 | 'dev_minor', 36 | 'ino', 37 | 'ret', 38 | ] 39 | ) 40 | 41 | class Ext4DAWriteEnd(Ext4DAWriteEndBase): 42 | __slots__ = () 43 | def __new__(cls, dev_major, dev_minor, ino, ret): 44 | dev_major = int(dev_major) 45 | dev_minor = int(dev_minor) 46 | ino=int(ino) 47 | ret=int(ret) 48 | 49 | return super(cls, Ext4DAWriteEnd).__new__( 50 | cls, 51 | dev_major=dev_major, 52 | dev_minor=dev_minor, 53 | ino=ino, 54 | ret=ret, 55 | ) 56 | 57 | ext4_sync_file_exit_pattern = re.compile( 58 | r""" 59 | dev\s+(?P\d+), 60 | (?P\d+)\s+ 61 | ino\s+(?P\d+)\s+ 62 | ret\s+(?P\d+) 63 | """, 64 | re.X|re.M 65 | ) 66 | 67 | @register_parser 68 | def ext4_sync_file_exit(payload): 69 | """Parser for `ext4_sync_file_exit` tracepoint""" 70 | try: 71 | match = re.match(ext4_sync_file_exit_pattern, payload) 72 | if match: 73 | match_group_dict = match.groupdict() 74 | return Ext4DAWriteEnd(**match_group_dict) 75 | except Exception, e: 76 | raise ParserError(e.message) 77 | -------------------------------------------------------------------------------- /ftrace/parsers/f2fs_sync_file_enter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | # TODO: Validate this! 28 | 29 | TRACEPOINT = 'f2fs_sync_file_enter' 30 | 31 | 32 | __all__ = [TRACEPOINT] 33 | 34 | F2FSSyncFileEnterBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'dev_major', 37 | 'dev_minor', 38 | 'ino', 39 | 'parent', 40 | 'datasync', 41 | ] 42 | ) 43 | 44 | class F2FSSyncFileEnter(F2FSSyncFileEnterBase): 45 | __slots__ = () 46 | def __new__(cls, dev_major, dev_minor, ino, parent, datasync): 47 | dev_major = int(dev_major) 48 | dev_minor = int(dev_minor) 49 | ino=int(ino) 50 | parent=int(parent) 51 | 52 | return super(cls, F2FSSyncFileEnter).__new__( 53 | cls, 54 | dev_major=dev_major, 55 | dev_minor=dev_minor, 56 | ino=ino, 57 | parent=parent, 58 | datasync=datasync, 59 | ) 60 | 61 | f2fs_sync_file_enter_pattern = re.compile( 62 | r""" 63 | dev = \((?P\d+), 64 | (?P\d+)\),\s+ 65 | ino = (?P\d+),\s+ 66 | parent = (?P\d+),\s+ 67 | datasync = (?P\d+) 68 | """, 69 | re.X|re.M 70 | ) 71 | 72 | @register_parser 73 | def f2fs_sync_file_enter(payload): 74 | """Parser for `f2fs_sync_file_enter` tracepoint""" 75 | try: 76 | match = re.match(f2fs_sync_file_enter_pattern, payload) 77 | if match: 78 | match_group_dict = match.groupdict() 79 | return F2FSSyncFileEnter(**match_group_dict) 80 | except Exception, e: 81 | raise ParserError(e.message) 82 | -------------------------------------------------------------------------------- /ftrace/parsers/f2fs_sync_file_exit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'f2fs_sync_file_exit' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | F2FSSyncFileExitBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'dev_major', 35 | 'dev_minor', 36 | 'ino', 37 | 'need_cp', 38 | 'datasync', 39 | 'ret', 40 | ] 41 | ) 42 | 43 | class F2FSSyncFileExit(F2FSSyncFileExitBase): 44 | __slots__ = () 45 | def __new__(cls, dev_major, dev_minor, ino, need_cp, datasync, ret): 46 | dev_major = int(dev_major) 47 | dev_minor = int(dev_minor) 48 | ino=int(ino) 49 | ret=int(ret) 50 | 51 | return super(cls, F2FSSyncFileExit).__new__( 52 | cls, 53 | dev_major=dev_major, 54 | dev_minor=dev_minor, 55 | ino=ino, 56 | need_cp=need_cp, 57 | datasync=datasync, 58 | ret=ret 59 | ) 60 | 61 | f2fs_sync_file_exit_pattern = re.compile( 62 | r""" 63 | dev = \((?P\d+), 64 | (?P\d+)\),\s+ 65 | ino = (?P\d+),\s+ 66 | checkpoint is (?P.+),\s+ 67 | datasync = (?P\d+),\s+ 68 | ret = (?P\d+) 69 | """, 70 | re.X|re.M 71 | ) 72 | 73 | @register_parser 74 | def f2fs_sync_file_exit(payload): 75 | """Parser for `f2fs_sync_file_exit` tracepoint""" 76 | try: 77 | match = re.match(f2fs_sync_file_exit_pattern, payload) 78 | if match: 79 | match_group_dict = match.groupdict() 80 | return F2FSSyncFileExit(**match_group_dict) 81 | except Exception, e: 82 | raise ParserError(e.message) 83 | -------------------------------------------------------------------------------- /ftrace/parsers/f2fs_write_begin.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'f2fs_write_begin' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | F2FSWriteBeginBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'dev_major', 35 | 'dev_minor', 36 | 'ino', 37 | 'pos', 38 | 'len', 39 | 'flags', 40 | ] 41 | ) 42 | 43 | class F2FSWriteBegin(F2FSWriteBeginBase): 44 | __slots__ = () 45 | def __new__(cls, dev_major, dev_minor, ino, pos, _len, flags): 46 | dev_major = int(dev_major) 47 | dev_minor = int(dev_minor) 48 | ino=int(ino) 49 | pos=int(pos) 50 | _len=int(_len) 51 | flags=int(flags) 52 | 53 | return super(cls, F2FSWriteBegin).__new__( 54 | cls, 55 | dev_major=dev_major, 56 | dev_minor=dev_minor, 57 | ino=ino, 58 | pos=pos, 59 | len=_len, 60 | flags=flags, 61 | ) 62 | 63 | f2fs_write_begin_pattern = re.compile( 64 | r""" 65 | dev = \((?P\d+), 66 | (?P\d+)\),\s+ 67 | ino = (?P\d+),\s+ 68 | pos = (?P\d+),\s+ 69 | len = (?P\d+),\s+ 70 | flags = (?P\d+) 71 | """, 72 | re.X|re.M 73 | ) 74 | 75 | @register_parser 76 | def f2fs_write_begin(payload): 77 | """Parser for `f2fs_write_begin` tracepoint""" 78 | try: 79 | match = re.match(f2fs_write_begin_pattern, payload) 80 | if match: 81 | match_group_dict = match.groupdict() 82 | return F2FSWriteBegin(**match_group_dict) 83 | except Exception, e: 84 | raise ParserError(e.message) 85 | -------------------------------------------------------------------------------- /ftrace/parsers/f2fs_write_end.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'f2fs_write_end' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | F2FSWriteEndBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'dev_major', 35 | 'dev_minor', 36 | 'ino', 37 | 'pos', 38 | 'len', 39 | 'copied', 40 | ] 41 | ) 42 | 43 | class F2FSWriteEnd(F2FSWriteEndBase): 44 | __slots__ = () 45 | def __new__(cls, dev_major, dev_minor, ino, pos, _len, copied): 46 | dev_major = int(dev_major) 47 | dev_minor = int(dev_minor) 48 | ino=int(ino) 49 | pos=int(pos) 50 | _len=int(_len) 51 | copied=int(copied) 52 | 53 | return super(cls, F2FSWriteEnd).__new__( 54 | cls, 55 | dev_major=dev_major, 56 | dev_minor=dev_minor, 57 | ino=ino, 58 | pos=pos, 59 | len=_len, 60 | copied=copied, 61 | ) 62 | 63 | f2fs_write_end_pattern = re.compile( 64 | r""" 65 | dev = \((?P\d+), 66 | (?P\d+)\),\s+ 67 | ino = (?P\d+),\s+ 68 | pos = (?P\d+),\s+ 69 | len = (?P\d+),\s+ 70 | copied = (?P\d+) 71 | """, 72 | re.X|re.M 73 | ) 74 | 75 | @register_parser 76 | def f2fs_write_end(payload): 77 | """Parser for `f2fs_write_end` tracepoint""" 78 | try: 79 | match = re.match(f2fs_write_end_pattern, payload) 80 | if match: 81 | match_group_dict = match.groupdict() 82 | return F2FSWriteEnd(**match_group_dict) 83 | except Exception, e: 84 | raise ParserError(e.message) 85 | -------------------------------------------------------------------------------- /ftrace/parsers/gpu_sched_switch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'gpu_sched_switch' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | 33 | GPUSchedSwitchBase = namedtuple(TRACEPOINT, 34 | [ 35 | 'gpu_name', # GPU Hardware block e.g. "2D", "3D", "Compute" 36 | 'timestamp', # Timestamp (not necessarily CPU clock) 37 | 'next_ctx_id', # Next context running on GPU hardware block 38 | 'next_prio', # Priority of next context 39 | 'next_job_id', # Batch of work enqueued 40 | ] 41 | ) 42 | 43 | 44 | class GPUSchedSwitch(GPUSchedSwitchBase): 45 | __slots__ = () 46 | def __new__(cls, gpu_name, timestamp, next_ctx_id, next_prio, next_job_id): 47 | timestamp = float(timestamp) 48 | next_ctx_id = int(next_ctx_id) 49 | next_prio = int(next_prio) 50 | next_job_id = int(next_job_id) 51 | 52 | return super(cls, GPUSchedSwitch).__new__( 53 | cls, 54 | gpu_name=gpu_name, 55 | timestamp=timestamp, 56 | next_ctx_id=next_ctx_id, 57 | next_prio=next_prio, 58 | next_job_id=next_job_id, 59 | ) 60 | 61 | gpu_sched_switch_pattern = re.compile( 62 | r"""gpu_name=(?P.+)\s+ 63 | ts=(?P\d+)\s+ 64 | next_ctx_id=(?P\d+)\s+ 65 | next_prio=(?P\d+)\s+ 66 | next_job_id=(?P\d+) 67 | """, 68 | re.X|re.M 69 | ) 70 | 71 | @register_parser 72 | def gpu_sched_switch(payload): 73 | """Parser for `gpu_sched_switch` tracepoint""" 74 | try: 75 | match = re.match(gpu_sched_switch_pattern, payload) 76 | if match: 77 | match_group_dict = match.groupdict() 78 | return GPUSchedSwitch(**match_group_dict) 79 | except Exception, e: 80 | raise ParserError(e.message) 81 | -------------------------------------------------------------------------------- /ftrace/parsers/irq_handler_entry.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'irq_handler_entry' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | IRQHandlerEntryBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'irq', 35 | 'name', 36 | ] 37 | ) 38 | 39 | class IRQHandlerEntry(IRQHandlerEntryBase): 40 | __slots__ = () 41 | def __new__(cls, irq, name): 42 | irq = int(irq) 43 | return super(cls, IRQHandlerEntry).__new__( 44 | cls, 45 | irq=irq, 46 | name=name, 47 | ) 48 | 49 | irq_handler_entry_pattern = re.compile( 50 | r""" 51 | irq=(?P\d+)\s+ 52 | name=(?P.+) 53 | """, 54 | re.X|re.M 55 | ) 56 | 57 | @register_parser 58 | def irq_handler_entry(payload): 59 | """Parser for `irq_handler_entry` tracepoint""" 60 | try: 61 | match = re.match(irq_handler_entry_pattern, payload) 62 | if match: 63 | match_group_dict = match.groupdict() 64 | return IRQHandlerEntry(**match_group_dict) 65 | except Exception, e: 66 | raise ParserError(e.message) 67 | -------------------------------------------------------------------------------- /ftrace/parsers/irq_handler_exit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'irq_handler_exit' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | IRQHandlerExitBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'irq', 35 | 'name', 36 | ] 37 | ) 38 | 39 | class IRQHandlerExit(IRQHandlerExitBase): 40 | __slots__ = () 41 | def __new__(cls, irq, name): 42 | irq = int(irq) 43 | return super(cls, IRQHandlerExit).__new__( 44 | cls, 45 | irq=irq, 46 | name=name, 47 | ) 48 | 49 | irq_handler_exit_pattern = re.compile( 50 | r""" 51 | irq=(?P\d+)\s+ 52 | name=(?P.+) 53 | """, 54 | re.X|re.M 55 | ) 56 | 57 | @register_parser 58 | def irq_handler_exit(payload): 59 | """Parser for `irq_handler_exit` tracepoint""" 60 | try: 61 | match = re.match(irq_handler_exit_pattern, payload) 62 | if match: 63 | match_group_dict = match.groupdict() 64 | return IRQHandlerExit(**match_group_dict) 65 | except Exception, e: 66 | raise ParserError(e.message) 67 | -------------------------------------------------------------------------------- /ftrace/parsers/kgsl_bus.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'kgsl_bus' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | #kgsl_bus: d_name=kgsl-3d0 flag=off 33 | 34 | KgslBusBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'd_name', 37 | 'flag', 38 | ] 39 | ) 40 | 41 | class KgslBus(KgslBusBase): 42 | __slots__ = () 43 | def __new__(cls, d_name, flag): 44 | 45 | return super(cls, KgslBus).__new__( 46 | cls, 47 | d_name=d_name, 48 | flag=flag, 49 | ) 50 | 51 | kgsl_bus_pattern = re.compile( 52 | r""" 53 | d_name=(?P.+)\s+ 54 | flag=(?P\w+) 55 | """, 56 | re.X|re.M 57 | ) 58 | 59 | @register_parser 60 | def kgsl_bus(payload): 61 | """Parser for `kgsl_bus` tracepoint""" 62 | try: 63 | match = re.match(kgsl_bus_pattern, payload) 64 | if match: 65 | match_group_dict = match.groupdict() 66 | return KgslBus(**match_group_dict) 67 | except Exception, e: 68 | raise ParserError(e.message) 69 | -------------------------------------------------------------------------------- /ftrace/parsers/kgsl_buslevel.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'kgsl_buslevel' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | #kgsl_buslevel: d_name=kgsl-3d0 pwrlevel=1 bus=2 33 | 34 | KgslBuslevelBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'd_name', 37 | 'pwrlevel', 38 | 'bus' 39 | ] 40 | ) 41 | 42 | class KgslBuslevel(KgslBuslevelBase): 43 | __slots__ = () 44 | def __new__(cls, d_name, pwrlevel, bus): 45 | pwrlevel=int(pwrlevel) 46 | bus=int(bus) 47 | 48 | return super(cls, KgslBuslevel).__new__( 49 | cls, 50 | d_name=d_name, 51 | pwrlevel=pwrlevel, 52 | bus=bus, 53 | ) 54 | 55 | kgsl_buslevel_pattern = re.compile( 56 | r""" 57 | d_name=(?P.+)\s+ 58 | pwrlevel=(?P\d+)\s+ 59 | bus=(?P\d+) 60 | """, 61 | re.X|re.M 62 | ) 63 | 64 | @register_parser 65 | def kgsl_buslevel(payload): 66 | """Parser for `kgsl_buslevel` tracepoint""" 67 | try: 68 | match = re.match(kgsl_buslevel_pattern, payload) 69 | if match: 70 | match_group_dict = match.groupdict() 71 | return KgslBuslevel(**match_group_dict) 72 | except Exception, e: 73 | raise ParserError(e.message) 74 | -------------------------------------------------------------------------------- /ftrace/parsers/kgsl_clk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'kgsl_clk' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | #kgsl_clk: d_name=kgsl-3d0 flag=off 33 | 34 | KgslClkBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'd_name', 37 | 'flag', 38 | ] 39 | ) 40 | 41 | class KgslClk(KgslClkBase): 42 | __slots__ = () 43 | def __new__(cls, d_name, flag): 44 | 45 | return super(cls, KgslClk).__new__( 46 | cls, 47 | d_name=d_name, 48 | flag=flag, 49 | ) 50 | 51 | kgsl_clk_pattern = re.compile( 52 | r""" 53 | d_name=(?P.+)\s+ 54 | flag=(?P\w+) 55 | """, 56 | re.X|re.M 57 | ) 58 | 59 | @register_parser 60 | def kgsl_clk(payload): 61 | """Parser for `kgsl_clk` tracepoint""" 62 | try: 63 | match = re.match(kgsl_clk_pattern, payload) 64 | if match: 65 | match_group_dict = match.groupdict() 66 | return KgslClk(**match_group_dict) 67 | except Exception, e: 68 | raise ParserError(e.message) 69 | -------------------------------------------------------------------------------- /ftrace/parsers/kgsl_gpubusy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'kgsl_gpubusy' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | #kgsl_gpubusy: d_name=kgsl-3d0 busy=0 elapsed=-1258611171 33 | 34 | KgslGpuBusyBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'd_name', 37 | 'busy', 38 | 'elapsed', 39 | ] 40 | ) 41 | 42 | class KgslGpuBusy(KgslGpuBusyBase): 43 | __slots__ = () 44 | def __new__(cls, d_name, busy, elapsed): 45 | busy=int(busy) 46 | elapsed=int(elapsed) 47 | 48 | return super(cls, KgslGpuBusy).__new__( 49 | cls, 50 | d_name=d_name, 51 | busy=busy, 52 | elapsed=elapsed, 53 | ) 54 | 55 | kgsl_gpubusy_pattern = re.compile( 56 | r""" 57 | d_name=(?P.+)\s+ 58 | busy=(?P\d+)\s+ 59 | elapsed=(?P.+) 60 | """, 61 | re.X|re.M 62 | ) 63 | 64 | @register_parser 65 | def kgsl_gpubusy(payload): 66 | """Parser for `kgsl_gpubusy` tracepoint""" 67 | try: 68 | match = re.match(kgsl_gpubusy_pattern, payload) 69 | if match: 70 | match_group_dict = match.groupdict() 71 | return KgslGpuBusy(**match_group_dict) 72 | except Exception, e: 73 | raise ParserError(e.message) 74 | -------------------------------------------------------------------------------- /ftrace/parsers/kgsl_irq.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'kgsl_irq' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | #kgsl_irq: d_name=kgsl-3d0 flag=off 33 | 34 | KgslIRQBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'd_name', 37 | 'flag', 38 | ] 39 | ) 40 | 41 | class KgslIRQ(KgslIRQBase): 42 | __slots__ = () 43 | def __new__(cls, d_name, flag): 44 | 45 | return super(cls, KgslIRQ).__new__( 46 | cls, 47 | d_name=d_name, 48 | flag=flag, 49 | ) 50 | 51 | kgsl_irq_pattern = re.compile( 52 | r""" 53 | d_name=(?P.+)\s+ 54 | flag=(?P\w+) 55 | """, 56 | re.X|re.M 57 | ) 58 | 59 | @register_parser 60 | def kgsl_irq(payload): 61 | """Parser for `kgsl_irq` tracepoint""" 62 | try: 63 | match = re.match(kgsl_irq_pattern, payload) 64 | if match: 65 | match_group_dict = match.groupdict() 66 | return KgslIRQ(**match_group_dict) 67 | except Exception, e: 68 | raise ParserError(e.message) 69 | -------------------------------------------------------------------------------- /ftrace/parsers/kgsl_pwr_set_state.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'kgsl_pwr_set_state' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | #kgsl_pwr_set_state: d_name=kgsl-3d0 state=SLUMBER 33 | 34 | KgslPwrSetStateBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'd_name', 37 | 'state' 38 | ] 39 | ) 40 | 41 | class KgslPwrSetState(KgslPwrSetStateBase): 42 | __slots__ = () 43 | def __new__(cls, d_name, state): 44 | 45 | return super(cls, KgslPwrSetState).__new__( 46 | cls, 47 | d_name=d_name, 48 | state=state, 49 | ) 50 | 51 | kgsl_pwr_set_state_pattern = re.compile( 52 | r""" 53 | d_name=(?P.+)\s+ 54 | state=(?P\w+) 55 | """, 56 | re.X|re.M 57 | ) 58 | 59 | @register_parser 60 | def kgsl_pwr_set_state(payload): 61 | """Parser for `kgsl_pwr_set_state` tracepoint""" 62 | try: 63 | match = re.match(kgsl_pwr_set_state_pattern, payload) 64 | if match: 65 | match_group_dict = match.groupdict() 66 | return KgslPwrSetState(**match_group_dict) 67 | except Exception, e: 68 | raise ParserError(e.message) 69 | -------------------------------------------------------------------------------- /ftrace/parsers/kgsl_pwrlevel.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'kgsl_pwrlevel' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | #kgsl_pwrlevel: d_name=kgsl-3d0 pwrlevel=1 freq=200000000 33 | 34 | KgslPwrlevelBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'd_name', 37 | 'pwrlevel', 38 | 'freq' 39 | ] 40 | ) 41 | 42 | class KgslPwrlevel(KgslPwrlevelBase): 43 | __slots__ = () 44 | def __new__(cls, d_name, pwrlevel, freq): 45 | pwrlevel=int(pwrlevel) 46 | freq=int(freq) 47 | 48 | return super(cls, KgslPwrlevel).__new__( 49 | cls, 50 | d_name=d_name, 51 | pwrlevel=pwrlevel, 52 | freq=freq, 53 | ) 54 | 55 | kgsl_pwrlevel_pattern = re.compile( 56 | r""" 57 | d_name=(?P.+)\s+ 58 | pwrlevel=(?P\d+)\s+ 59 | freq=(?P\d+) 60 | """, 61 | re.X|re.M 62 | ) 63 | 64 | @register_parser 65 | def kgsl_pwrlevel(payload): 66 | """Parser for `kgsl_pwrlevel` tracepoint""" 67 | try: 68 | match = re.match(kgsl_pwrlevel_pattern, payload) 69 | if match: 70 | match_group_dict = match.groupdict() 71 | return KgslPwrlevel(**match_group_dict) 72 | except Exception, e: 73 | raise ParserError(e.message) 74 | -------------------------------------------------------------------------------- /ftrace/parsers/kgsl_rail.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'kgsl_rail' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | #kgsl_rail: d_name=kgsl-3d0 flag=off 33 | 34 | KgslRailBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'd_name', 37 | 'flag', 38 | ] 39 | ) 40 | 41 | class KgslRail(KgslRailBase): 42 | __slots__ = () 43 | def __new__(cls, d_name, flag): 44 | 45 | return super(cls, KgslRail).__new__( 46 | cls, 47 | d_name=d_name, 48 | flag=flag, 49 | ) 50 | 51 | kgsl_rail_pattern = re.compile( 52 | r""" 53 | d_name=(?P.+)\s+ 54 | flag=(?P\w+) 55 | """, 56 | re.X|re.M 57 | ) 58 | 59 | @register_parser 60 | def kgsl_rail(payload): 61 | """Parser for `kgsl_rail` tracepoint""" 62 | try: 63 | match = re.match(kgsl_rail_pattern, payload) 64 | if match: 65 | match_group_dict = match.groupdict() 66 | return KgslRail(**match_group_dict) 67 | except Exception, e: 68 | raise ParserError(e.message) 69 | -------------------------------------------------------------------------------- /ftrace/parsers/mali_job_slots_event.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from .register import register_parser 23 | from collections import namedtuple 24 | from ftrace.common import ParserError 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'mali_job_slots_event' 28 | 29 | __all__ = [TRACEPOINT] 30 | 31 | MaliJobSlotsEventBase = namedtuple(TRACEPOINT, 32 | [ 33 | 'event', 34 | 'tgid', 35 | 'pid', 36 | 'job_id' 37 | 38 | ] 39 | ) 40 | 41 | class MaliJobSlotsEvent(MaliJobSlotsEventBase): 42 | __slots__ = () 43 | def __new__(cls, event, tgid, pid, job_id): 44 | 45 | tgid=int(tgid) 46 | pid=int(pid) 47 | job_id=int(job_id) 48 | 49 | return super(cls, MaliJobSlotsEvent).__new__( 50 | cls, 51 | event=event, 52 | tgid=tgid, 53 | pid=pid, 54 | job_id=job_id 55 | ) 56 | 57 | mali_job_slots_event_pattern = re.compile( 58 | r""" 59 | event=(?P\d+)\s+ 60 | tgid=(?P\d+)\s+ 61 | pid=(?P\d+)\s+ 62 | job_id=(?P\d+) 63 | """, 64 | re.X|re.M 65 | ) 66 | 67 | @register_parser 68 | def mali_job_slots_event(payload): 69 | """Parser for `mali_job_slots_event` tracepoint""" 70 | try: 71 | match = re.match(mali_job_slots_event_pattern, payload) 72 | if match: 73 | match_group_dict = match.groupdict() 74 | return MaliJobSlotsEvent(**match_group_dict) 75 | except Exception, e: 76 | raise ParserError(e.message) 77 | -------------------------------------------------------------------------------- /ftrace/parsers/mali_pm_power_off.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'mali_pm_power_off' 28 | 29 | __all__ = [TRACEPOINT] 30 | 31 | MaliPMPowerOffBase = namedtuple(TRACEPOINT, 32 | [ 33 | 'event', 34 | 'value', 35 | ] 36 | ) 37 | 38 | class MaliPMPowerOff(MaliPMPowerOffBase): 39 | __slots__ = () 40 | def __new__(cls, event, value): 41 | 42 | value=int(value) 43 | 44 | return super(cls, MaliPMPowerOff).__new__( 45 | cls, 46 | event=event, 47 | value=value, 48 | ) 49 | 50 | mali_pm_power_off_pattern = re.compile( 51 | r""" 52 | event=(?P\d+)\s+ 53 | =(?P\d+) 54 | """, 55 | re.X|re.M 56 | ) 57 | 58 | @register_parser 59 | def mali_pm_power_off(payload): 60 | """Parser for `mali_pm_power_off` tracepoint""" 61 | try: 62 | match = re.match(mali_pm_power_off_pattern, payload) 63 | if match: 64 | match_group_dict = match.groupdict() 65 | return MaliPMPowerOff(**match_group_dict) 66 | except Exception, e: 67 | raise ParserError(e.message) 68 | -------------------------------------------------------------------------------- /ftrace/parsers/mali_pm_power_on.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'mali_pm_power_on' 28 | 29 | __all__ = [TRACEPOINT] 30 | 31 | MaliPMPowerOnBase = namedtuple(TRACEPOINT, 32 | [ 33 | 'event', 34 | 'value', 35 | ] 36 | ) 37 | 38 | class MaliPMPowerOn(MaliPMPowerOnBase): 39 | __slots__ = () 40 | def __new__(cls, event, value): 41 | 42 | value=int(value) 43 | 44 | return super(cls, MaliPMPowerOn).__new__( 45 | cls, 46 | event=event, 47 | value=value, 48 | ) 49 | 50 | mali_pm_power_on_pattern = re.compile( 51 | r""" 52 | event=(?P\d+)\s+ 53 | =(?P\d+) 54 | """, 55 | re.X|re.M 56 | ) 57 | 58 | @register_parser 59 | def mali_pm_power_on(payload): 60 | """Parser for `mali_pm_power_on` tracepoint""" 61 | try: 62 | match = re.match(mali_pm_power_on_pattern, payload) 63 | if match: 64 | match_group_dict = match.groupdict() 65 | return MaliPMPowerOn(**match_group_dict) 66 | except Exception, e: 67 | raise ParserError(e.message) 68 | -------------------------------------------------------------------------------- /ftrace/parsers/mali_pm_status.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from .register import register_parser 23 | from collections import namedtuple 24 | from ftrace.common import ParserError 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'mali_pm_status' 28 | 29 | __all__ = [TRACEPOINT] 30 | 31 | MaliPMStatusBase = namedtuple(TRACEPOINT, 32 | [ 33 | 'event', 34 | 'value', 35 | ] 36 | ) 37 | 38 | class MaliPMStatus(MaliPMStatusBase): 39 | __slots__ = () 40 | def __new__(cls, event, value): 41 | 42 | value=int(value) 43 | 44 | return super(cls, MaliPMStatus).__new__( 45 | cls, 46 | event=event, 47 | value=value, 48 | ) 49 | 50 | mali_pm_status_pattern = re.compile( 51 | r""" 52 | event=(?P\d+)\s+ 53 | =(?P\d+) 54 | """, 55 | re.X|re.M 56 | ) 57 | 58 | @register_parser 59 | def mali_pm_status(payload): 60 | """Parser for `mali_pm_status` tracepoint""" 61 | try: 62 | match = re.match(mali_pm_status_pattern, payload) 63 | if match: 64 | match_group_dict = match.groupdict() 65 | return MaliPMStatus(**match_group_dict) 66 | except Exception, e: 67 | raise ParserError(e.message) 68 | -------------------------------------------------------------------------------- /ftrace/parsers/memory_bus_usage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from .register import register_parser 23 | from collections import namedtuple, defaultdict 24 | #from ftrace.third_party.cnamedtuple import namedtuple 25 | from ftrace.common import ConstantBase, ParserError 26 | 27 | TRACEPOINT = 'memory_bus_usage' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | 33 | MemoryBusUsageBase = namedtuple(TRACEPOINT, 34 | [ 35 | 'bus', # Bus name 36 | 'rw_bytes', # Bytes written/read 37 | 'r_bytes', # Bytes read 38 | 'w_bytes', # Bytes written 39 | 'cycles', # Bus cycles 40 | 'ns', # nanoseconds 41 | 'r_MBps', # Read throughput (MB/s) 42 | 'w_MBps', # Write throughput (MB/s) 43 | ] 44 | ) 45 | 46 | 47 | class MemoryBusUsage(MemoryBusUsageBase): 48 | __slots__ = () 49 | def __new__(cls, bus, rw_bytes, r_bytes, w_bytes, cycles, ns): 50 | rw_bytes = int(rw_bytes) 51 | r_bytes = int(r_bytes) 52 | w_bytes = int(w_bytes) 53 | cycles = int(cycles) 54 | ns = int(ns) 55 | 56 | r_MBps = (1E9 * (r_bytes / ns))/ 1048576.0 57 | w_MBps = (1E9 * (w_bytes / ns))/ 1048576.0 58 | 59 | return super(cls, MemoryBusUsage).__new__( 60 | cls, 61 | bus=bus, 62 | rw_bytes=rw_bytes, 63 | r_bytes=r_bytes, 64 | w_bytes=w_bytes, 65 | cycles=cycles, 66 | ns=ns, 67 | r_MBps=r_MBps, 68 | w_MBps=w_MBps, 69 | ) 70 | 71 | memory_bus_usage_pattern = re.compile( 72 | r"""bus=(?P.+)\s+ 73 | rw_bytes=(?P\d+)\s+ 74 | r_bytes=(?P\d+)\s+ 75 | w_bytes=(?P\d+)\s+ 76 | cycles=(?P\d+)\s+ 77 | ns=(?P\d+) 78 | """, 79 | re.X|re.M 80 | ) 81 | 82 | @register_parser 83 | def memory_bus_usage(payload): 84 | """Parser for `memory_bus_usage` tracepoint""" 85 | try: 86 | match = re.match(memory_bus_usage_pattern, payload) 87 | if match: 88 | match_group_dict = match.groupdict() 89 | return MemoryBusUsage(**match_group_dict) 90 | except Exception, e: 91 | raise ParserError(e.message) 92 | -------------------------------------------------------------------------------- /ftrace/parsers/register.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | try: 18 | 19 | from logbook import Logger 20 | except ImportError: 21 | import logging 22 | logging.basicConfig() 23 | from logging import getLogger as Logger 24 | 25 | log = Logger('Parser') 26 | 27 | PARSERS = {} 28 | 29 | def register_parser(func): 30 | """Decorator to register ftrace parser""" 31 | global PARSERS 32 | name = func.__name__ 33 | log.info("Registering {name} parser".format(name=name)) 34 | PARSERS[name] = func 35 | return func 36 | 37 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_boost_cpu.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | try: 25 | from ftrace.third_party.cnamedtuple import namedtuple 26 | except ImportError: 27 | from collections import namedtuple 28 | 29 | 30 | TRACEPOINT = 'sched_boost_cpu' 31 | 32 | __all__ = [TRACEPOINT] 33 | 34 | SchedBoostCpuBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'cpu' 37 | 'util', 38 | 'margin' 39 | ] 40 | ) 41 | 42 | class SchedBoostCpu(SchedBoostCpuBase): 43 | __slots__ = () 44 | def __new__(cls, cpu, util, margin): 45 | cpu = int(cpu) 46 | util = int(util) 47 | margin = int(margin) 48 | 49 | return super(cls, SchedBoostCpu).__new__( 50 | cls, 51 | cpu=cpu, 52 | util=util, 53 | margin=margin, 54 | ) 55 | 56 | sched_boost_cpu_pattern = re.compile( 57 | r""" 58 | cpu=(?P\d+)\s+ 59 | util=(?P\d+)\s+ 60 | margin=(?P\d+) 61 | """, 62 | re.X|re.M 63 | ) 64 | 65 | @register_parser 66 | def sched_boost_cpu(payload): 67 | """Parser for `sched_boost_cpu` tracepoint""" 68 | try: 69 | match = re.match(sched_boost_cpu_pattern, payload) 70 | if match: 71 | match_group_dict = match.groupdict() 72 | return SchedBoostCpu(**match_group_dict) 73 | except Exception, e: 74 | raise ParserError(e.message) 75 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_contrib_scale_f.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | try: 25 | from ftrace.third_party.cnamedtuple import namedtuple 26 | except ImportError: 27 | from collections import namedtuple 28 | 29 | 30 | TRACEPOINT = 'sched_contrib_scale_f' 31 | 32 | __all__ = [TRACEPOINT] 33 | 34 | SchedContribScaleFBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'cpu' 37 | 'freq_scale_factor', 38 | 'cpu_scale_factor' 39 | ] 40 | ) 41 | 42 | class SchedContribScaleF(SchedContribScaleFBase): 43 | __slots__ = () 44 | def __new__(cls, cpu, freq_scale_factor, cpu_scale_factor): 45 | cpu = int(cpu) 46 | freq_scale_factor = int(freq_scale_factor) 47 | cpu_scale_factor = int(cpu_scale_factor) 48 | 49 | return super(cls, SchedContribScaleF).__new__( 50 | cls, 51 | cpu=cpu, 52 | freq_scale_factor=freq_scale_factor, 53 | cpu_scale_factor=cpu_scale_factor, 54 | ) 55 | 56 | sched_contrib_scale_f_pattern = re.compile( 57 | r""" 58 | cpu=(?P\d+)\s+ 59 | freq_scale_factor=(?P\d+)\s+ 60 | cpu_scale_factor=(?P\d+) 61 | """, 62 | re.X|re.M 63 | ) 64 | 65 | @register_parser 66 | def sched_contrib_scale_f(payload): 67 | """Parser for `sched_contrib_scale_f` tracepoint""" 68 | try: 69 | match = re.match(sched_contrib_scale_f_pattern, payload) 70 | if match: 71 | match_group_dict = match.groupdict() 72 | return SchedContribScaleF(**match_group_dict) 73 | except Exception, e: 74 | raise ParserError(e.message) 75 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_hmp_migrate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from ftrace.sched_hmp import HMPMigrateMapping 25 | try: 26 | from ftrace.third_party.cnamedtuple import namedtuple 27 | except ImportError: 28 | from collections import namedtuple 29 | 30 | 31 | TRACEPOINT = 'sched_hmp_migrate' 32 | 33 | __all__ = [TRACEPOINT] 34 | 35 | SchedHMPMigrateBase = namedtuple(TRACEPOINT, 36 | [ 37 | 'comm', # Task name 38 | 'pid', # Process pid 39 | 'dest', # Dest. cpu 40 | 'force' 41 | ] 42 | ) 43 | 44 | class SchedHMPMigrate(SchedHMPMigrateBase): 45 | __slots__ = () 46 | def __new__(cls, comm, pid, dest, force): 47 | pid = int(pid) 48 | dest = int(dest) 49 | force = force 50 | 51 | return super(cls, SchedHMPMigrate).__new__( 52 | cls, 53 | comm=comm, 54 | pid=pid, 55 | dest=dest, 56 | force=force, 57 | ) 58 | 59 | sched_hmp_migrate_pattern = re.compile( 60 | r""" 61 | comm=(?P.+)\s+ 62 | pid=(?P\d+)\s+ 63 | dest=(?P\d+)\s+ 64 | force=(?P\d+) 65 | """, 66 | re.X|re.M 67 | ) 68 | 69 | @register_parser 70 | def sched_hmp_migrate(payload): 71 | """Parser for `sched_hmp_migrate` tracepoint""" 72 | try: 73 | match = re.match(sched_hmp_migrate_pattern, payload) 74 | if match: 75 | match_group_dict = match.groupdict() 76 | match_group_dict['force'] = HMPMigrateMapping[int(match_group_dict['force'])] 77 | return SchedHMPMigrate(**match_group_dict) 78 | except Exception, e: 79 | raise ParserError(e.message) 80 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_load_avg_cpu.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | try: 25 | from ftrace.third_party.cnamedtuple import namedtuple 26 | except ImportError: 27 | from collections import namedtuple 28 | 29 | 30 | TRACEPOINT = 'sched_load_avg_cpu' 31 | 32 | __all__ = [TRACEPOINT] 33 | 34 | SchedLoadAvgCpuBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'cpu' 37 | 'load_avg', 38 | 'util_avg' 39 | ] 40 | ) 41 | 42 | class SchedLoadAvgCpu(SchedLoadAvgCpuBase): 43 | __slots__ = () 44 | def __new__(cls, cpu, load_avg, util_avg): 45 | cpu = int(cpu) 46 | load_avg = int(load_avg) 47 | util_avg = int(util_avg) 48 | 49 | return super(cls, SchedLoadAvgCpu).__new__( 50 | cls, 51 | cpu=cpu, 52 | load_avg=load_avg, 53 | util_avg=util_avg, 54 | ) 55 | 56 | sched_load_avg_cpu_pattern = re.compile( 57 | r""" 58 | cpu=(?P\d+)\s+ 59 | load_avg=(?P\d+)\s+ 60 | util_avg=(?P\d+) 61 | """, 62 | re.X|re.M 63 | ) 64 | 65 | @register_parser 66 | def sched_load_avg_cpu(payload): 67 | """Parser for `sched_load_avg_cpu` tracepoint""" 68 | try: 69 | match = re.match(sched_load_avg_cpu_pattern, payload) 70 | if match: 71 | match_group_dict = match.groupdict() 72 | return SchedLoadAvgCpu(**match_group_dict) 73 | except Exception, e: 74 | raise ParserError(e.message) 75 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_load_avg_task.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from ftrace.globals import SCHED_RAVG_WINDOW 24 | from .register import register_parser 25 | try: 26 | from ftrace.third_party.cnamedtuple import namedtuple 27 | except ImportError: 28 | from collections import namedtuple 29 | 30 | 31 | TRACEPOINT = 'sched_load_avg_task' 32 | 33 | 34 | __all__ = [TRACEPOINT] 35 | 36 | 37 | SchedLoadAvgTaskBase = namedtuple(TRACEPOINT, 38 | [ 39 | 'pid', 40 | 'comm', 41 | 'cpu', 42 | 'load_avg', 43 | 'util_avg', 44 | 'load_sum', 45 | 'util_sum', 46 | 'period_contrib', 47 | ] 48 | ) 49 | 50 | 51 | class SchedLoadAvgTask(SchedLoadAvgTaskBase): 52 | __slots__ = () 53 | def __new__(cls, pid, comm, load_avg, 54 | util_avg, load_sum, util_sum, period_contrib): 55 | pid = int(pid) 56 | load_avg = int(load_avg) 57 | util_avg = int(util_avg) 58 | load_sum = int(load_sum) 59 | util_sum = int(util_sum) 60 | period_contrib = int(period_contrib) 61 | 62 | return super(cls, SchedLoadAvgTask).__new__( 63 | cls, 64 | pid=pid, 65 | comm=comm, 66 | load_avg=load_avg, 67 | util_avg=util_avg, 68 | load_sum=load_sum, 69 | util_sum=util_sum, 70 | period_contrib=period_contrib, 71 | ) 72 | 73 | sched_load_avg_task_pattern = re.compile( 74 | r"""comm=(?P.*)\s+ 75 | pid=(?P\d+)\s+ 76 | cpu=(?P\d+)\s+ 77 | load_avg=(?P\d+)\s+ 78 | util_avg=(?P\d+)\s+ 79 | load_sum=(?P\d+)\s+ 80 | util_sum=(?P\d+)\s+ 81 | period_contrib=(?P\d+)\s 82 | """, 83 | re.X|re.M 84 | ) 85 | 86 | @register_parser 87 | def sched_load_avg_task(payload): 88 | """Parser for `sched_load_avg_task` tracepoint""" 89 | try: 90 | match = re.match(sched_load_avg_task_pattern, payload) 91 | if match: 92 | match_group_dict = match.groupdict() 93 | return SchedLoadAvgTask(**match_group_dict) 94 | except Exception, e: 95 | raise ParserError(e.message) 96 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_migrate_task.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'sched_migrate_task' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | # 33 | 34 | SchedMigrateTaskBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'comm', # Task name 37 | 'pid', # Process pid 38 | 'prio', # Process priority 39 | 'load', # load if available 40 | 'orig_cpu', # Orig. cpu 41 | 'dest_cpu', # Dest. cpu 42 | ] 43 | ) 44 | 45 | class SchedMigrateTask(SchedMigrateTaskBase): 46 | __slots__ = () 47 | def __new__(cls, comm, pid, prio, orig_cpu, dest_cpu, load=None): 48 | pid = int(pid) 49 | prio = int(prio) 50 | orig_cpu = int(orig_cpu) 51 | dest_cpu = int(dest_cpu) 52 | load = int(load) if load else load 53 | 54 | return super(cls, SchedMigrateTask).__new__( 55 | cls, 56 | comm=comm, 57 | pid=pid, 58 | prio=prio, 59 | load=load, 60 | orig_cpu=orig_cpu, 61 | dest_cpu=dest_cpu, 62 | ) 63 | 64 | sched_migrate_pattern = re.compile( 65 | r""" 66 | comm=(?P.+)\s+ 67 | pid=(?P\d+)\s+ 68 | prio=(?P\d+)\s+ 69 | \w*\D*(?P\d*)\s* 70 | orig_cpu=(?P\d+)\s+ 71 | dest_cpu=(?P\d+) 72 | """, 73 | re.X|re.M 74 | ) 75 | 76 | @register_parser 77 | def sched_migrate_task(payload): 78 | """Parser for `sched_migrate_task` tracepoint""" 79 | try: 80 | match = re.match(sched_migrate_pattern, payload) 81 | if match: 82 | match_group_dict = match.groupdict() 83 | return SchedMigrateTask(**match_group_dict) 84 | except Exception, e: 85 | raise ParserError(e.message) 86 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_rq_nr_running.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | 25 | try: 26 | from ftrace.third_party.cnamedtuple import namedtuple 27 | except ImportError: 28 | from collections import namedtuple 29 | 30 | 31 | TRACEPOINT = 'sched_rq_nr_running' 32 | 33 | 34 | __all__ = [TRACEPOINT] 35 | 36 | 37 | SchedRqNrRunningBase = namedtuple(TRACEPOINT, 38 | [ 39 | 'cpu', 40 | 'nr_running', 41 | 'nr_iowait' 42 | ] 43 | ) 44 | 45 | 46 | class SchedRqNrRunning(SchedRqNrRunningBase): 47 | __slots__ = () 48 | def __new__(cls, cpu, nr_running, nr_iowait): 49 | cpu = int(cpu) 50 | nr_running = int(nr_running) 51 | nr_iowait = int(nr_iowait) 52 | 53 | return super(cls, SchedRqNrRunning).__new__( 54 | cls, 55 | cpu=cpu, 56 | nr_running=nr_running, 57 | nr_iowait=nr_iowait, 58 | ) 59 | 60 | 61 | sched_rq_nr_running_pattern = re.compile( 62 | r"""cpu=(?P\d+)\s+ 63 | nr_running=(?P\d+)\s+ 64 | nr_iowait=(?P\d+)\s+ 65 | """, 66 | re.X|re.M 67 | ) 68 | 69 | @register_parser 70 | def sched_rq_nr_running(payratio): 71 | """Parser for `sched_rq_nr_running` tracepoint""" 72 | try: 73 | match = re.match(sched_rq_nr_running_pattern, payratio) 74 | if match: 75 | match_group_dict = match.groupdict() 76 | return SchedRqNrRunning(**match_group_dict) 77 | except Exception, e: 78 | raise ParserError(e.message) 79 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_rq_runnable_load.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | 25 | try: 26 | from ftrace.third_party.cnamedtuple import namedtuple 27 | except ImportError: 28 | from collections import namedtuple 29 | 30 | 31 | TRACEPOINT = 'sched_rq_runnable_load' 32 | 33 | 34 | __all__ = [TRACEPOINT] 35 | 36 | 37 | SchedRQRunnableLoadBase = namedtuple(TRACEPOINT, 38 | [ 39 | 'cpu', 40 | 'load' 41 | ] 42 | ) 43 | 44 | 45 | class SchedRQRunnableLoad(SchedRQRunnableLoadBase): 46 | """ 47 | Tracked rq runnable ratio [0..1023]. 48 | """ 49 | __slots__ = () 50 | def __new__(cls, cpu, load): 51 | cpu = int(cpu) 52 | load = float(load) 53 | 54 | return super(cls, SchedRQRunnableLoad).__new__( 55 | cls, 56 | cpu=cpu, 57 | load=load, 58 | ) 59 | 60 | @property 61 | def normalized_load(self): 62 | "" 63 | return float(self.load)/1023.0 64 | 65 | sched_rq_runnable_load_pattern = re.compile( 66 | r"""cpu=(?P\d+)\s+ 67 | load=(?P\d+)\s+ 68 | """, 69 | re.X|re.M 70 | ) 71 | 72 | @register_parser 73 | def sched_rq_runnable_load(payload): 74 | """Parser for `sched_rq_runnable_load` tracepoint""" 75 | try: 76 | match = re.match(sched_rq_runnable_load_pattern, payload) 77 | if match: 78 | match_group_dict = match.groupdict() 79 | return SchedRQRunnableLoad(**match_group_dict) 80 | except Exception, e: 81 | raise ParserError(e.message) 82 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_rq_runnable_ratio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | 25 | try: 26 | from ftrace.third_party.cnamedtuple import namedtuple 27 | except ImportError: 28 | from collections import namedtuple 29 | 30 | 31 | TRACEPOINT = 'sched_rq_runnable_ratio' 32 | 33 | 34 | __all__ = [TRACEPOINT] 35 | 36 | 37 | SchedRQRunnableRatioBase = namedtuple(TRACEPOINT, 38 | [ 39 | 'cpu', 40 | 'ratio' 41 | ] 42 | ) 43 | 44 | 45 | class SchedRQRunnableRatio(SchedRQRunnableRatioBase): 46 | """ 47 | Tracked rq runnable ratio [0..1023]. 48 | """ 49 | __slots__ = () 50 | def __new__(cls, cpu, ratio): 51 | cpu = int(cpu) 52 | ratio = float(self.ratio)/1023.0 53 | 54 | return super(cls, SchedRQRunnableRatio).__new__( 55 | cls, 56 | cpu=cpu, 57 | ratio=ratio, 58 | ) 59 | 60 | sched_rq_runnable_ratio_pattern = re.compile( 61 | r"""cpu=(?P\d+)\s+ 62 | ratio=(?P\d+)\s+ 63 | """, 64 | re.X|re.M 65 | ) 66 | 67 | @register_parser 68 | def sched_rq_runnable_ratio(payratio): 69 | """Parser for `sched_rq_runnable_ratio` tracepoint""" 70 | try: 71 | match = re.match(sched_rq_runnable_ratio_pattern, payratio) 72 | if match: 73 | match_group_dict = match.groupdict() 74 | return SchedRQRunnableRatio(**match_group_dict) 75 | except Exception, e: 76 | raise ParserError(e.message) 77 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_switch.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | from ftrace.task import TaskStateMapping 27 | 28 | TRACEPOINT = 'sched_switch' 29 | 30 | 31 | __all__ = [TRACEPOINT] 32 | 33 | # prev_comm=swapper/7 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=snapshot-test-2 next_pid=2243 next_prio=120 34 | 35 | SchedSwitchBase = namedtuple(TRACEPOINT, 36 | [ 37 | 'prev_comm', # Prev. Task name 38 | 'prev_pid', # Prev. process pid 39 | 'prev_prio', # Prev. process priority 40 | 'prev_state', # Prev. process state 41 | 'next_comm', # Next Task name 42 | 'next_pid', # Next task pid 43 | 'next_prio', # Next task prio 44 | ] 45 | ) 46 | 47 | 48 | class SchedSwitch(SchedSwitchBase): 49 | __slots__ = () 50 | def __new__(cls, prev_comm, prev_pid, prev_prio, 51 | prev_state, next_comm, next_pid, next_prio): 52 | prev_pid = int(prev_pid) 53 | prev_prio = int(prev_prio) 54 | next_pid = int(next_pid) 55 | next_prio = int(next_prio) 56 | 57 | return super(cls, SchedSwitch).__new__( 58 | cls, 59 | prev_comm=prev_comm, 60 | prev_pid=prev_pid, 61 | prev_prio=prev_prio, 62 | prev_state=prev_state, 63 | next_comm=next_comm, 64 | next_pid=next_pid, 65 | next_prio=next_prio, 66 | ) 67 | 68 | sched_switch_pattern = re.compile( 69 | r"""prev_comm=(?P.*)\s+ 70 | prev_pid=(?P\d+)\s+ 71 | prev_prio=(?P\d+)\s+ 72 | prev_state=(?P.+)\s+ # todo: handled corner cases e.g. D|W 73 | ==>\s+ 74 | next_comm=(?P.*)\s+ 75 | next_pid=(?P\d+)\s+ 76 | next_prio=(?P\d+) 77 | """, 78 | re.X|re.M 79 | ) 80 | 81 | @register_parser 82 | def sched_switch(payload): 83 | """Parser for `sched_switch` tracepoint""" 84 | try: 85 | match = re.match(sched_switch_pattern, payload) 86 | if match: 87 | match_group_dict = match.groupdict() 88 | match_group_dict['prev_state'] = TaskStateMapping[match_group_dict['prev_state']] 89 | return SchedSwitch(**match_group_dict) 90 | except Exception, e: 91 | raise ParserError(e.message) 92 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_task_load_contrib.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | 25 | try: 26 | from ftrace.third_party.cnamedtuple import namedtuple 27 | except ImportError: 28 | from collections import namedtuple 29 | 30 | 31 | TRACEPOINT = 'sched_task_load_contrib' 32 | 33 | 34 | __all__ = [TRACEPOINT] 35 | 36 | 37 | SchedTaskLoadContribBase = namedtuple(TRACEPOINT, 38 | [ 39 | 'comm', 40 | 'pid', 41 | 'load_contrib' 42 | ] 43 | ) 44 | 45 | 46 | class SchedTaskLoadContrib(SchedTaskLoadContribBase): 47 | __slots__ = () 48 | def __new__(cls, comm, pid, load_contrib): 49 | pid = int(pid) 50 | load_contrib = float(load_contrib)/1023. 51 | 52 | return super(cls, SchedTaskLoadContrib).__new__( 53 | cls, 54 | comm=comm, 55 | pid=pid, 56 | load_contrib=load_contrib, 57 | ) 58 | 59 | sched_task_load_contrib_pattern = re.compile( 60 | r"""comm=(?P.*)\s+ 61 | pid=(?P\d+)\s+ 62 | load_contrib=(?P\d+)\s+ 63 | """, 64 | re.X|re.M 65 | ) 66 | 67 | @register_parser 68 | def sched_task_load_contrib(payload): 69 | """Parser for `sched_task_load_contrib` tracepoint""" 70 | try: 71 | match = re.match(sched_task_load_contrib_pattern, payload) 72 | if match: 73 | match_group_dict = match.groupdict() 74 | return SchedTaskLoadContrib(**match_group_dict) 75 | except Exception, e: 76 | raise ParserError(e.message) 77 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_task_runnable_ratio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | 25 | try: 26 | from ftrace.third_party.cnamedtuple import namedtuple 27 | except ImportError: 28 | from collections import namedtuple 29 | 30 | 31 | TRACEPOINT = 'sched_task_runnable_ratio' 32 | 33 | 34 | __all__ = [TRACEPOINT] 35 | 36 | 37 | SchedTaskRunnableRatioBase = namedtuple(TRACEPOINT, 38 | [ 39 | 'comm', 40 | 'pid', 41 | 'ratio' 42 | ] 43 | ) 44 | 45 | 46 | class SchedTaskRunnableRatio(SchedTaskRunnableRatioBase): 47 | __slots__ = () 48 | def __new__(cls, comm, pid, ratio): 49 | pid = int(pid) 50 | ratio = float(ratio)/1023. 51 | 52 | return super(cls, SchedTaskRunnableRatio).__new__( 53 | cls, 54 | comm=comm, 55 | pid=pid, 56 | ratio=ratio, 57 | ) 58 | 59 | sched_task_runnable_ratio_pattern = re.compile( 60 | r"""comm=(?P.*)\s+ 61 | pid=(?P\d+)\s+ 62 | ratio=(?P\d+)\s+ 63 | """, 64 | re.X|re.M 65 | ) 66 | 67 | @register_parser 68 | def sched_task_runnable_ratio(payload): 69 | """Parser for `sched_task_runnable_ratio` tracepoint""" 70 | try: 71 | match = re.match(sched_task_runnable_ratio_pattern, payload) 72 | if match: 73 | match_group_dict = match.groupdict() 74 | return SchedTaskRunnableRatio(**match_group_dict) 75 | except Exception, e: 76 | raise ParserError(e.message) 77 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_task_usage_ratio.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | 25 | try: 26 | from ftrace.third_party.cnamedtuple import namedtuple 27 | except ImportError: 28 | from collections import namedtuple 29 | 30 | 31 | TRACEPOINT = 'sched_task_usage_ratio' 32 | 33 | 34 | __all__ = [TRACEPOINT] 35 | 36 | 37 | SchedTaskUsageRatioBase = namedtuple(TRACEPOINT, 38 | [ 39 | 'comm', 40 | 'pid', 41 | 'ratio' 42 | ] 43 | ) 44 | 45 | 46 | class SchedTaskUsageRatio(SchedTaskUsageRatioBase): 47 | """ 48 | Tracked task cpu usage ratio [0..1023]. 49 | """ 50 | __slots__ = () 51 | def __new__(cls, comm, pid, ratio): 52 | pid = int(pid) 53 | ratio = float(self.ratio)/1023.0 54 | 55 | return super(cls, SchedTaskUsageRatio).__new__( 56 | cls, 57 | comm=comm, 58 | pid=pid, 59 | ratio=ratio, 60 | ) 61 | 62 | sched_task_usage_ratio_pattern = re.compile( 63 | r"""comm=(?P.*)\s+ 64 | pid=(?P\d+)\s+ 65 | ratio=(?P\d+)\s+ 66 | """, 67 | re.X|re.M 68 | ) 69 | 70 | @register_parser 71 | def sched_task_usage_ratio(payload): 72 | """Parser for `sched_task_usage_ratio` tracepoint""" 73 | try: 74 | match = re.match(sched_task_usage_ratio_pattern, payload) 75 | if match: 76 | match_group_dict = match.groupdict() 77 | return SchedTaskUsageRatio(**match_group_dict) 78 | except Exception, e: 79 | raise ParserError(e.message) 80 | -------------------------------------------------------------------------------- /ftrace/parsers/sched_wakeup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | 26 | TRACEPOINT = 'sched_wakeup' 27 | 28 | 29 | __all__ = [TRACEPOINT] 30 | 31 | # NOTE: 'success' is optional for some android phones and linux kernels 32 | # comm=tfm_b6bcf800 pid=1714 prio=35 success=1 target_cpu=000 33 | 34 | SchedWakeupBase = namedtuple(TRACEPOINT, 35 | [ 36 | 'comm', # Task name 37 | 'pid', # Process pid 38 | 'prio', # Process priority 39 | 'success', # success flag 40 | 'target_cpu', # Target cpu 41 | ] 42 | ) 43 | 44 | class SchedWakeup(SchedWakeupBase): 45 | __slots__ = () 46 | def __new__(cls, comm, pid, prio, success, target_cpu): 47 | pid = int(pid) 48 | prio = int(prio) 49 | success = 1 if success is None else int(success) 50 | target_cpu = int(target_cpu) 51 | 52 | return super(cls, SchedWakeup).__new__( 53 | cls, 54 | comm=comm, 55 | pid=pid, 56 | prio=prio, 57 | success=success, 58 | target_cpu=target_cpu, 59 | ) 60 | 61 | sched_wakeup_pattern = re.compile( 62 | r""" 63 | comm=(?P.*)\s+ 64 | pid=(?P\d+)\s+ 65 | prio=(?P\d+)\s+ 66 | (success=(?P\d+)\s+)? 67 | target_cpu=(?P\d+) 68 | """, 69 | re.X|re.M 70 | ) 71 | 72 | @register_parser 73 | def sched_wakeup(payload): 74 | """Parser for `sched_wakeup` tracepoint""" 75 | try: 76 | match = re.match(sched_wakeup_pattern, payload) 77 | if match: 78 | match_group_dict = match.groupdict() 79 | return SchedWakeup(**match_group_dict) 80 | except Exception, e: 81 | raise ParserError(e.message) 82 | -------------------------------------------------------------------------------- /ftrace/parsers/softirq_entry.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'softirq_entry' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | SoftIRQEntryBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'vec', 35 | 'action', 36 | ] 37 | ) 38 | 39 | class SoftIRQEntry(SoftIRQEntryBase): 40 | __slots__ = () 41 | def __new__(cls, vec, action): 42 | vec = int(vec) 43 | return super(cls, SoftIRQEntry).__new__( 44 | cls, 45 | vec=vec, 46 | action=action, 47 | ) 48 | 49 | softirq_entry_pattern = re.compile( 50 | r""" 51 | vec=(?P\d+)\s+ 52 | \[action=(?P.+)\] 53 | """, 54 | re.X|re.M 55 | ) 56 | 57 | @register_parser 58 | def softirq_entry(payload): 59 | """Parser for `softirq_entry` tracepoint""" 60 | try: 61 | match = re.match(softirq_entry_pattern, payload) 62 | if match: 63 | match_group_dict = match.groupdict() 64 | return SoftIRQEntry(**match_group_dict) 65 | except Exception, e: 66 | raise ParserError(e.message) 67 | -------------------------------------------------------------------------------- /ftrace/parsers/softirq_exit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'softirq_exit' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | SoftIRQExitBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'vec', 35 | 'action', 36 | ] 37 | ) 38 | 39 | class SoftIRQExit(SoftIRQExitBase): 40 | __slots__ = () 41 | def __new__(cls, vec, action): 42 | vec = int(vec) 43 | return super(cls, SoftIRQExit).__new__( 44 | cls, 45 | vec=vec, 46 | action=action, 47 | ) 48 | 49 | softirq_exit_pattern = re.compile( 50 | r""" 51 | vec=(?P\d+)\s+ 52 | \[action=(?P.+)\] 53 | """, 54 | re.X|re.M 55 | ) 56 | 57 | @register_parser 58 | def softirq_exit(payload): 59 | """Parser for `softirq_exit` tracepoint""" 60 | try: 61 | match = re.match(softirq_exit_pattern, payload) 62 | if match: 63 | match_group_dict = match.groupdict() 64 | return SoftIRQExit(**match_group_dict) 65 | except Exception, e: 66 | raise ParserError(e.message) 67 | -------------------------------------------------------------------------------- /ftrace/parsers/softirq_raise.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'softirq_raise' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | SoftIRQRaiseBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'vec', 35 | 'action', 36 | ] 37 | ) 38 | 39 | class SoftIRQRaise(SoftIRQRaiseBase): 40 | __slots__ = () 41 | def __new__(cls, vec, action): 42 | vec = int(vec) 43 | return super(cls, SoftIRQRaise).__new__( 44 | cls, 45 | vec=vec, 46 | action=action, 47 | ) 48 | 49 | softirq_raise_pattern = re.compile( 50 | r""" 51 | vec=(?P\d+)\s+ 52 | \[action=(?P.+)\] 53 | """, 54 | re.X|re.M 55 | ) 56 | 57 | @register_parser 58 | def softirq_raise(payload): 59 | """Parser for `softirq_raise` tracepoint""" 60 | try: 61 | match = re.match(softirq_raise_pattern, payload) 62 | if match: 63 | match_group_dict = match.groupdict() 64 | return SoftIRQRaise(**match_group_dict) 65 | except Exception, e: 66 | raise ParserError(e.message) 67 | -------------------------------------------------------------------------------- /ftrace/parsers/sync_pt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'sync_pt' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | SyncPTBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'name', 35 | 'value', 36 | ] 37 | ) 38 | 39 | class SyncPT(SyncPTBase): 40 | __slots__ = () 41 | def __new__(cls, name, value): 42 | return super(cls, SyncPT).__new__( 43 | cls, 44 | name=name, 45 | value=value, 46 | ) 47 | 48 | sync_pt_pattern = re.compile( 49 | r""" 50 | name=(?P.+)\s+ 51 | value=(?P.+) 52 | """, 53 | re.X|re.M 54 | ) 55 | 56 | @register_parser 57 | def sync_pt(payload): 58 | """Parser for `sync_pt` tracepoint""" 59 | try: 60 | match = re.match(sync_pt_pattern, payload) 61 | if match: 62 | match_group_dict = match.groupdict() 63 | return SyncPT(**match_group_dict) 64 | except Exception, e: 65 | raise ParserError(e.message) 66 | -------------------------------------------------------------------------------- /ftrace/parsers/sync_timeline.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'sync_timeline' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | SyncTimelineBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'name', 35 | 'value', 36 | ] 37 | ) 38 | 39 | class SyncTimeline(SyncTimelineBase): 40 | __slots__ = () 41 | def __new__(cls, name, value): 42 | return super(cls, SyncTimeline).__new__( 43 | cls, 44 | name=name, 45 | value=value, 46 | ) 47 | 48 | sync_timeline_pattern = re.compile( 49 | r""" 50 | name=(?P.+)\s+ 51 | value=(?P.+) 52 | """, 53 | re.X|re.M 54 | ) 55 | 56 | @register_parser 57 | def sync_timeline(payload): 58 | """Parser for `sync_timeline` tracepoint""" 59 | try: 60 | match = re.match(sync_timeline_pattern, payload) 61 | if match: 62 | match_group_dict = match.groupdict() 63 | return SyncTimeline(**match_group_dict) 64 | except Exception, e: 65 | raise ParserError(e.message) 66 | -------------------------------------------------------------------------------- /ftrace/parsers/sync_wait.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'sync_wait' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | SyncWaitBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'name', 35 | 'status', 36 | 'begin', 37 | ] 38 | ) 39 | 40 | class SyncWait(SyncWaitBase): 41 | __slots__ = () 42 | def __new__(cls, name, status, begin): 43 | status = int(status) 44 | return super(cls, SyncWait).__new__( 45 | cls, 46 | state=state, 47 | name=name, 48 | begin=begin, 49 | ) 50 | 51 | sync_wait_pattern = re.compile( 52 | r""" 53 | (?P\w+)\s+ 54 | name=(?P.+)\s+ 55 | status=(?P\d+) 56 | """, 57 | re.X|re.M 58 | ) 59 | 60 | @register_parser 61 | def sync_wait(payload): 62 | """Parser for `sync_wait` tracepoint""" 63 | try: 64 | match = re.match(sync_wait_pattern, payload) 65 | if match: 66 | match_group_dict = match.groupdict() 67 | return SyncWait(**match_group_dict) 68 | except Exception, e: 69 | raise ParserError(e.message) 70 | -------------------------------------------------------------------------------- /ftrace/parsers/tsens_read.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'tsens_read' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | 33 | TsensReadBase = namedtuple(TRACEPOINT, 34 | [ 35 | 'temp', 36 | 'sensor' 37 | ] 38 | ) 39 | 40 | class TsensRead(TsensReadBase): 41 | __slots__ = () 42 | def __new__(cls, temp, sensor): 43 | temp = int(temp) 44 | 45 | return super(cls, TsensRead).__new__( 46 | cls, 47 | temp=temp, 48 | sensor=sensor, 49 | ) 50 | 51 | tsens_read_pattern = re.compile( 52 | r""" 53 | temp=(?P\d+)\s+ 54 | sensor=(?P.+) 55 | """, 56 | re.X|re.M 57 | ) 58 | 59 | @register_parser 60 | def tsens_read(payload): 61 | """Parser for `tsens_read` tracepoint""" 62 | try: 63 | match = re.match(tsens_read_pattern, payload) 64 | if match: 65 | match_group_dict = match.groupdict() 66 | return TsensRead(**match_group_dict) 67 | except Exception, e: 68 | raise ParserError(e.message) 69 | -------------------------------------------------------------------------------- /ftrace/parsers/tsens_threshold_clear.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'tsens_threshold_clear' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | 33 | TsensThresholdClearBase = namedtuple(TRACEPOINT, 34 | [ 35 | 'temp', 36 | 'sensor' 37 | ] 38 | ) 39 | 40 | class TsensThresholdClear(TsensThresholdClearBase): 41 | __slots__ = () 42 | def __new__(cls, temp, sensor): 43 | temp = int(temp) 44 | 45 | return super(cls, TsensThresholdClear).__new__( 46 | cls, 47 | temp=temp, 48 | sensor=sensor, 49 | ) 50 | 51 | tsens_threshold_clear_pattern = re.compile( 52 | r""" 53 | temp=(?P\d+)\s+ 54 | sensor=(?P.+) 55 | """, 56 | re.X|re.M 57 | ) 58 | 59 | @register_parser 60 | def tsens_threshold_clear(payload): 61 | """Parser for `tsens_threshold_clear` tracepoint""" 62 | try: 63 | match = re.match(tsens_threshold_clear_pattern, payload) 64 | if match: 65 | match_group_dict = match.groupdict() 66 | return TsensThresholdClear(**match_group_dict) 67 | except Exception, e: 68 | raise ParserError(e.message) 69 | -------------------------------------------------------------------------------- /ftrace/parsers/tsens_threshold_hit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'tsens_threshold_hit' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | 33 | TsensThresholdHitBase = namedtuple(TRACEPOINT, 34 | [ 35 | 'temp', 36 | 'sensor' 37 | ] 38 | ) 39 | 40 | class TsensThresholdHit(TsensThresholdHitBase): 41 | __slots__ = () 42 | def __new__(cls, temp, sensor): 43 | temp = int(temp) 44 | 45 | return super(cls, TsensThresholdHit).__new__( 46 | cls, 47 | temp=temp, 48 | sensor=sensor, 49 | ) 50 | 51 | tsens_threshold_hit_pattern = re.compile( 52 | r""" 53 | temp=(?P\d+)\s+ 54 | sensor=(?P.+) 55 | """, 56 | re.X|re.M 57 | ) 58 | 59 | @register_parser 60 | def tsens_threshold_hit(payload): 61 | """Parser for `tsens_threshold_hit` tracepoint""" 62 | try: 63 | match = re.match(tsens_threshold_hit_pattern, payload) 64 | if match: 65 | match_group_dict = match.groupdict() 66 | return TsensThresholdHit(**match_group_dict) 67 | except Exception, e: 68 | raise ParserError(e.message) 69 | -------------------------------------------------------------------------------- /ftrace/parsers/workqueue_activate_work.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'workqueue_activate_work' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | WorkqueueQueueActivateWorkBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'work_struct', 35 | ] 36 | ) 37 | 38 | class WorkqueueQueueActivateWork(WorkqueueQueueActivateWorkBase): 39 | __slots__ = () 40 | def __new__(cls, work_struct): 41 | 42 | return super(cls, WorkqueueQueueActivateWork).__new__( 43 | cls, 44 | work_struct=work_struct 45 | ) 46 | 47 | workqueue_activate_work_pattern = re.compile( 48 | r""" 49 | work struct (?P.+) 50 | """, 51 | re.X|re.M 52 | ) 53 | 54 | @register_parser 55 | def workqueue_activate_work(payload): 56 | """Parser for `workqueue_activate_work` tracepoint""" 57 | try: 58 | match = re.match(workqueue_activate_work_pattern, payload) 59 | if match: 60 | match_group_dict = match.groupdict() 61 | return WorkqueueQueueActivateWork(**match_group_dict) 62 | except Exception, e: 63 | raise ParserError(e.message) 64 | -------------------------------------------------------------------------------- /ftrace/parsers/workqueue_execute_end.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'workqueue_execute_end' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | WorkqueueQueueExecuteEndBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'work_struct', 35 | ] 36 | ) 37 | 38 | class WorkqueueQueueExecuteEnd(WorkqueueQueueExecuteEndBase): 39 | __slots__ = () 40 | def __new__(cls, work_struct): 41 | 42 | return super(cls, WorkqueueQueueExecuteEnd).__new__( 43 | cls, 44 | work_struct=work_struct 45 | ) 46 | 47 | workqueue_execute_end_pattern = re.compile( 48 | r""" 49 | work struct (?P.+) 50 | """, 51 | re.X|re.M 52 | ) 53 | 54 | @register_parser 55 | def workqueue_execute_end(payload): 56 | """Parser for `workqueue_execute_end` tracepoint""" 57 | try: 58 | match = re.match(workqueue_execute_end_pattern, payload) 59 | if match: 60 | match_group_dict = match.groupdict() 61 | return WorkqueueQueueExecuteEnd(**match_group_dict) 62 | except Exception, e: 63 | raise ParserError(e.message) 64 | -------------------------------------------------------------------------------- /ftrace/parsers/workqueue_execute_start.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'workqueue_execute_start' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | WorkqueueQueueExecuteStartBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'work_struct', 35 | 'function', 36 | ] 37 | ) 38 | 39 | class WorkqueueQueueExecuteStart(WorkqueueQueueExecuteStartBase): 40 | __slots__ = () 41 | def __new__(cls, work_struct, function): 42 | 43 | return super(cls, WorkqueueQueueExecuteStart).__new__( 44 | cls, 45 | work_struct=work_struct, 46 | function=function 47 | ) 48 | 49 | workqueue_execute_start_pattern = re.compile( 50 | r""" 51 | work struct (?P.+):\s+ 52 | function (?P.+) 53 | """, 54 | re.X|re.M 55 | ) 56 | 57 | @register_parser 58 | def workqueue_execute_start(payload): 59 | """Parser for `workqueue_execute_start` tracepoint""" 60 | try: 61 | match = re.match(workqueue_execute_start_pattern, payload) 62 | if match: 63 | match_group_dict = match.groupdict() 64 | return WorkqueueQueueExecuteStart(**match_group_dict) 65 | except Exception, e: 66 | raise ParserError(e.message) 67 | -------------------------------------------------------------------------------- /ftrace/parsers/workqueue_queue_work.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | import re 22 | from ftrace.common import ParserError 23 | from .register import register_parser 24 | from collections import namedtuple 25 | #from ftrace.third_party.cnamedtuple import namedtuple 26 | 27 | TRACEPOINT = 'workqueue_queue_work' 28 | 29 | 30 | __all__ = [TRACEPOINT] 31 | 32 | WorkqueueQueueWorkBase = namedtuple(TRACEPOINT, 33 | [ 34 | 'work_struct', 35 | 'function', 36 | 'workqueue', 37 | 'req_cpu', 38 | 'cpu', 39 | ] 40 | ) 41 | 42 | class WorkqueueQueueWork(WorkqueueQueueWorkBase): 43 | __slots__ = () 44 | def __new__(cls, work_struct, function, workqueue, req_cpu, cpu): 45 | req_cpu = int(req_cpu) 46 | cpu = int(cpu) 47 | 48 | return super(cls, WorkqueueQueueWork).__new__( 49 | cls, 50 | work_struct=work_struct, 51 | function=function, 52 | workqueue=workqueue, 53 | req_cpu=req_cpu, 54 | cpu=cpu 55 | ) 56 | 57 | workqueue_queue_work_pattern = re.compile( 58 | r""" 59 | work struct=(?P.+)\s+ 60 | function=(?P.+)\s+ 61 | workqueue=(?P.+)\s+ 62 | req_cpu=(?P\d+)\s+ 63 | cpu=(?P\d+) 64 | """, 65 | re.X|re.M 66 | ) 67 | 68 | @register_parser 69 | def workqueue_queue_work(payload): 70 | """Parser for `workqueue_queue_work` tracepoint""" 71 | try: 72 | match = re.match(workqueue_queue_work_pattern, payload) 73 | if match: 74 | match_group_dict = match.groupdict() 75 | return WorkqueueQueueWork(**match_group_dict) 76 | except Exception, e: 77 | raise ParserError(e.message) 78 | -------------------------------------------------------------------------------- /ftrace/third_party/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/corakwue/ftrace/d46139a562418146087f11f25528e0ab29c1c2c2/ftrace/third_party/__init__.py -------------------------------------------------------------------------------- /ftrace/third_party/cnamedtuple/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Joe Jevnik. 2 | All rights reserved. 3 | 4 | https://github.com/llllllllll/cnamedtuple -------------------------------------------------------------------------------- /ftrace/third_party/cnamedtuple/__init__.py: -------------------------------------------------------------------------------- 1 | from collections import OrderedDict 2 | 3 | from cnamedtuple._namedtuple import namedtuple, _register_asdict 4 | 5 | __all__ = [ 6 | 'namedtuple' 7 | ] 8 | 9 | __version__ = '0.1.5' 10 | 11 | # Register `OrderedDict` as the constructor to use when calling `_asdict`. 12 | # This step exists because there is currently work being done to move this into 13 | # Python 3.5, and this works to solve a circular dependency between 14 | # 'cnamedtuple/_namedtuple.c' ('Modules/_collectionsmodule.c' in cpyton) 15 | # and 'Lib/collections.py'. 16 | _register_asdict(OrderedDict) 17 | 18 | # Clean up the namespace for this module, the only public api should be 19 | # `namedtuple`. 20 | del _register_asdict 21 | del OrderedDict 22 | -------------------------------------------------------------------------------- /ftrace/third_party/enum/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Ethan Furman. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | Redistributions of source code must retain the above 9 | copyright notice, this list of conditions and the 10 | following disclaimer. 11 | 12 | Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials 15 | provided with the distribution. 16 | 17 | Neither the name Ethan Furman nor the names of any 18 | contributors may be used to endorse or promote products 19 | derived from this software without specific prior written 20 | permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 26 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /ftrace/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/corakwue/ftrace/d46139a562418146087f11f25528e0ab29c1c2c2/ftrace/utils/__init__.py -------------------------------------------------------------------------------- /ftrace/version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2015 Huawei Devices USA Inc. All rights reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | # Authors: 19 | # Chuk Orakwue 20 | 21 | 22 | BANNER = """ 23 | ftrace {version} 24 | Released under Apache V2 25 | """.strip() 26 | 27 | VERSION = (1, 0, 0, 'beta') 28 | 29 | 30 | def pretty_version(): 31 | return BANNER.format(version='.'.join(VERSION)) -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import warnings 4 | from itertools import chain 5 | 6 | try: 7 | from setuptools import setup 8 | except ImportError: 9 | from distutils.core import setup 10 | 11 | ftrace_dir = os.path.join(os.path.dirname(__file__), 'ftrace') 12 | 13 | # happends if falling back to distutils 14 | warnings.filterwarnings('ignore', "Unknown distribution option: 'install_requires'") 15 | warnings.filterwarnings('ignore', "Unknown distribution option: 'extras_require'") 16 | 17 | packages = [] 18 | data_files = {} 19 | source_dir = os.path.dirname(__file__) 20 | for root, dirs, files in os.walk(ftrace_dir): 21 | rel_dir = os.path.relpath(root, source_dir) 22 | data = [] 23 | if '__init__.py' in files: 24 | for f in files: 25 | if os.path.splitext(f)[1] not in ['.py', '.pyc', '.pyo']: 26 | data.append(f) 27 | package_name = rel_dir.replace(os.sep, '.') 28 | package_dir = root 29 | packages.append(package_name) 30 | data_files[package_name] = data 31 | else: 32 | # use previous package name 33 | filepaths = [os.path.join(root, f) for f in files] 34 | data_files[package_name].extend([os.path.relpath(f, package_dir) for f in filepaths]) 35 | 36 | CLASSIFIERS = [ 37 | 'Development Status :: 4 - Beta', 38 | 'Intended Audience :: Developers', 39 | 'License :: OSI Approved :: BSD License', 40 | 'Natural Language :: English', 41 | 'Operating System :: OS Independent', 42 | 'Programming Language :: Python', 43 | 'Topic :: Scientific/Engineering :: Mathematics', 44 | 'Topic :: Software Development :: Libraries :: Python Modules', 45 | 'Programming Language :: Python :: 2.7', 46 | 'Programming Language :: Python :: 3.3', 47 | 'Programming Language :: Python :: 3.4', 48 | ] 49 | 50 | KEYWORDS = 'linux ftrace parser library' 51 | 52 | setup( 53 | name='ftrace', 54 | version='1.0.0', 55 | description='Linux ftrace parser library.', 56 | author='Chuk Orakwue', 57 | author_email='chukwuchebem.orakwue@gmail.com', 58 | url='https://github.com/corakwue/ftrace/', 59 | download_url='https://github.com/corakwue/ftrace/', 60 | maintainer='Chuk Orakwue', 61 | maintainer_email='chukwuchebem.orakwue@gmail.com', 62 | packages=packages, 63 | platforms=['Platform Independent'], 64 | license='Apache v2', 65 | classifiers=CLASSIFIERS, 66 | keywords=KEYWORDS, 67 | install_requires=['logbook', 'pandas'], 68 | ) --------------------------------------------------------------------------------