Lines Matching +full:event +full:- +full:deep

2 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
14 # List of event tables generated from "/sys" directories.
16 # Map from an event name to an architecture standard
31 'event',
39 def removesuffix(s: str, suffix: str) -> str:
45 return s[0:-len(suffix)] if s.endswith(suffix) else s
48 def file_name_to_table_name(parents: Sequence[str], dirname: str) -> str:
54 return tblname.replace('-', '_')
56 def c_len(s: str) -> int:
68 utf = s.encode(encoding='utf-8',errors='strict')
72 return len(utf) - utf.count(b'\\') + utf.count(b'\\\\') - (utf.count(b'\\000') * 2)
77 Generating a large number of stand-alone C strings creates a large
84 strings are merged. If a longer string ends-with the same value as a
94 def add(self, s: str) -> None:
98 def compute(self) -> None:
104 sorted_reversed_strings = sorted([x[::-1] for x in self.strings])
120 folded_strings[s[::-1]] = sorted_reversed_strings[best_pos][::-1]
129 # being appended to - comments, etc. don't count. big_string is
154 self.offsets[s] = self.offsets[folded_s] + c_len(folded_s) - c_len(s)
159 """Representation of an event loaded from a json file dictionary."""
164 def llx(x: int) -> str:
168 def fixdesc(s: str) -> str:
176 def convert_aggr_mode(aggr_mode: str) -> Optional[str]:
186 def lookup_msr(num: str) -> Optional[str]:
187 """Converts the msr number, or first in a list to the appropriate event field."""
198 def real_event(name: str, event: str) -> Optional[str]:
199 """Convert well known event names to an event string otherwise use the event argument."""
201 'inst_retired.any': 'event=0xc0,period=2000003',
202 'inst_retired.any_p': 'event=0xc0,period=2000003',
203 'cpu_clk_unhalted.ref': 'event=0x0,umask=0x03,period=2000003',
204 'cpu_clk_unhalted.thread': 'event=0x3c,period=2000003',
205 'cpu_clk_unhalted.core': 'event=0x3c,period=2000003',
206 'cpu_clk_unhalted.thread_any': 'event=0x3c,any=1,period=2000003',
212 return event
214 def unit_to_pmu(unit: str) -> Optional[str]:
224 'iMPH-U': 'uncore_arb',
225 'CPU-M-CF': 'cpum_cf',
226 'CPU-M-SF': 'cpum_sf',
227 'PAI-CRYPTO' : 'pai_crypto',
275 if precise and self.desc and '(Precise Event)' not in self.desc:
277 'event)')
278 event = f'config={llx(configcode)}' if configcode is not None else f'event={llx(eventcode)}'
291 event += ',' + value + jd[key]
293 event += f',{filter}'
295 event += f',{msr}{msrval}'
305 event = _arch_std_events[arch_std.lower()].event
306 # Copy from the architecture standard event to self for undefined fields.
311 self.event = real_event(self.name, event)
313 def __repr__(self) -> str:
321 def build_c_string(self) -> str:
328 def to_c_string(self) -> str:
329 """Representation of the event as a C struct initializer."""
335 def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]:
343 for event in result:
344 event.topic = topic
347 def preprocess_arch_std_files(archpath: str) -> None:
352 for event in read_json_events(item.path, topic=''):
353 if event.name:
354 _arch_std_events[event.name.lower()] = event
357 def print_events_table_prefix(tblname: str) -> None:
366 def add_events_table_entries(item: os.DirEntry, topic: str) -> None:
374 def print_events_table_suffix() -> None:
377 def event_cmp_key(j: JsonEvent) -> Tuple[bool, str, str, str, str]:
378 def fix_none(s: Optional[str]) -> str:
391 for event in sorted(_pending_events, key=event_cmp_key):
392 _args.output_file.write(event.to_c_string())
398 def get_topic(topic: str) -> str:
401 return removesuffix(topic, '.json').replace('-', ' ')
403 def preprocess_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
408 # base dir or too deep
419 for event in read_json_events(item.path, topic):
420 _bcs.add(event.build_c_string())
422 def process_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
426 def is_leaf_dir(path: str) -> bool:
442 # base dir or too deep
455 def print_mapping_table(archs: Sequence[str]) -> None:
456 """Read the mapfile and generate the struct from cpuid string to event table."""
458 /* Struct used to make the PMU event table implementation opaque to callers. */
466 * cpuid field, which is an arch-specific identifier for the CPU.
467 * The identifier specified in tools/perf/pmu-events/arch/xxx/mapfile
524 def print_system_mapping_table() -> None:
554 \tpe->{attr} = (*p == '\\0' ? NULL : p);
556 if attr == _json_event_attributes[-1]:
565 for (size_t i = 0; i < table->length; i++) {
569 decompress(table->entries[i].offset, &pe);
592 if (!map->arch)
595 if (!strcmp_cpuid_str(map->cpuid, cpuid)) {
596 table = &map->table;
607 tables->arch;
609 if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid))
610 return &tables->table;
618 tables->arch;
620 int ret = pmu_events_table_for_each_event(&tables->table, fn, data);
631 tables->name;
633 if (!strcmp(tables->name, name))
634 return &tables->table;
642 tables->name;
644 int ret = pmu_events_table_for_each_event(&tables->table, fn, data);
654 def main() -> None:
657 def dir_path(path: str) -> str:
664 action: Callable[[Sequence[str], os.DirEntry], None]) -> None:
679 'output_file', type=argparse.FileType('w', encoding='utf-8'), nargs='?', default=sys.stdout)
683 #include "pmu-events/pmu-events.h"