Skip to contentSkip to conversation

perf jevents: Fix build issue in '*/' in event descriptions

PATCH In review Ian Rogers 2 participants 10 messages Nov 13, 2024 – Dec 10, 2024 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 perf jevents: Fix build issue in '*/' in event descriptions

For big string offsets we output comments for what string the offset is for. If the string contains a '*/' as seen in Intel Arrowlake event descriptions, then this causes C parsing issues for the generated pmu-events.c. Catch such '*/' values and escape to avoid this.

---
 tools/perf/pmu-events/jevents.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/pmu-events/jevents.py +4 -1
index 6e71b09dbc2a..028cf3c43881 100755
@@ -430,8 +430,11 @@ class JsonEvent:
   def to_c_string(self, metric: bool) -> str:
     """Representation of the event as a C struct initializer."""
 
+    def fix_comment(s: str) -> str:
+        return s.replace('*/', '\*\/')
+
     s = self.build_c_string(metric)
-    return f'{{ { _bcs.offsets[s] } }}, /* {s} */\n'
+    return f'{{ { _bcs.offsets[s] } }}, /* {fix_comment(s)} */\n'
 
 
 @lru_cache(maxsize=None)
Signature · 1 line
2.47.0.277.g8800431eea-goog
author reviewer
#1 lore raw
Quoted 7 lines · Ian Rogers

For big string offsets we output comments for what string the offset is for. If the string contains a '*/' as seen in Intel Arrowlake event descriptions, then this causes C parsing issues for the generated pmu-events.c. Catch such '*/' values and escape to avoid this.

Ping.

Thanks,
Ian

Quoted 24 lines
---
 tools/perf/pmu-events/jevents.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/pmu-events/jevents.py +4 -2
index 6e71b09dbc2a..028cf3c43881 100755
@@ -430,8 +430,11 @@ class JsonEvent:
   def to_c_string(self, metric: bool) -> str:
     """Representation of the event as a C struct initializer."""
 
+    def fix_comment(s: str) -> str:
+        return s.replace('*/', '\*\/')
+
     s = self.build_c_string(metric)
-    return f'{{ { _bcs.offsets[s] } }}, /* {s} */\n'
+    return f'{{ { _bcs.offsets[s] } }}, /* {fix_comment(s)} */\n'
 
 
 @lru_cache(maxsize=None)
--

2.47.0.277.g8800431eea-goog

#2 lore raw
Quoted 10 lines · Ian Rogers
Quoted 7 lines · Ian Rogers

For big string offsets we output comments for what string the offset is for. If the string contains a '*/' as seen in Intel Arrowlake event descriptions, then this causes C parsing issues for the generated pmu-events.c. Catch such '*/' values and escape to avoid this.

Ping.

A fixes: is missing, probably this should go via perf-tools, i.e. for this merge window?

- Arnaldo

Quoted 27 lines

Thanks,
Ian

Quoted 24 lines
---
 tools/perf/pmu-events/jevents.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/pmu-events/jevents.py +4 -2
index 6e71b09dbc2a..028cf3c43881 100755
@@ -430,8 +430,11 @@ class JsonEvent:
   def to_c_string(self, metric: bool) -> str:
     """Representation of the event as a C struct initializer."""
 
+    def fix_comment(s: str) -> str:
+        return s.replace('*/', '\*\/')
+
     s = self.build_c_string(metric)
-    return f'{{ { _bcs.offsets[s] } }}, /* {s} */\n'
+    return f'{{ { _bcs.offsets[s] } }}, /* {fix_comment(s)} */\n'
 
 
 @lru_cache(maxsize=None)
--

2.47.0.277.g8800431eea-goog

author reviewer
#3 lore raw
Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 7 lines · Ian Rogers
Quoted 6 lines · Ian Rogers

For big string offsets we output comments for what string the offset is for. If the string contains a '*/' as seen in Intel Arrowlake event descriptions, then this causes C parsing issues for the generated pmu-events.c. Catch such '*/' values and escape to avoid this.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Ping.

