Commit e1e19d05 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf jevents: Clean up pytype warnings

Improve type hints to clean up pytype warnings.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.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: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@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
Link: http://lore.kernel.org/lkml/20220804221816.1802790-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5b245985
...@@ -6,8 +6,7 @@ import csv ...@@ -6,8 +6,7 @@ import csv
import json import json
import os import os
import sys import sys
from typing import Callable from typing import (Callable, Optional, Sequence)
from typing import Sequence
# Global command line arguments. # Global command line arguments.
_args = None _args = None
...@@ -57,7 +56,7 @@ class JsonEvent: ...@@ -57,7 +56,7 @@ class JsonEvent:
'. '), '.').replace('\n', '\\n').replace( '. '), '.').replace('\n', '\\n').replace(
'\"', '\\"').replace('\r', '\\r') '\"', '\\"').replace('\r', '\\r')
def convert_aggr_mode(aggr_mode: str) -> str: def convert_aggr_mode(aggr_mode: str) -> Optional[str]:
"""Returns the aggr_mode_class enum value associated with the JSON string.""" """Returns the aggr_mode_class enum value associated with the JSON string."""
if not aggr_mode: if not aggr_mode:
return None return None
...@@ -67,7 +66,7 @@ class JsonEvent: ...@@ -67,7 +66,7 @@ class JsonEvent:
} }
return aggr_mode_to_enum[aggr_mode] return aggr_mode_to_enum[aggr_mode]
def lookup_msr(num: str) -> str: def lookup_msr(num: str) -> Optional[str]:
"""Converts the msr number, or first in a list to the appropriate event field.""" """Converts the msr number, or first in a list to the appropriate event field."""
if not num: if not num:
return None return None
...@@ -79,7 +78,7 @@ class JsonEvent: ...@@ -79,7 +78,7 @@ class JsonEvent:
} }
return msrmap[int(num.split(',', 1)[0], 0)] return msrmap[int(num.split(',', 1)[0], 0)]
def real_event(name: str, event: str) -> str: def real_event(name: str, event: str) -> Optional[str]:
"""Convert well known event names to an event string otherwise use the event argument.""" """Convert well known event names to an event string otherwise use the event argument."""
fixed = { fixed = {
'inst_retired.any': 'event=0xc0,period=2000003', 'inst_retired.any': 'event=0xc0,period=2000003',
...@@ -95,7 +94,7 @@ class JsonEvent: ...@@ -95,7 +94,7 @@ class JsonEvent:
return fixed[name.lower()] return fixed[name.lower()]
return event return event
def unit_to_pmu(unit: str) -> str: def unit_to_pmu(unit: str) -> Optional[str]:
"""Convert a JSON Unit to Linux PMU name.""" """Convert a JSON Unit to Linux PMU name."""
if not unit: if not unit:
return None return None
...@@ -154,7 +153,7 @@ class JsonEvent: ...@@ -154,7 +153,7 @@ class JsonEvent:
if self.metric_expr: if self.metric_expr:
self.metric_expr = self.metric_expr.replace('\\', '\\\\') self.metric_expr = self.metric_expr.replace('\\', '\\\\')
arch_std = jd.get('ArchStdEvent') arch_std = jd.get('ArchStdEvent')
if precise and self.desc and not '(Precise Event)' in self.desc: if precise and self.desc and '(Precise Event)' not in self.desc:
extra_desc += ' (Must be precise)' if precise == '2' else (' (Precise ' extra_desc += ' (Must be precise)' if precise == '2' else (' (Precise '
'event)') 'event)')
event = f'config={llx(configcode)}' if configcode is not None else f'event={llx(eventcode)}' event = f'config={llx(configcode)}' if configcode is not None else f'event={llx(eventcode)}'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment