mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 23:54:04 +08:00
perf jevents: Rewrite metrics in the same file with each other
Rewrite metrics within the same file in terms of each other. For example, on Power8 other_stall_cpi is rewritten from: "PM_CMPLU_STALL / PM_RUN_INST_CMPL - PM_CMPLU_STALL_BRU_CRU / PM_RUN_INST_CMPL - PM_CMPLU_STALL_FXU / PM_RUN_INST_CMPL - PM_CMPLU_STALL_VSU / PM_RUN_INST_CMPL - PM_CMPLU_STALL_LSU / PM_RUN_INST_CMPL - PM_CMPLU_STALL_NTCG_FLUSH / PM_RUN_INST_CMPL - PM_CMPLU_STALL_NO_NTF / PM_RUN_INST_CMPL" to: "stall_cpi - bru_cru_stall_cpi - fxu_stall_cpi - vsu_stall_cpi - lsu_stall_cpi - ntcg_flush_cpi - no_ntf_stall_cpi" Which more closely matches the definition on Power9. To avoid recomputation decorate the function with a cache. Reviewed-by: Kajol Jain <kjain@linux.ibm.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Caleb Biggers <caleb.biggers@intel.com> Cc: Florian Fischer <florian.fischer@muhq.space> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Kang Minchul <tegongkang@gmail.com> Cc: Kim Phillips <kim.phillips@amd.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Perry Taylor <perry.taylor@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Rob Herring <robh@kernel.org> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Stephane Eranian <eranian@google.com> Cc: Will Deacon <will@kernel.org> Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20230126233645.200509-4-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
2efbb73d46
commit
df5499ddb8
@ -3,6 +3,7 @@
|
||||
"""Convert directories of JSON events to C code."""
|
||||
import argparse
|
||||
import csv
|
||||
from functools import lru_cache
|
||||
import json
|
||||
import metric
|
||||
import os
|
||||
@ -337,18 +338,28 @@ class JsonEvent:
|
||||
s = self.build_c_string()
|
||||
return f'{{ { _bcs.offsets[s] } }}, /* {s} */\n'
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]:
|
||||
"""Read json events from the specified file."""
|
||||
|
||||
try:
|
||||
result = json.load(open(path), object_hook=JsonEvent)
|
||||
events = json.load(open(path), object_hook=JsonEvent)
|
||||
except BaseException as err:
|
||||
print(f"Exception processing {path}")
|
||||
raise
|
||||
for event in result:
|
||||
metrics: list[Tuple[str, metric.Expression]] = []
|
||||
for event in events:
|
||||
event.topic = topic
|
||||
return result
|
||||
if event.metric_name and '-' not in event.metric_name:
|
||||
metrics.append((event.metric_name, event.metric_expr))
|
||||
updates = metric.RewriteMetricsInTermsOfOthers(metrics)
|
||||
if updates:
|
||||
for event in events:
|
||||
if event.metric_name in updates:
|
||||
# print(f'Updated {event.metric_name} from\n"{event.metric_expr}"\n'
|
||||
# f'to\n"{updates[event.metric_name]}"')
|
||||
event.metric_expr = updates[event.metric_name]
|
||||
|
||||
return events
|
||||
|
||||
def preprocess_arch_std_files(archpath: str) -> None:
|
||||
"""Read in all architecture standard events."""
|
||||
|
Loading…
Reference in New Issue
Block a user