A fixes: is missing, probably this should go via perf-tools, i.e. for this merge window?

We don't yet have arrowlake events/metrics, should there be a fixes? I'm just preparing the patches for the latest vendor json from Intel, but they will depend on this. I suspect given the size of the vendor json it will miss the current merge window.

Thanks,
Ian

#4 lore raw
Quoted 11 lines · Ian Rogers
Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 7 lines · Ian Rogers
Quoted 6 lines · Ian Rogers

For big string offsets we output comments for what string the offset is for. If the string contains a '*/' as seen in Intel Arrowlake event descriptions, then this causes C parsing issues for the generated pmu-events.c. Catch such '*/' values and escape to avoid this.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Ping.

A fixes: is missing, probably this should go via perf-tools, i.e. for this merge window?

We don't yet have arrowlake events/metrics, should there be a fixes?

Ok, thanks for the clarification.

Quoted 3 lines

I'm just preparing the patches for the latest vendor json from Intel, but they will depend on this. I suspect given the size of the vendor json it will miss the current merge window.

Probably best to have big patches via perf-tools-next at this point in time.

- Arnaldo

#5 lore raw
Quoted 21 lines · Arnaldo Carvalho de Melo
Quoted 11 lines · Ian Rogers
Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 7 lines · Ian Rogers
Quoted 6 lines · Ian Rogers

For big string offsets we output comments for what string the offset is for. If the string contains a '*/' as seen in Intel Arrowlake event descriptions, then this causes C parsing issues for the generated pmu-events.c. Catch such '*/' values and escape to avoid this.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Ping.

A fixes: is missing, probably this should go via perf-tools, i.e. for this merge window?

We don't yet have arrowlake events/metrics, should there be a fixes?

Quoted 8 lines

Ok, thanks for the clarification.

Quoted 3 lines

I'm just preparing the patches for the latest vendor json from Intel, but they will depend on this. I suspect given the size of the vendor json it will miss the current merge window.

Probably best to have big patches via perf-tools-next at this point in time.

I'm seeing this after applying:

/home/acme/git/perf-tools-next/tools/perf/pmu-events/jevents.py:434: SyntaxWarning: invalid escape sequence '\*'
return s.replace('*/', '\*\/')

⬢ [acme@toolbox perf-tools-next]$ head /etc/os-release NAME="Fedora Linux"
VERSION="40 (Toolbx Container Image)" ID=fedora
VERSION_ID=40
VERSION_CODENAME="" PLATFORM_ID="platform:f40" PRETTY_NAME="Fedora Linux 40 (Toolbx Container Image)" ANSI_COLOR="0;38;2;60;110;180" LOGO=fedora-logo-icon CPE_NAME="cpe:/o:fedoraproject:fedora:40"
⬢ [acme@toolbox perf-tools-next]$ python --version Python 3.12.7
⬢ [acme@toolbox perf-tools-next]$

author reviewer
#6 lore raw
Quoted 29 lines · Arnaldo Carvalho de Melo
Quoted 27 lines · Arnaldo Carvalho de Melo
Quoted 11 lines · Ian Rogers
Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 7 lines · Ian Rogers
Quoted 6 lines · Ian Rogers

For big string offsets we output comments for what string the offset is for. If the string contains a '*/' as seen in Intel Arrowlake event descriptions, then this causes C parsing issues for the generated pmu-events.c. Catch such '*/' values and escape to avoid this.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Ping.

A fixes: is missing, probably this should go via perf-tools, i.e. for this merge window?

We don't yet have arrowlake events/metrics, should there be a fixes?

Ok, thanks for the clarification.

Quoted 3 lines

I'm just preparing the patches for the latest vendor json from Intel, but they will depend on this. I suspect given the size of the vendor json it will miss the current merge window.

Quoted 7 lines
Quoted 2 lines

Probably best to have big patches via perf-tools-next at this point in time.

I'm seeing this after applying:

