linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Vlastimil Babka <vbabka@suse.cz>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Matthew Wilcox <willy@infradead.org>
Cc: Dawei Li <set_pte_at@outlook.com>, "cl@linux.com" <cl@linux.com>,
	"penberg@kernel.org" <penberg@kernel.org>,
	"rientjes@google.com" <rientjes@google.com>,
	"iamjoonsoo.kim@lge.com" <iamjoonsoo.kim@lge.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"roman.gushchin@linux.dev" <roman.gushchin@linux.dev>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: simplify size2index conversion of __kmalloc_index
Date: Tue, 30 Aug 2022 05:51:06 +0000	[thread overview]
Message-ID: <f02b862f-8e8c-0ec9-7b83-c9e26831c242@csgroup.eu> (raw)
In-Reply-To: <1188aeeb-3949-b561-bec0-512ed763d857@suse.cz>



Le 29/08/2022 à 16:21, Vlastimil Babka a écrit :
> On 8/29/22 05:36, Hyeonggon Yoo wrote:
>> On Mon, Aug 29, 2022 at 04:11:04AM +0100, Matthew Wilcox wrote:
>>> On Sun, Aug 28, 2022 at 11:14:48PM +0800, Dawei Li wrote:
>>>> Current size2index is implemented by one to one hardcode mapping,
>>>> which can be improved by order_base_2().
>>>> Must be careful to not violate compile-time optimization rule.
>>>
>>> This patch has been NACKed before (when submitted by other people).
>>
>>
>> Hmm right.
>> https://lkml.iu.edu/hypermail/linux/kernel/1606.2/05402.html
>>
>> Christoph Lameter wrote:
>>> On Wed, 22 Jun 2016, Yury Norov wrote:
>>>> There will be no fls() for constant at runtime because ilog2() calculates
>>>> constant values at compile-time as well. From this point of view,
>>>> this patch removes code duplication, as we already have compile-time
>>>> log() calculation in kernel, and should re-use it whenever possible.\
>>
>>> The reason not to use ilog there was that the constant folding did not
>>> work correctly with one or the other architectures/compilers. If you want
>>> to do this then please verify that all arches reliably do produce a
>>> constant there.
>>
>> Can we re-evaluate this?
> 
> Is there a way to turn inability of compile-time calculation to a
> compile-time error? (when size_is_constant=true etc). Then we could try and
> see if anything breaks in -next.
> 
> 

The following will generate a build error if the function 
constant_check() is not called with a buildtime constant argument.

static void __always_inline constant_check(unsigned long val)
{
	BUILD_BUG_ON(!__builtin_constant_p(val));
}

Is that what you are looking for ?

  parent reply	other threads:[~2022-08-30  5:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-28 15:14 [PATCH] mm: simplify size2index conversion of __kmalloc_index Dawei Li
2022-08-29  3:11 ` Matthew Wilcox
2022-08-29  3:36   ` Hyeonggon Yoo
2022-08-29 14:21     ` Vlastimil Babka
2022-08-29 15:37       ` 回复: " pgd pte
2022-08-30  5:51       ` Christophe Leroy [this message]
2022-08-30 13:13         ` Vlastimil Babka
2022-08-29  3:18 ` Hyeonggon Yoo

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=f02b862f-8e8c-0ec9-7b83-c9e26831c242@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=set_pte_at@outlook.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).