[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5d904bee-3faf-374a-090c-ce7c99c84ea9@huawei.com>
Date: Thu, 17 Feb 2022 18:44:05 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: Vlastimil Babka <vbabka@...e.cz>
CC: <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Christoph Lameter <cl@...ux.com>, <penberg@...nel.org>,
<rientjes@...gle.com>, <iamjoonsoo.kim@....com>
Subject: Re: [PATCH] mm/slab_common: use helper function is_power_of_2()
On 2022/2/17 17:23, Vlastimil Babka wrote:
> On 2/17/22 10:16, Miaohe Lin wrote:
>> Use helper function is_power_of_2() to check if KMALLOC_MIN_SIZE is power
>> of two. Minor readability improvement.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
>
> We can try, but in case some compiler will no longer able to perform the
> check at build-time (although is_power_of_2() looks sufficiently trivial
> too), we'll have to revert it.
I see. I checked the compiler in my env but there might be some compilers can't
perform the check at build-time.
Many thanks for your reply.
>
>> ---
>> mm/slab_common.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>> index 23f2ab0713b7..6ee64d6208b3 100644
>> --- a/mm/slab_common.c
>> +++ b/mm/slab_common.c
>> @@ -807,7 +807,7 @@ void __init setup_kmalloc_cache_index_table(void)
>> unsigned int i;
>>
>> BUILD_BUG_ON(KMALLOC_MIN_SIZE > 256 ||
>> - (KMALLOC_MIN_SIZE & (KMALLOC_MIN_SIZE - 1)));
>> + !is_power_of_2(KMALLOC_MIN_SIZE));
>>
>> for (i = 8; i < KMALLOC_MIN_SIZE; i += 8) {
>> unsigned int elem = size_index_elem(i);
>
> .
>
Powered by blists - more mailing lists