From 264e472e17ca06490a8dc78595d6ebec766e1e14 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 3 Jan 2024 17:53:53 -0800 Subject: [PATCH 1/5] Add missing arch fixups for alderlake and rocketlake Add an assertion that the PMU prefix isn't used with what appear to be uncore events. --- scripts/create_perf_json.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/create_perf_json.py b/scripts/create_perf_json.py index 38aa139b..527799c1 100644 --- a/scripts/create_perf_json.py +++ b/scripts/create_perf_json.py @@ -945,7 +945,9 @@ def fixup(form: str) -> str: ('UNC_C_CLOCKTICKS:one_unit', 'cbox_0@event\=0x0@'), ] arch_fixups = { - 'ADL': td_event_fixups, + 'ADL': td_event_fixups + [ + ('UNC_ARB_DAT_OCCUPANCY.RD:c1', 'UNC_ARB_DAT_OCCUPANCY.RD@cmask\=1@'), + ], 'BDW-DE': hsx_uncore_fixups, 'BDX': hsx_uncore_fixups, 'CLX': [ @@ -979,7 +981,9 @@ def fixup(form: str) -> str: 'UNC_C_TOR_OCCUPANCY.MISS_OPCODE@filter_opc\=0x182\,thresh\=1@'), ('UNC_C_CLOCKTICKS:one_unit', 'cbox_0@event\=0x0@'), ], - 'RKL': td_event_fixups, + 'RKL': td_event_fixups + [ + ('UNC_ARB_DAT_OCCUPANCY.RD:c1', 'UNC_ARB_DAT_OCCUPANCY.RD@cmask\=1@'), + ], 'SKL': [ ('UNC_ARB_TRK_OCCUPANCY.DATA_READ:c1', 'UNC_ARB_TRK_OCCUPANCY.DATA_READ@cmask\=1@'), @@ -1192,6 +1196,7 @@ def save_form(name, group, form, desc, locate, scale_unit, threshold, assert v in events or v.upper() in events or v in infoname or v in aux, \ f'Expected {v} to be an event in "{name}": "{form}" on {self.shortname}' + assert f'{pmu_prefix}@UNC' not in form, form if group: group = ';'.join(sorted(set(group.split(';')))) # Check for duplicate metrics. Note, done after From d3bb189445f0252174d0a1177eb02d7f231166a9 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 3 Jan 2024 18:01:16 -0800 Subject: [PATCH 2/5] Fix UNCORE_FREQ for alderlake The Unit needs to be set on UNCORE_FREQ otherwise the perf tool won't know which metric is being referred to. Set the Unit by using save_form (that also validates the metric) rather than manually appending to the metric list. --- scripts/create_perf_json.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/create_perf_json.py b/scripts/create_perf_json.py index 527799c1..496738cc 100644 --- a/scripts/create_perf_json.py +++ b/scripts/create_perf_json.py @@ -1189,7 +1189,8 @@ def save_form(name, group, form, desc, locate, scale_unit, threshold, 'imc_0', 'uncore_cha_0', 'cbox_0', 'arb', 'cbox', 'num_packages', 'num_cores', 'SYSTEM_TSC_FREQ', 'filter_tid', 'TSC', 'cha', 'config1', - 'source_count', 'slots', 'thresh', 'has_pmem']: + 'source_count', 'slots', 'thresh', 'has_pmem', + 'num_dies']: continue if v.startswith('tma_') or v.startswith('topdown\\-'): continue @@ -1460,12 +1461,8 @@ def append_to_desc(s: str): form = resolve_all(form, expand_metrics=False) if form: formula = metric.ParsePerfJson(form) - jo.append({ - 'MetricName': 'UNCORE_FREQ', - 'MetricExpr': formula.ToPerfJson(), - 'BriefDescription': 'Uncore frequency per die [GHZ]', - 'MetricGroup': 'SoC' - }) + save_form('UNCORE_FREQ', 'SoC', formula.ToPerfJson(), + 'Uncore frequency per die [GHZ]', None, None, None, []) if 'extra metrics' in self.files: with open(self.files['extra metrics'], 'r') as extra_json: From 83e291f476583558efd8b2ddac3361ef660244a2 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 3 Jan 2024 14:15:43 -0800 Subject: [PATCH 3/5] Workaround "Metric Group" column issue Metric groups in the "Metric Group" column are semicolon separated, however, a broken cell may contain a value like "CacheHits;" where the split will say there is an empty string after the semicolon. Skip such empty strings if they occur. --- scripts/create_perf_json.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/create_perf_json.py b/scripts/create_perf_json.py index 496738cc..c60e607c 100644 --- a/scripts/create_perf_json.py +++ b/scripts/create_perf_json.py @@ -842,6 +842,8 @@ def is_topdown_row(key: str) -> bool: csv_groups = metric_group(metric_name) if csv_groups: for group in csv_groups.split(';'): + if not group: + continue mgroups.append(group) if group not in self.metricgroups: self.metricgroups[group] = 'Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet' @@ -877,6 +879,8 @@ def is_topdown_row(key: str) -> bool: csv_groups = metric_group(metric_name) if csv_groups: for group in csv_groups.split(';'): + if not group: + continue mgroups.append(group) if group not in self.metricgroups: self.metricgroups[group] = 'Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet' From a5107718edbf2f2e8f78c3a0b5db862bffa74ccb Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Wed, 3 Jan 2024 14:10:39 -0800 Subject: [PATCH 4/5] Support :u1 event umask suffixes in metrics Most umask suffixes are given with :u0x but :u1 may be used. Support this non hex version by expanding the number match/replace. --- scripts/create_perf_json.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/create_perf_json.py b/scripts/create_perf_json.py index c60e607c..67e6c6d8 100644 --- a/scripts/create_perf_json.py +++ b/scripts/create_perf_json.py @@ -1060,8 +1060,8 @@ def fixup(form: str) -> str: rf'{pmu_prefix}@\1\\,inv@'), ('(' + event_pattern + rf'):c(\d+)', rf'{pmu_prefix}@\1\\,cmask\\=\2@'), - ('(' + event_pattern + rf'):u0x([a-fA-F0-9]+)', - rf'{pmu_prefix}@\1\\,umask\\=0x\2@'), + ('(' + event_pattern + rf'):u((0x[a-fA-F0-9]+|\d+))', + rf'{pmu_prefix}@\1\\,umask\\=\2@'), ('(' + event_pattern + rf'):e1', rf'{pmu_prefix}@\1\\,edge@'), ]: From e1507544020762881edacf3aa52c43d596868539 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Tue, 5 Sep 2023 21:06:15 -0700 Subject: [PATCH 5/5] Add support for Num_CPUs aux value Num_CPUs is special in that the # prefix is missing. It maps to the perf num_cpus_online literal. --- scripts/create_perf_json.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/create_perf_json.py b/scripts/create_perf_json.py index 67e6c6d8..e8f2231a 100644 --- a/scripts/create_perf_json.py +++ b/scripts/create_perf_json.py @@ -908,7 +908,7 @@ def is_topdown_row(key: str) -> bool: form = find_form() if form and form != '#NA': aux_name = field('Level1') - assert aux_name.startswith('#') + assert aux_name.startswith('#') or aux_name == 'Num_CPUs' aux[aux_name] = form _verboseprint3(f'Adding aux {aux_name}: {form}') @@ -1103,8 +1103,11 @@ def bracket(expr): return expr def resolve_aux(v: str) -> str: - if any(v == i for i in ['#core_wide', '#Model', '#SMT_on', '#num_dies','#has_pmem']): + if any(v == i for i in ['#core_wide', '#Model', '#SMT_on', '#num_dies', + '#has_pmem', '#num_cpus_online']): return v + if v == 'Num_CPUs': + return '#num_cpus_online' if v == '#PMM_App_Direct': return '#has_pmem > 0' if v == '#DurationTimeInSeconds': @@ -1150,7 +1153,7 @@ def resolve(v: str) -> str: return expand_hhq(v[3:]) if v.startswith('##'): return expand_hh(v[2:]) - if v.startswith('#'): + if v.startswith('#') or v == 'Num_CPUs': return resolve_aux(v) return resolve_info(v) @@ -1194,7 +1197,7 @@ def save_form(name, group, form, desc, locate, scale_unit, threshold, 'num_packages', 'num_cores', 'SYSTEM_TSC_FREQ', 'filter_tid', 'TSC', 'cha', 'config1', 'source_count', 'slots', 'thresh', 'has_pmem', - 'num_dies']: + 'num_dies', 'num_cpus_online']: continue if v.startswith('tma_') or v.startswith('topdown\\-'): continue