This allows the set of generated jevents events and metrics be limited
to a subset of the model names. Appropriate if trying to minimize the
binary size where only a set of models are possible.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/pmu-events/Build | 3 ++-
tools/perf/pmu-events/jevents.py | 14 ++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
index 15b9e8fdbffa..a14de24ecb69 100644
--- a/tools/perf/pmu-events/Build
+++ b/tools/perf/pmu-events/Build
@@ -10,6 +10,7 @@ JEVENTS_PY = pmu-events/jevents.py
ifeq ($(JEVENTS_ARCH),)
JEVENTS_ARCH=$(SRCARCH)
endif
+JEVENTS_MODEL ?= all
#
# Locate/process JSON files in pmu-events/arch/
@@ -23,5 +24,5 @@ $(OUTPUT)pmu-events/pmu-events.c: pmu-events/empty-pmu-events.c
else
$(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS_PY) pmu-events/metric.py
$(call rule_mkdir)
- $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) pmu-events/arch $@
+ $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@
endif
diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 627ee817f57f..2bcd07ce609f 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -599,6 +599,8 @@ const struct pmu_events_map pmu_events_map[] = {
else:
metric_tblname = 'NULL'
metric_size = '0'
+ if event_size == '0' and metric_size == '0':
+ continue
cpuid = row[0].replace('\\', '\\\\')
_args.output_file.write(f"""{{
\t.arch = "{arch}",
@@ -888,12 +890,24 @@ def main() -> None:
action: Callable[[Sequence[str], os.DirEntry], None]) -> None:
"""Replicate the directory/file walking behavior of C's file tree walk."""
for item in os.scandir(path):
+ if _args.model != 'all' and item.is_dir():
+ # Check if the model matches one in _args.model.
+ 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(','):
+ continue
action(parents, item)
if item.is_dir():
ftw(item.path, parents + [item.name], action)
ap = argparse.ArgumentParser()
ap.add_argument('arch', help='Architecture name like x86')
+ ap.add_argument('model', help='''Select a model such as skylake to
+reduce the code size. Normally set to "all". For architectures like
+ARM64 with an implementor/model, the model must include the implementor
+such as "arm/cortex-a34".''',
+ default='all')
ap.add_argument(
'starting_dir',
type=dir_path,
--
2.39.1.456.gfc5497dd1b-goog
On 26/01/2023 01:18, Ian Rogers wrote: > This allows the set of generated jevents events and metrics be limited > to a subset of the model names. Appropriate if trying to minimize the > binary size where only a set of models are possible. > > Signed-off-by: Ian Rogers <irogers@google.com> Thanks for this: Reviewed-by: John Garry <john.g.garry@oracle.com> > --- > tools/perf/pmu-events/Build | 3 ++- > tools/perf/pmu-events/jevents.py | 14 ++++++++++++++ > 2 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build > index 15b9e8fdbffa..a14de24ecb69 100644 > --- a/tools/perf/pmu-events/Build > +++ b/tools/perf/pmu-events/Build > @@ -10,6 +10,7 @@ JEVENTS_PY = pmu-events/jevents.py > ifeq ($(JEVENTS_ARCH),) > JEVENTS_ARCH=$(SRCARCH) > endif > +JEVENTS_MODEL ?= all > > # > # Locate/process JSON files in pmu-events/arch/ > @@ -23,5 +24,5 @@ $(OUTPUT)pmu-events/pmu-events.c: pmu-events/empty-pmu-events.c > else > $(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS_PY) pmu-events/metric.py > $(call rule_mkdir) > - $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) pmu-events/arch $@ > + $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@ > endif > diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py > index 627ee817f57f..2bcd07ce609f 100755 > --- a/tools/perf/pmu-events/jevents.py > +++ b/tools/perf/pmu-events/jevents.py > @@ -599,6 +599,8 @@ const struct pmu_events_map pmu_events_map[] = { > else: > metric_tblname = 'NULL' > metric_size = '0' > + if event_size == '0' and metric_size == '0': > + continue > cpuid = row[0].replace('\\', '\\\\') > _args.output_file.write(f"""{{ > \t.arch = "{arch}", > @@ -888,12 +890,24 @@ def main() -> None: > action: Callable[[Sequence[str], os.DirEntry], None]) -> None: > """Replicate the directory/file walking behavior of C's file tree walk.""" > for item in os.scandir(path): > + if _args.model != 'all' and item.is_dir(): > + # Check if the model matches one in _args.model. > + 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(','): > + continue > action(parents, item) > if item.is_dir(): > ftw(item.path, parents + [item.name], action) > > ap = argparse.ArgumentParser() > ap.add_argument('arch', help='Architecture name like x86') > + ap.add_argument('model', help='''Select a model such as skylake to > +reduce the code size. Normally set to "all". For architectures like > +ARM64 with an implementor/model, the model must include the implementor mega-nit: /s/ARM64/arm64/ it just makes grepping easier (without -i, of course) > +such as "arm/cortex-a34".''', > + default='all') > ap.add_argument( > 'starting_dir', > type=dir_path,
Em Thu, Jan 26, 2023 at 01:44:39PM +0000, John Garry escreveu: > On 26/01/2023 01:18, Ian Rogers wrote: > > This allows the set of generated jevents events and metrics be limited > > to a subset of the model names. Appropriate if trying to minimize the > > binary size where only a set of models are possible. > > > > Signed-off-by: Ian Rogers <irogers@google.com> > > Thanks for this: > > Reviewed-by: John Garry <john.g.garry@oracle.com> Thanks for reviewing the series John, I see there are a few patches for which you didn't provide your Reviewed-by, are you planning to review those as well? - Arnaldo > > --- > > tools/perf/pmu-events/Build | 3 ++- > > tools/perf/pmu-events/jevents.py | 14 ++++++++++++++ > > 2 files changed, 16 insertions(+), 1 deletion(-) > > > > diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build > > index 15b9e8fdbffa..a14de24ecb69 100644 > > --- a/tools/perf/pmu-events/Build > > +++ b/tools/perf/pmu-events/Build > > @@ -10,6 +10,7 @@ JEVENTS_PY = pmu-events/jevents.py > > ifeq ($(JEVENTS_ARCH),) > > JEVENTS_ARCH=$(SRCARCH) > > endif > > +JEVENTS_MODEL ?= all > > # > > # Locate/process JSON files in pmu-events/arch/ > > @@ -23,5 +24,5 @@ $(OUTPUT)pmu-events/pmu-events.c: pmu-events/empty-pmu-events.c > > else > > $(OUTPUT)pmu-events/pmu-events.c: $(JSON) $(JSON_TEST) $(JEVENTS_PY) pmu-events/metric.py > > $(call rule_mkdir) > > - $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) pmu-events/arch $@ > > + $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) pmu-events/arch $@ > > endif > > diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py > > index 627ee817f57f..2bcd07ce609f 100755 > > --- a/tools/perf/pmu-events/jevents.py > > +++ b/tools/perf/pmu-events/jevents.py > > @@ -599,6 +599,8 @@ const struct pmu_events_map pmu_events_map[] = { > > else: > > metric_tblname = 'NULL' > > metric_size = '0' > > + if event_size == '0' and metric_size == '0': > > + continue > > cpuid = row[0].replace('\\', '\\\\') > > _args.output_file.write(f"""{{ > > \t.arch = "{arch}", > > @@ -888,12 +890,24 @@ def main() -> None: > > action: Callable[[Sequence[str], os.DirEntry], None]) -> None: > > """Replicate the directory/file walking behavior of C's file tree walk.""" > > for item in os.scandir(path): > > + if _args.model != 'all' and item.is_dir(): > > + # Check if the model matches one in _args.model. > > + 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(','): > > + continue > > action(parents, item) > > if item.is_dir(): > > ftw(item.path, parents + [item.name], action) > > ap = argparse.ArgumentParser() > > ap.add_argument('arch', help='Architecture name like x86') > > + ap.add_argument('model', help='''Select a model such as skylake to > > +reduce the code size. Normally set to "all". For architectures like > > +ARM64 with an implementor/model, the model must include the implementor > > mega-nit: /s/ARM64/arm64/ > > it just makes grepping easier (without -i, of course) > > > +such as "arm/cortex-a34".''', > > + default='all') > > ap.add_argument( > > 'starting_dir', > > type=dir_path, > -- - Arnaldo
On 26/01/2023 14:20, Arnaldo Carvalho de Melo wrote: > Em Thu, Jan 26, 2023 at 01:44:39PM +0000, John Garry escreveu: >> On 26/01/2023 01:18, Ian Rogers wrote: >>> This allows the set of generated jevents events and metrics be limited >>> to a subset of the model names. Appropriate if trying to minimize the >>> binary size where only a set of models are possible. >>> >>> Signed-off-by: Ian Rogers<irogers@google.com> >> Thanks for this: >> >> Reviewed-by: John Garry<john.g.garry@oracle.com> > Thanks for reviewing the series John, I see there are a few patches for > which you didn't provide your Reviewed-by, Hi Arnaldo, > are you planning to review > those as well? > I will do when I get a chance over the next day or so. I am just checking the easier ones at the moment :) Thanks, John
© 2016 - 2025 Red Hat, Inc.