• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2024 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""
15Contains tables related to perf data ingestion.
16"""
17
18from python.generators.trace_processor_table.public import Column as C
19from python.generators.trace_processor_table.public import ColumnDoc
20from python.generators.trace_processor_table.public import ColumnFlag
21from python.generators.trace_processor_table.public import CppInt64
22from python.generators.trace_processor_table.public import CppOptional
23from python.generators.trace_processor_table.public import CppString
24from python.generators.trace_processor_table.public import CppTableId
25from python.generators.trace_processor_table.public import CppUint32
26from python.generators.trace_processor_table.public import Table
27from python.generators.trace_processor_table.public import TableDoc
28from .profiler_tables import STACK_PROFILE_FRAME_TABLE
29from .profiler_tables import STACK_PROFILE_MAPPING_TABLE
30from .metadata_tables import THREAD_TABLE
31from .etm_tables import FILE_TABLE
32
33SPE_RECORD_TABLE = Table(
34    python_module=__file__,
35    class_name='SpeRecordTable',
36    sql_name='__intrinsic_spe_record',
37    columns=[
38        C('ts', CppInt64(), ColumnFlag.SORTED),
39        C('utid', CppOptional(CppTableId(THREAD_TABLE))),
40        C('exception_level', CppString()),
41        C('instruction_frame_id',
42          CppOptional(CppTableId(STACK_PROFILE_FRAME_TABLE))),
43        C('operation', CppString()),
44        C('data_virtual_address', CppInt64()),
45        C('data_physical_address', CppInt64()),
46        C('total_latency', CppUint32()),
47        C('issue_latency', CppUint32()),
48        C('translation_latency', CppUint32()),
49        C('events_bitmask', CppInt64()),
50        C('data_source', CppString()),
51    ],
52    tabledoc=TableDoc(
53        doc='''
54          This table has a row for each sampled operation in an ARM Statistical
55          Profiling Extension trace.
56        ''',
57        group='Perf',
58        columns={
59            'ts':
60                'Time the operation was sampled',
61            'utid':
62                'EXecuting thread',
63            'exception_level':
64                'Exception level the operation executed in',
65            'instruction_frame_id':
66                ColumnDoc(
67                    'Instruction virtual address',
68                    joinable='stack_profile_frame.id'),
69            'operation':
70                'Operation executed',
71            'data_virtual_address':
72                'Virtual address of accesses data (if any)',
73            'data_physical_address':
74                '''
75                  Physical address of accesses data (if any)
76                ''',
77            'total_latency':
78                '''
79                  Cycle count from the operation being dispatched for issue to
80                  the operation being complete.
81                ''',
82            'issue_latency':
83                '''
84                  Cycle count from the operation being dispatched for issue to
85                  the operation being issued for execution.
86                ''',
87            'translation_latency':
88                '''
89                  Cycle count from a virtual address being passed to the MMU for
90                  translation to the result of the translation being available.
91                ''',
92            'events_bitmask':
93                'Events generated by the operation',
94            'data_source':
95                '''
96                  Where the data returned for a load operation was sourced
97                ''',
98        },
99    ),
100)
101
102MMAP_RECORD = Table(
103    python_module=__file__,
104    class_name='MmapRecordTable',
105    sql_name='__intrinsic_mmap_record',
106    columns=[
107        C('ts', CppInt64()),
108        C('upid', CppOptional(CppUint32())),
109        C('mapping_id', CppTableId(STACK_PROFILE_MAPPING_TABLE)),
110        C('file_id', CppOptional(CppTableId(FILE_TABLE))),
111    ],
112    tabledoc=TableDoc(
113        doc='''
114          This table has a row for each mmap or mmap2 record in a perf trace.
115          It allows us to determine when mappings are created, what process
116          created them and what is the actual data contained in the mapping.
117        ''',
118        group='Perf',
119        columns={
120            'ts':
121                'Time the mapping was created.',
122            'upid':
123                'Process that created the mapping',
124            'mapping_id':
125                ColumnDoc('Mapping', joinable='stack_profile_mapping.id'),
126            'file_id':
127                ColumnDoc(
128                    'References a file that backs the contents of this mapping',
129                    joinable='__intrinsic_file.id'),
130        },
131    ))
132
133ALL_TABLES = [
134    SPE_RECORD_TABLE,
135    MMAP_RECORD,
136]
137