From: Vlastimil Babka <vbabka@suse.cz>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com
Subject: Re: [PATCH] mm/slab_common: use helper function is_power_of_2()
Date: Thu, 17 Feb 2022 18:04:01 +0100 [thread overview]
Message-ID: <49a1bc35-7505-bc82-2931-e57f7b959cb3@suse.cz> (raw)
In-Reply-To: <5d904bee-3faf-374a-090c-ce7c99c84ea9@huawei.com>
On 2/17/22 11:44, Miaohe Lin wrote:
> 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@huawei.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.
I'll add this to the slab tree and linux-next and we'll see if wider testing
uncovers such compilers. Should be unlikely.
> 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);
>>
>> .
>>
>
next prev parent reply other threads:[~2022-02-17 17:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 9:16 Miaohe Lin
2022-02-17 9:23 ` Vlastimil Babka
2022-02-17 10:44 ` Miaohe Lin
2022-02-17 17:04 ` Vlastimil Babka [this message]
2022-02-18 1:15 ` Miaohe Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49a1bc35-7505-bc82-2931-e57f7b959cb3@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox