[PATCH v2 0/6] Enable setexpr command to print cpu-list like bitmaps

Lukas Funke lukas.funke-oss at weidmueller.com
Tue Dec 12 12:51:01 CET 2023


Hi Heinrich,

On 12.12.2023 11:13, Heinrich Schuchardt wrote:
> On 12.12.23 09:52, lukas.funke-oss at weidmueller.com wrote:
>> From: Lukas Funke <lukas.funke at weidmueller.com>
>>
>>
>> This series enables the 'setexpr' command to print "cpu list"-like
>> bitmaps based on the printk format specifier [1].
>>
>> One use-case is to pass cpu list [2] based kernel parameter like
>> 'isolcpu', 'nohz_full', irq affinity or RCU related CPU parameter to
>> the kernel via a separate firmware variable without exposing the
>> 'bootargs' variable to directly.
>>
>> Example:
>>
>> setexpr isolcpu_bootarg=%32pbl $myCPUisolation
> 
> I applied your patches on top of origin/next but your example simply
> does not work:
> 
> => setenv myCPUisolation 123456789abcdef0
> => setexpr isolcpu_bootarg=%32pbl $myCPUisolation
> ## Error: illegal character '='in variable name "isolcpu_bootarg=%32pbl"

Thanks for testing.

I messed up the example in the cover letter. In your case it actually 
should be

=> setenv myCPUisolation 0x123456789abcdef0
=> setexpr bootargs fmt isolcpu_bootarg=%64pbl $myCPUisolation
=> echo $bootargs
isolcpu_bootarg=4-7,9-12,14-15,18-21,23,25,27-28,31,35-37,41,44,46-47,50,52,57-59

...which is wrong btw (the upper half bitmask is crooked).

> 
> This produces some output:
> 
> => setexpr a fmt '%32pbl' 64; echo $a
> 6
> 
> But the result is completely unexpected. Number arguments in U-Boot are
> always hexadecimal. So the output should be

Thanks for pointing it out! The internals use autodetect from 
strtoll(...) which handles decimal and hexadecimal. All other uses of 
strtoll use 16 as base. I'll address this issue in the next version.

> 
> 2,5-6
> 
> Best regards
> 
> Heinrich
> 
>> && env set bootargs "$isolcpu_bootarg"
>> && bootm
>>
>> [1] https://www.kernel.org/doc/Documentation/printk-formats.txt
>> [2] 
>> https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
>>
>>
>> Changes in v2:
>> - Add bitmap format specifier to documentation
>>
>> Lukas Funke (6):
>>    sandbox: add generic find_next_zero_bit implementation
>>    linux: bitmap.h: add 'for_each_set_bitrange' iteration macro
>>    test: cmd: setexptr: Add tests for bitmap string format
>>    doc: printf() codes: Add bitmap format specifier
>>    lib: vsprintf: enable '%*pb[l]' format specifier
>>    cmd: printf: forward '%p' format string specifier
>>
>>   arch/sandbox/include/asm/bitops.h | 16 ++++++-
>>   cmd/printf.c                      | 29 ++++++++++++
>>   doc/develop/printf.rst            |  6 +++
>>   include/linux/bitmap.h            |  7 +++
>>   lib/vsprintf.c                    | 75 +++++++++++++++++++++++++++++++
>>   test/cmd/setexpr.c                |  9 ++++
>>   6 files changed, 140 insertions(+), 2 deletions(-)
>>
> 



More information about the U-Boot mailing list