Skip to contentSkip to conversation

rt-tests: hwlatdetect: Add a grouping separator to tracing_cpumask

PATCH In review Costa Shulyupin 2 participants 2 messages Jun 19, 2025 – Jul 1, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 rt-tests: hwlatdetect: Add a grouping separator to tracing_cpumask

Writing values longer than 32 bits without a comma results in an error:

echo 100000000 > /sys/kernel/debug/tracing/tracing_cpumask
bash: echo: write error: Value too large for defined data type

The bitmap_pars() kernel function specification:
"Commas group hex digits into chunks.
Each chunk defines exactly 32 bits of the resultant bitmask. No chunk may specify a value larger than 32 bits (%-EOVERFLOW)"

Add a comma as a grouping separator every 32 bits to a hexadecimal number, as expected by the bitmap_pars() kernel function.

---
Changes in v3:
- rename hex to num_hex
Changes in v2:
- rebased

---
 src/hwlatdetect/hwlatdetect.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/hwlatdetect/hwlatdetect.py +6 -1
index dc28f38b751a..68f312db639f 100755
@@ -33,6 +33,11 @@ def info(istr):
         print(istr)
 
 
+def group_sep(num_hex):
+    """ Add a comma as a grouping separator every 32 bits to a hexadecimal number. """
+    return ','.join([num_hex[max(i - 8, 0):i] for i in range(len(num_hex), 0, -8)][::-1])
+
+
 #
 # Class used to manage mounting and umounting the debugfs
 # filesystem. Note that if an instance of this class mounts
@@ -494,7 +499,7 @@ def microseconds(sval):
             for i in range(l, r + 1):
                 cpumask |= (1 << i)
         debug(f"set tracing_cpumask to {cpumask:x}")
-        detect.set("cpumask", f"{cpumask:x}")
+        detect.set("cpumask", group_sep(f"{cpumask:x}"))
 
     info(f"hwlatdetect:  test duration {detect.testduration} seconds")
     info(f"   detector: {detect.type}")
Signature · 1 line
2.48.1
#1 lore raw
Quoted 56 lines · Costa Shulyupin

Writing values longer than 32 bits without a comma results in an error:

echo 100000000 > /sys/kernel/debug/tracing/tracing_cpumask
bash: echo: write error: Value too large for defined data type

The bitmap_pars() kernel function specification:
"Commas group hex digits into chunks.
Each chunk defines exactly 32 bits of the resultant bitmask. No chunk may specify a value larger than 32 bits (%-EOVERFLOW)"

Add a comma as a grouping separator every 32 bits to a hexadecimal number, as expected by the bitmap_pars() kernel function.

---
Changes in v3:
- rename hex to num_hex
Changes in v2:
- rebased

---
 src/hwlatdetect/hwlatdetect.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/hwlatdetect/hwlatdetect.py +6 -1
index dc28f38b751a..68f312db639f 100755
@@ -33,6 +33,11 @@ def info(istr):
         print(istr)
 
 
+def group_sep(num_hex):
+    """ Add a comma as a grouping separator every 32 bits to a hexadecimal number. """
+    return ','.join([num_hex[max(i - 8, 0):i] for i in range(len(num_hex), 0, -8)][::-1])
+
+
 #
 # Class used to manage mounting and umounting the debugfs
 # filesystem. Note that if an instance of this class mounts
@@ -494,7 +499,7 @@ def microseconds(sval):
             for i in range(l, r + 1):
                 cpumask |= (1 << i)
         debug(f"set tracing_cpumask to {cpumask:x}")
-        detect.set("cpumask", f"{cpumask:x}")
+        detect.set("cpumask", group_sep(f"{cpumask:x}"))
 
     info(f"hwlatdetect:  test duration {detect.testduration} seconds")
     info(f"   detector: {detect.type}")
Signature · 1 line
2.48.1