• Home
  • Raw
  • Download

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',
296 if 'EventCode' in jd:
297 eventcode = int(jd['EventCode'].split(',', 1)[0], 0)
298 if 'ExtSel' in jd:
299 eventcode |= int(jd['ExtSel']) << 8
300 configcode = int(jd['ConfigCode'], 0) if 'ConfigCode' in jd else None
301 self.name = jd['EventName'].lower() if 'EventName' in jd else None
303 self.compat = jd.get('Compat')
304 self.desc = fixdesc(jd.get('BriefDescription'))
305 self.long_desc = fixdesc(jd.get('PublicDescription'))
306 precise = jd.get('PEBS')
307 msr = lookup_msr(jd.get('MSRIndex'))
308 msrval = jd.get('MSRValue')
310 if 'Data_LA' in jd:
312 if 'Errata' in jd:
314 if 'Errata' in jd:
315 extra_desc += ' Spec update: ' + jd['Errata']
316 self.pmu = unit_to_pmu(jd.get('Unit'))
317 filter = jd.get('Filter')
318 self.unit = jd.get('ScaleUnit')
319 self.perpkg = jd.get('PerPkg')
320 self.aggr_mode = convert_aggr_mode(jd.get('AggregationMode'))
321 self.deprecated = jd.get('Deprecated')
322 self.metric_name = jd.get('MetricName')
323 self.metric_group = jd.get('MetricGroup')
324 self.metricgroup_no_group = jd.get('MetricgroupNoGroup')
325 self.default_metricgroup_name = jd.get('DefaultMetricgroupName')
326 self.event_grouping = convert_metric_constraint(jd.get('MetricConstraint'))
328 if 'MetricExpr' in jd:
329 self.metric_expr = metric.ParsePerfJson(jd['MetricExpr']).Simplify()
332 self.metric_threshold = jd.get('MetricThreshold')
334 arch_std = jd.get('ArchStdEvent')
345 ('Invert', 'inv='),
350 if key in jd and jd[key] != '0':
351 event += ',' + value + jd[key]
372 def __repr__(self) -> str:
380 def build_c_string(self, metric: bool) -> str:
396 def to_c_string(self, metric: bool) -> str:
404 def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]:
414 if event.metric_name and '-' not in event.metric_name:
426 def preprocess_arch_std_files(archpath: str) -> None:
438 def add_events_table_entries(item: os.DirEntry, topic: str) -> None:
447 def print_pending_events() -> None:
450 def event_cmp_key(j: JsonEvent) -> Tuple[str, str, bool, str, str]:
451 def fix_none(s: Optional[str]) -> str:
503 def print_pending_metrics() -> None:
506 def metric_cmp_key(j: JsonEvent) -> Tuple[bool, str, str]:
507 def fix_none(s: Optional[str]) -> str:
558 def get_topic(topic: str) -> str:
561 return removesuffix(topic, '.json').replace('-', ' ')
563 def preprocess_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
599 def process_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
601 def is_leaf_dir(path: str) -> bool:
634 def print_mapping_table(archs: Sequence[str]) -> None:
651 * cpuid field, which is an arch-specific identifier for the CPU.
652 * The identifier specified in tools/perf/pmu-events/arch/xxx/mapfile
732 def print_system_mapping_table() -> None:
784 _args.output_file.write(f'\n\tpe->{attr} = ')
786 _args.output_file.write("*p - '0';\n")
789 if attr == _json_event_attributes[-1]:
802 _args.output_file.write(f'\n\tpm->{attr} = ')
804 _args.output_file.write("*p - '0';\n")
807 if attr == _json_metric_attributes[-1]:
822 .pmu = &big_c_string[pmu->pmu_name.offset],
825 for (uint32_t i = 0; i < pmu->num_entries; i++) {
826 decompress_event(pmu->entries[i].offset, &pe);
843 .pmu = &big_c_string[pmu->pmu_name.offset],
845 int low = 0, high = pmu->num_entries - 1;
850 decompress_event(pmu->entries[mid].offset, &pe);
860 high = mid - 1;
870 high = mid - 1;
876 return -1000;
884 for (size_t i = 0; i < table->num_pmus; i++) {
885 const struct pmu_table_entry *table_pmu = &table->pmus[i];
886 const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
905 for (size_t i = 0; i < table->num_pmus; i++) {
906 const struct pmu_table_entry *table_pmu = &table->pmus[i];
907 const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
914 if (ret != -1000)
917 return -1000;
925 for (size_t i = 0; i < table->num_pmus; i++) {
926 const struct pmu_table_entry *table_pmu = &table->pmus[i];
927 const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
930 count += table_pmu->num_entries;
942 .pmu = &big_c_string[pmu->pmu_name.offset],
945 for (uint32_t i = 0; i < pmu->num_entries; i++) {
946 decompress_metric(pmu->entries[i].offset, &pm);
960 for (size_t i = 0; i < table->num_pmus; i++) {
961 int ret = pmu_metrics_table__for_each_metric_pmu(table, &table->pmus[i],
985 if (!map->arch)
988 if (!strcmp_cpuid_str(map->cpuid, cpuid)) {
989 table = &map->event_table;
997 for (i = 0; i < table->num_pmus; i++) {
998 const struct pmu_table_entry *table_pmu = &table->pmus[i];
999 const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
1022 if (!map->arch)
1025 if (!strcmp_cpuid_str(map->cpuid, cpuid)) {
1026 table = &map->metric_table;
1037 tables->arch;
1039 if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid))
1040 return &tables->event_table;
1048 tables->arch;
1050 if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpuid))
1051 return &tables->metric_table;
1059 tables->arch;
1061 int ret = pmu_events_table__for_each_event(&tables->event_table,
1073 tables->arch;
1075 int ret = pmu_metrics_table__for_each_metric(&tables->metric_table, fn, data);
1086 tables->name;
1088 if (!strcmp(tables->name, name))
1089 return &tables->event_table;
1097 tables->name;
1099 int ret = pmu_events_table__for_each_event(&tables->event_table,
1111 tables->name;
1113 int ret = pmu_metrics_table__for_each_metric(&tables->metric_table, fn, data);
1122 def print_metricgroups() -> None:
1136 int low = 0, high = (int)ARRAY_SIZE(metricgroups) - 1;
1148 high = mid - 1;
1155 def main() -> None:
1158 def dir_path(path: str) -> str:
1165 action: Callable[[Sequence[str], os.DirEntry], None]) -> None:
1184 such as "arm/cortex-a34".''',
1192 'output_file', type=argparse.FileType('w', encoding='utf-8'), nargs='?', default=sys.stdout)
1196 #include <pmu-events/pmu-events.h>