Re: [PATCH v2] rt-tests: hwlatdetect: Add a grouping separator to tracing_cpumask

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Mon, 2 Jun 2025, Costa Shulyupin wrote:

> 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@xxxxxxxxxx>
> 
> ---
> Cnahges in v2:
> - rebased
> 
> Signed-off-by: Costa Shulyupin <costa.shul@xxxxxxxxxx>
> ---
>  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 dc28f38b751a..946bef33748b 100755
> --- a/src/hwlatdetect/hwlatdetect.py
> +++ b/src/hwlatdetect/hwlatdetect.py
> @@ -33,6 +33,11 @@ def info(istr):
>          print(istr)
>  
>  
> +def group_sep(hex):

Can you rename the above since hex is a python built-in?

> +    """ 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
> @@ -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}")
> -- 
> 2.48.1
> 
> 
> 





[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux