On 2026/08/17 19:48, Tao Liu wrote:
>>>> + /*
>>>> + * on Linux 7.1 and later, zone.vmemmap_tails is defined only when
>>>> + * CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP is enabled.
>>>> + */
>>>> +#define is_power_of_2(n) (n - 1 < (n ^ (n - 1)))
>>>
>>> Hi Kazu, BTW, there is one nitpick found by AI, it would be better to improve
the above macro as below or just use the kernel inline function:
>>> #define IS_POWER_OF_TWO(n) ((n) > 0 && ((n) & ((n) - 1)) ==
0)
>>
>> Either is fine, but I think the former is the current is_power_of_2()
>> used in compound_info_has_mask(), and I used the same one as kernel.
>
> Hi Kazu, I agree with you it should work here, but the suggested one is more robust
as it checks the edge value and adds parentheses around 'n' to avoid side effect
of multiple expansion in some cases. Anyway up to Tao to handle it or not.
>
Frankly I'd prefer the ((n) > 0 && ((n) & ((n) - 1)) == 0) one,
because it is more easy to understand than (n - 1 < (n ^ (n - 1))).
How about we use the former instead? If Kazu agrees, we can replace it
when merge, so no need to send v2. For the patchset, LGTM, ack.
I agree, rethinking crash's situation, it would be better to be easy
to understand rather than same as kernel in this case.
Thanks,
Kazu