Commit c9b121b7 authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim
Browse files

perf jevents: Add tool event json under a common architecture



Introduce the notion of a common architecture/model that can be used
to find event tables for common PMUs like the tool PMU. By having tool
events be json standard PMU attribute configuration, descriptions,
etc. can be used and these routines are already optimized for things
like binary searching.

Signed-off-by: default avatarIan Rogers <irogers@google.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20241002032016.333748-9-irogers@google.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 06905723
Loading
Loading
Loading
Loading
+74 −0
Original line number Diff line number Diff line
[
  {
    "Unit": "tool",
    "EventName": "duration_time",
    "BriefDescription": "Wall clock interval time in nanoseconds",
    "ConfigCode": "1"
  },
  {
    "Unit": "tool",
    "EventName": "user_time",
    "BriefDescription": "User (non-kernel) time in nanoseconds",
    "ConfigCode": "2"
  },
  {
    "Unit": "tool",
    "EventName": "system_time",
    "BriefDescription": "System/kernel time in nanoseconds",
    "ConfigCode": "3"
  },
  {
    "Unit": "tool",
    "EventName": "has_pmem",
    "BriefDescription": "1 if persistent memory installed otherwise 0",
    "ConfigCode": "4"
  },
  {
    "Unit": "tool",
    "EventName": "num_cores",
    "BriefDescription": "Number of cores. A core consists of 1 or more thread, with each thread being associated with a logical Linux CPU",
    "ConfigCode": "5"
  },
  {
    "Unit": "tool",
    "EventName": "num_cpus",
    "BriefDescription": "Number of logical Linux CPUs. There may be multiple such CPUs on a core",
    "ConfigCode": "6"
  },
  {
    "Unit": "tool",
    "EventName": "num_cpus_online",
    "BriefDescription": "Number of online logical Linux CPUs. There may be multiple such CPUs on a core",
    "ConfigCode": "7"
  },
  {
    "Unit": "tool",
    "EventName": "num_dies",
    "BriefDescription": "Number of dies. Each die has 1 or more cores",
    "ConfigCode": "8"
  },
  {
    "Unit": "tool",
    "EventName": "num_packages",
    "BriefDescription": "Number of packages. Each package has 1 or more die",
    "ConfigCode": "9"
  },
  {
    "Unit": "tool",
    "EventName": "slots",
    "BriefDescription": "Number of functional units that in parallel can execute parts of an instruction",
    "ConfigCode": "10"
  },
  {
    "Unit": "tool",
    "EventName": "smt_on",
    "BriefDescription": "1 if simultaneous multithreading (aka hyperthreading) is enable otherwise 0",
    "ConfigCode": "11"
  },
  {
    "Unit": "tool",
    "EventName": "system_tsc_freq",
    "BriefDescription": "The amount a Time Stamp Counter (TSC) increases per second",
    "ConfigCode": "12"
  }
]
+127 −81

File changed.

Preview size limit exceeded, changes collapsed.

+14 −2
Original line number Diff line number Diff line
@@ -292,6 +292,7 @@ class JsonEvent:
          'cpu_atom': 'cpu_atom',
          'ali_drw': 'ali_drw',
          'arm_cmn': 'arm_cmn',
          'tool': 'tool',
      }
      return table[unit] if unit in table else f'uncore_{unit.lower()}'

@@ -721,6 +722,17 @@ const struct pmu_events_map pmu_events_map[] = {
\t\t.num_pmus = ARRAY_SIZE(pmu_metrics__test_soc_cpu),
\t}
},
""")
    elif arch == 'common':
      _args.output_file.write("""{
\t.arch = "common",
\t.cpuid = "common",
\t.event_table = {
\t\t.pmus = pmu_events__common,
\t\t.num_pmus = ARRAY_SIZE(pmu_events__common),
\t},
\t.metric_table = {},
},
""")
    else:
      with open(f'{_args.starting_dir}/{arch}/mapfile.csv') as csvfile:
@@ -1241,7 +1253,7 @@ def main() -> None:
        if len(parents) == _args.model.split(',')[0].count('/'):
          # We're testing the correct directory.
          item_path = '/'.join(parents) + ('/' if len(parents) > 0 else '') + item.name
          if 'test' not in item_path and item_path not in _args.model.split(','):
          if 'test' not in item_path and 'common' not in item_path and item_path not in _args.model.split(','):
            continue
      action(parents, item)
      if item.is_dir():
@@ -1289,7 +1301,7 @@ struct pmu_table_entry {
  for item in os.scandir(_args.starting_dir):
    if not item.is_dir():
      continue
    if item.name == _args.arch or _args.arch == 'all' or item.name == 'test':
    if item.name == _args.arch or _args.arch == 'all' or item.name == 'test' or item.name == 'common':
      archs.append(item.name)

  if len(archs) < 2 and _args.arch != 'none':