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

perf jevents: Skip optional metrics in metric group list

For metric groups, skip metrics in the list that are None. This allows
functions to better optionally return metrics.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
d9f2ce39 a1d9bb1a

+5 -3
+5 -3
tools/perf/pmu-events/metric.py
··· 493 493 """ 494 494 495 495 def __init__(self, name: str, 496 - metric_list: List[Union[Metric, 'MetricGroup']], 496 + metric_list: List[Union[Optional[Metric], Optional['MetricGroup']]], 497 497 description: Optional[str] = None): 498 498 self.name = name 499 - self.metric_list = metric_list 499 + self.metric_list = [] 500 500 self.description = description 501 501 for metric in metric_list: 502 - metric.AddToMetricGroup(self) 502 + if metric: 503 + self.metric_list.append(metric) 504 + metric.AddToMetricGroup(self) 503 505 504 506 def AddToMetricGroup(self, group): 505 507 """Callback used when a MetricGroup is added into another."""