linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] rt-tests: hwlatdetect: Add a grouping separator to tracing_cpumask
@ 2025-01-03  5:32 Costa Shulyupin
  0 siblings, 0 replies; only message in thread
From: Costa Shulyupin @ 2025-01-03  5:32 UTC (permalink / raw)
  To: Costa Shulyupin, linux-rt-users; +Cc: Bart Wensley, John Kacur, Clark Williams

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.

Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
 src/hwlatdetect/hwlatdetect.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index 352abb6..87e4ee5 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -35,6 +35,11 @@ def info(istr):
         sys.stdout.flush()
 
 
+def group_sep(hex):
+    """ Add a comma as a grouping separator every 32 bits to a hexadecimal number. """
+    return ','.join([hex[max(i - 8, 0):i] for i in range(len(hex), 0, -8)][::-1])
+
+
 #
 # Class used to manage mounting and umounting the debugfs
 # filesystem. Note that if an instance of this class mounts
@@ -497,7 +502,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}")
-- 
2.47.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-01-03  5:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-03  5:32 [PATCH v1] rt-tests: hwlatdetect: Add a grouping separator to tracing_cpumask Costa Shulyupin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).