Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf jevents: Validate that all names given an Event

Validate they exist in a JSON file from one directory found from one
directory above the model's JSON directory.

This avoids broken fallback encodings being created.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Benjamin Gray <bgray@linux.ibm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Edward Baker <edward.baker@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xu Yang <xu.yang_2@nxp.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
e205952d 82e53e7a

+36
+36
tools/perf/pmu-events/metric.py
··· 11 11 all_pmus = set() 12 12 all_events = set() 13 13 experimental_events = set() 14 + all_events_all_models = set() 14 15 15 16 def LoadEvents(directory: str) -> None: 16 17 """Populate a global set of all known events for the purpose of validating Event names""" 17 18 global all_pmus 18 19 global all_events 19 20 global experimental_events 21 + global all_events_all_models 20 22 all_events = { 21 23 "context\\-switches", 22 24 "cpu\\-cycles", ··· 44 42 # The generated directory may be the same as the input, which 45 43 # causes partial json files. Ignore errors. 46 44 pass 45 + all_events_all_models = all_events.copy() 46 + for root, dirs, files in os.walk(directory + ".."): 47 + for filename in files: 48 + if filename.endswith(".json"): 49 + try: 50 + for x in json.load(open(f"{root}/{filename}")): 51 + if "EventName" in x: 52 + all_events_all_models.add(x["EventName"]) 53 + elif "ArchStdEvent" in x: 54 + all_events_all_models.add(x["ArchStdEvent"]) 55 + except json.decoder.JSONDecodeError: 56 + # The generated directory may be the same as the input, which 57 + # causes partial json files. Ignore errors. 58 + pass 47 59 48 60 49 61 def CheckPmu(name: str) -> bool: ··· 79 63 return True 80 64 81 65 return name in all_events 66 + 67 + def CheckEveryEvent(*names: str) -> None: 68 + """Check all the events exist in at least one json file""" 69 + global all_events_all_models 70 + if len(all_events_all_models) == 0: 71 + assert len(names) == 1, f"Cannot determine valid events in {names}" 72 + # No events loaded so assume any event is good. 73 + return 74 + 75 + for name in names: 76 + # Remove trailing modifier. 77 + if ':' in name: 78 + name = name[:name.find(':')] 79 + elif '/' in name: 80 + name = name[:name.find('/')] 81 + if any([name.startswith(x) for x in ['amd', 'arm', 'cpu', 'msr', 'power']]): 82 + continue 83 + if name not in all_events_all_models: 84 + raise Exception(f"Is {name} a named json event?") 82 85 83 86 84 87 def IsExperimentalEvent(name: str) -> bool: ··· 438 403 439 404 def __init__(self, *args: str): 440 405 error = "" 406 + CheckEveryEvent(*args) 441 407 for name in args: 442 408 if CheckEvent(name): 443 409 self.name = _FixEscapes(name)