/home/acme/git/perf-tools-next/tools/perf/pmu-events/jevents.py:434: SyntaxWarning: invalid escape sequence '\*'
return s.replace('*/', '\*\/')

It likely needs to be:

```
return s.replace('*/', r'\*\/')
```

note the r. Could you test for me?

Thanks,
Ian

Quoted 16 lines

⬢ [acme@toolbox perf-tools-next]$ head /etc/os-release NAME="Fedora Linux"
VERSION="40 (Toolbx Container Image)" ID=fedora
VERSION_ID=40
VERSION_CODENAME="" PLATFORM_ID="platform:f40" PRETTY_NAME="Fedora Linux 40 (Toolbx Container Image)" ANSI_COLOR="0;38;2;60;110;180" LOGO=fedora-logo-icon CPE_NAME="cpe:/o:fedoraproject:fedora:40"
⬢ [acme@toolbox perf-tools-next]$ python --version Python 3.12.7
⬢ [acme@toolbox perf-tools-next]$

#7 lore raw
Quoted 36 lines · Ian Rogers
Quoted 34 lines · Arnaldo Carvalho de Melo
Quoted 21 lines · Arnaldo Carvalho de Melo
Quoted 11 lines · Ian Rogers
Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 7 lines · Ian Rogers
Quoted 6 lines · Ian Rogers

For big string offsets we output comments for what string the offset is for. If the string contains a '*/' as seen in Intel Arrowlake event descriptions, then this causes C parsing issues for the generated pmu-events.c. Catch such '*/' values and escape to avoid this.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Ping.

A fixes: is missing, probably this should go via perf-tools, i.e. for this merge window?

We don't yet have arrowlake events/metrics, should there be a fixes?

Quoted 8 lines

Ok, thanks for the clarification.

Quoted 3 lines

I'm just preparing the patches for the latest vendor json from Intel, but they will depend on this. I suspect given the size of the vendor json it will miss the current merge window.

Probably best to have big patches via perf-tools-next at this point in time.

I'm seeing this after applying:

Quoted 8 lines
Quoted 2 lines

/home/acme/git/perf-tools-next/tools/perf/pmu-events/jevents.py:434: SyntaxWarning: invalid escape sequence '\*'
return s.replace('*/', '\*\/')

It likely needs to be:

```
return s.replace('*/', r'\*\/')
```

note the r. Could you test for me?

Sure.

- Arnaldo

#8 lore raw
Quoted 11 lines · Arnaldo Carvalho de Melo
Quoted 10 lines · Ian Rogers

On Tue, Dec 10, 2024 at 11:17 AM Arnaldo Carvalho de Melo

Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

Probably best to have big patches via perf-tools-next at this point in time.

I'm seeing this after applying:

/home/acme/git/perf-tools-next/tools/perf/pmu-events/jevents.py:434: SyntaxWarning: invalid escape sequence '\*'
return s.replace('*/', '\*\/')

Quoted 7 lines
Quoted 5 lines

It likely needs to be:

```
return s.replace('*/', r'\*\/')
```

note the r. Could you test for me?

Sure.

Yeah, no more warning, thanks, fixed it up.

- Arnaldo

author reviewer
#9 lore raw
Quoted 19 lines · Arnaldo Carvalho de Melo
Quoted 17 lines · Arnaldo Carvalho de Melo
Quoted 15 lines · Ian Rogers

On Tue, Dec 10, 2024 at 11:17 AM Arnaldo Carvalho de Melo

Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 2 lines

Probably best to have big patches via perf-tools-next at this point in time.

I'm seeing this after applying:

/home/acme/git/perf-tools-next/tools/perf/pmu-events/jevents.py:434: SyntaxWarning: invalid escape sequence '\*'
return s.replace('*/', '\*\/')

It likely needs to be:

```
return s.replace('*/', r'\*\/')
```

note the r. Could you test for me?

Quoted 3 lines
Quoted 1 line

Sure.

Yeah, no more warning, thanks, fixed it up.

Thanks for your help!
Ian