Re: [PATCH v6 1/8] x86/runtime-const: Introduce runtime_const_mask_32()

K Prateek Nayak <[email protected]>
Newsgroups dev.linux.lists.sashiko-reviews,org.kernel.vger.linux-s390
Message-ID <[email protected]>
Hello,

On 7/28/2026 11:07 AM, [email protected] wrote:
>> diff --git a/arch/x86/include/asm/runtime-const.h b/arch/x86/include/asm/runtime-const.h
>> index 4cd94fdcb45e2..b13f7036c1c9b 100644
>> --- a/arch/x86/include/asm/runtime-const.h
>> +++ b/arch/x86/include/asm/runtime-const.h
> [ ... ]
>> @@ -41,6 +41,15 @@
>>  		:"+r" (__ret));					\
>>  	__ret; })
>>  
>> +#define runtime_const_mask_32(val, sym) ({			\
>> +	typeof(0u+(val)) __ret = (val);				\
>> +	asm_inline("and $0x12345678, %k0\n1:\n"				\
>> +		   ".pushsection runtime_mask_" #sym ",\"a\"\n\t"\
>> +		   ".long 1b - 4 - .\n"				\
>> +		   ".popsection"				\
>> +		   : "+r" (__ret));				\
>> +	__ret; })
>> +
> 
> [Severity: Medium]
> Will this cause a build regression on non-x86 architectures when the generic
> code starts using runtime_const_mask_32()?

That only happens at Patch 8 and by Patch 7, we have the generic
fallback. Everything is aligned before the first user is introduced.

> 
> The commit message mentions this will be used by the futex hash computation in
> a subsequent commit. However, there doesn't appear to be a generic fallback
> for this macro in include/asm-generic/runtime-const.h.
> 
> Without a generic fallback, it seems architectures that don't support or
> haven't yet implemented runtime constants would fail to compile once the
> generic futex code uses this macro.
> 
> Should a fallback like the following be introduced in
> include/asm-generic/runtime-const.h alongside this x86 implementation to
> maintain cross-architecture compatibility and strict bisectability?
> 
> #define runtime_const_mask_32(val, sym) ((val) & (sym))

Done in Patch 7. Bisectibility is preserved by having the plumbing
in place (in some order) before first user is introduced in Patch 8.

-- 
Thanks and Regards,
Prateek
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.