Skip to contentSkip to conversation

perf jevents: Ignore sys when determining a model directory

PATCH In review Ian Rogers 2 participants 2 messages Sep 4, 2024 – Sep 5, 2024 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 perf jevents: Ignore sys when determining a model directory

Existing sys directories aren't placed under a model directory like skylake. Placing a sys directory there causes the is_leaf_dir test to fail and consequently no events or metrics are generated for the model. Ignore sys directories in this case and update the comments to reflect why.

This change has no affect, but when testing with a sys directory for a model people have reported running into the no event/metric issue.

---
 tools/perf/pmu-events/jevents.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
tools/perf/pmu-events/jevents.py +7 -4
index 1d96b2204e52..bb0a5d92df4a 100755
@@ -635,14 +635,17 @@ def preprocess_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
 
 def process_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
   """Process a JSON file during the main walk."""
-  def is_leaf_dir(path: str) -> bool:
+  def is_leaf_dir_ignoring_sys(path: str) -> bool:
     for item in os.scandir(path):
-      if item.is_dir():
+      if item.is_dir() and item.name != 'sys':
         return False
     return True
 
-  # model directory, reset topic
-  if item.is_dir() and is_leaf_dir(item.path):
+  # Model directories are leaves (ignoring possible sys
+  # directories). The FTW will walk into the directory next. Flush
+  # pending events and metrics and update the table names for the new
+  # model directory.
+  if item.is_dir() and is_leaf_dir_ignoring_sys(item.path):
     print_pending_events()
     print_pending_metrics()
 
Signature · 1 line
2.46.0.469.g59c65b2a67-goog
#1 lore raw
Quoted 8 lines · Ian Rogers

Existing sys directories aren't placed under a model directory like skylake. Placing a sys directory there causes the is_leaf_dir test to fail and consequently no events or metrics are generated for the model. Ignore sys directories in this case and update the comments to reflect why.

This change has no affect, but when testing with a sys directory for a model people have reported running into the no event/metric issue.

Thanks, applied, if Stephan is satisfied with the fix and have tested it, please consider providing a Tested-by,

Thanks,

- Arnaldo

Quoted 34 lines
---
 tools/perf/pmu-events/jevents.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
tools/perf/pmu-events/jevents.py +7 -4
index 1d96b2204e52..bb0a5d92df4a 100755
@@ -635,14 +635,17 @@ def preprocess_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
 
 def process_one_file(parents: Sequence[str], item: os.DirEntry) -> None:
   """Process a JSON file during the main walk."""
-  def is_leaf_dir(path: str) -> bool:
+  def is_leaf_dir_ignoring_sys(path: str) -> bool:
     for item in os.scandir(path):
-      if item.is_dir():
+      if item.is_dir() and item.name != 'sys':
         return False
     return True
 
-  # model directory, reset topic
-  if item.is_dir() and is_leaf_dir(item.path):
+  # Model directories are leaves (ignoring possible sys
+  # directories). The FTW will walk into the directory next. Flush
+  # pending events and metrics and update the table names for the new
+  # model directory.
+  if item.is_dir() and is_leaf_dir_ignoring_sys(item.path):
     print_pending_events()
     print_pending_metrics()
 
Signature · 1 line
2.46.0.469.g59c65b2a67-goog