Lines Matching +full:jd +full:- +full:invert
2 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
63 def removesuffix(s: str, suffix: str) -> str:
69 return s[0:-len(suffix)] if s.endswith(suffix) else s
73 dirname: str) -> str:
79 return tblname.replace('-', '_')
82 def c_len(s: str) -> int:
94 utf = s.encode(encoding='utf-8',errors='strict')
98 return len(utf) - utf.count(b'\\') + utf.count(b'\\\\') - (utf.count(b'\\000') * 2)
103 Generating a large number of stand-alone C strings creates a large
110 strings are merged. If a longer string ends-with the same value as a
126 def add(self, s: str, metric: bool) -> None:
135 def compute(self) -> None:
141 sorted_reversed_strings = sorted([x[::-1] for x in self.strings])
157 folded_strings[s[::-1]] = sorted_reversed_strings[best_pos][::-1]
166 # being appended to - comments, etc. don't count. big_string is
174 def string_cmp_key(s: str) -> Tuple[bool, int, str]:
194 self.offsets[s] = self.offsets[folded_s] + c_len(folded_s) - c_len(s)
201 def __init__(self, jd: dict):
204 def llx(x: int) -> str:
208 def fixdesc(s: str) -> str:
216 def convert_aggr_mode(aggr_mode: str) -> Optional[str]:
226 def convert_metric_constraint(metric_constraint: str) -> Optional[str]:
238 def lookup_msr(num: str) -> Optional[str]:
250 def real_event(name: str, event: str) -> Optional[str]:
266 def unit_to_pmu(unit: str) -> Optional[str]:
276 'iMPH-U': 'uncore_arb',
277 'CPU-M-CF': 'cpum_cf',
278 'CPU-M-SF': 'cpum_sf',
279 'PAI-CRYPTO' : 'pai_crypto',
280 'PAI-EXT' : 'pai_ext',
298 def is_zero(val: str) -> bool:
307 def canonicalize_value(val: str) -> str:
316 if 'EventCode' in jd:
317 eventcode = int(jd['EventCode'].split(',', 1)[0], 0)
318 if 'ExtSel' in jd:
319 eventcode |= int(jd['ExtSel']) << 8
320 configcode = int(jd['ConfigCode'], 0) if 'ConfigCode' in jd else None
321 eventidcode = int(jd['EventidCode'], 0) if 'EventidCode' in jd else None
322 self.name = jd['EventName'].lower() if 'EventName' in jd else None
324 self.compat = jd.get('Compat')
325 self.desc = fixdesc(jd.get('BriefDescription'))
326 self.long_desc = fixdesc(jd.get('PublicDescription'))
327 precise = jd.get('PEBS')
328 msr = lookup_msr(jd.get('MSRIndex'))
329 msrval = jd.get('MSRValue')
331 if 'Data_LA' in jd:
333 if 'Errata' in jd:
335 if 'Errata' in jd:
336 extra_desc += ' Spec update: ' + jd['Errata']
337 self.pmu = unit_to_pmu(jd.get('Unit'))
338 filter = jd.get('Filter')
339 self.unit = jd.get('ScaleUnit')
340 self.perpkg = jd.get('PerPkg')
341 self.aggr_mode = convert_aggr_mode(jd.get('AggregationMode'))
342 self.deprecated = jd.get('Deprecated')
343 self.metric_name = jd.get('MetricName')
344 self.metric_group = jd.get('MetricGroup')
345 self.metricgroup_no_group = jd.get('MetricgroupNoGroup')
346 self.default_metricgroup_name = jd.get('DefaultMetricgroupName')
347 self.event_grouping = convert_metric_constraint(jd.get('MetricConstraint'))
349 if 'MetricExpr' in jd:
350 self.metric_expr = metric.ParsePerfJson(jd['MetricExpr']).Simplify()
353 self.metric_threshold = jd.get('MetricThreshold')
355 arch_std = jd.get('ArchStdEvent')
372 ('Invert', 'inv='),
383 if key in jd and not is_zero(jd[key]):
384 event += f',{value}{canonicalize_value(jd[key])}'
405 def __repr__(self) -> str:
413 def build_c_string(self, metric: bool) -> str:
429 def to_c_string(self, metric: bool) -> str:
437 def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]:
447 if event.metric_name and '-' not in event.metric_name:
459 def preprocess_arch_std_files(archpath: str) -> None:
471 def add_events_table_entries(item: os.DirEntry, topic: str) -> None:
480 def print_pending_events() -> None:
483 def event_cmp_key(j: JsonEvent) -> Tuple[str, str, bool, str, str]:
484 def fix_none(s: Optional[str]) -> str:
540 def print_pending_metrics() -> None:
543 def metric_cmp_key(j: JsonEvent) -> Tuple[bool, str, str]:
544 def fix_none(s: Optional[str]) -> str:
595 def get_topic(topic: str) -> str:
598 return removesuffix(topic, '.json').replace('-', ' ')
600 def preprocess_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
636 def process_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
638 def is_leaf_dir_ignoring_sys(path: str) -> bool:
674 def print_mapping_table(archs: Sequence[str]) -> None:
691 * cpuid field, which is an arch-specific identifier for the CPU.
692 * The identifier specified in tools/perf/pmu-events/arch/xxx/mapfile
772 def print_system_mapping_table() -> None:
824 _args.output_file.write(f'\n\tpe->{attr} = ')
826 _args.output_file.write("*p - '0';\n")
829 if attr == _json_event_attributes[-1]:
842 _args.output_file.write(f'\n\tpm->{attr} = ')
844 _args.output_file.write("*p - '0';\n")
847 if attr == _json_metric_attributes[-1]:
862 .pmu = &big_c_string[pmu->pmu_name.offset],
865 for (uint32_t i = 0; i < pmu->num_entries; i++) {
866 decompress_event(pmu->entries[i].offset, &pe);
883 .pmu = &big_c_string[pmu->pmu_name.offset],
885 int low = 0, high = pmu->num_entries - 1;
890 decompress_event(pmu->entries[mid].offset, &pe);
900 high = mid - 1;
910 high = mid - 1;
924 for (size_t i = 0; i < table->num_pmus; i++) {
925 const struct pmu_table_entry *table_pmu = &table->pmus[i];
926 const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
945 for (size_t i = 0; i < table->num_pmus; i++) {
946 const struct pmu_table_entry *table_pmu = &table->pmus[i];
947 const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
965 for (size_t i = 0; i < table->num_pmus; i++) {
966 const struct pmu_table_entry *table_pmu = &table->pmus[i];
967 const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
970 count += table_pmu->num_entries;
982 .pmu = &big_c_string[pmu->pmu_name.offset],
985 for (uint32_t i = 0; i < pmu->num_entries; i++) {
986 decompress_metric(pmu->entries[i].offset, &pm);
1000 for (size_t i = 0; i < table->num_pmus; i++) {
1001 int ret = pmu_metrics_table__for_each_metric_pmu(table, &table->pmus[i],
1045 if (!map->arch) {
1050 if (!strcmp_cpuid_str(map->cpuid, cpuid))
1073 return &map->event_table;
1075 for (size_t i = 0; i < map->event_table.num_pmus; i++) {
1076 const struct pmu_table_entry *table_pmu = &map->event_table.pmus[i];
1077 const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
1080 return &map->event_table;
1093 return &map->metric_table;
1095 for (size_t i = 0; i < map->metric_table.num_pmus; i++) {
1096 const struct pmu_table_entry *table_pmu = &map->metric_table.pmus[i];
1097 const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
1100 return &map->metric_table;
1108 tables->arch;
1110 if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid))
1111 return &tables->event_table;
1119 tables->arch;
1121 if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid))
1122 return &tables->metric_table;
1130 tables->arch;
1132 int ret = pmu_events_table__for_each_event(&tables->event_table,
1144 tables->arch;
1146 int ret = pmu_metrics_table__for_each_metric(&tables->metric_table, fn, data);
1157 tables->name;
1159 if (!strcmp(tables->name, name))
1160 return &tables->event_table;
1168 tables->name;
1170 int ret = pmu_events_table__for_each_event(&tables->event_table,
1182 tables->name;
1184 int ret = pmu_metrics_table__for_each_metric(&tables->metric_table, fn, data);
1193 def print_metricgroups() -> None:
1207 int low = 0, high = (int)ARRAY_SIZE(metricgroups) - 1;
1219 high = mid - 1;
1226 def main() -> None:
1229 def dir_path(path: str) -> str:
1236 action: Callable[[Sequence[str], os.DirEntry], None]) -> None:
1255 such as "arm/cortex-a34".''',
1263 'output_file', type=argparse.FileType('w', encoding='utf-8'), nargs='?', default=sys.stdout)
1267 /* SPDX-License-Identifier: GPL-2.0 */
1271 #include <pmu-events/pmu-events.h>