linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	 David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	 Nathan Chancellor <nathan@kernel.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	 Linux Memory Management List <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	 clang-built-linux <clang-built-linux@googlegroups.com>,
	 Naresh Kamboju <naresh.kamboju@linaro.org>
Subject: Re: [PATCH] mm, slub: Fix support for clang 10
Date: Tue, 18 May 2021 13:30:05 -0700	[thread overview]
Message-ID: <CAKwvOdk+BZjNeGNjW3a0_yRoGhonP0=Jr6C7=KxWQphkU_dRkA@mail.gmail.com> (raw)
In-Reply-To: <20210518181247.GA10062@hyeyoo>

On Tue, May 18, 2021 at 11:12 AM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote:
>
> Previously in 'commit ff3daafe3fd3 ("mm, slub: change run-time assertion
> in kmalloc_index() to compile-time")', changed kmalloc_index's run-time
> assertion to compile-time assertion.
>
> But clang 10 has a bug misevaluating __builtin_constant_p() as true,
> making it unable to compile. This bug was fixed in clang 11.
>
> To support clang 10, introduce a macro to do run-time assertion if clang
> version is less than 11, even if the size is constant. Might revert this
> commit later if we choose not to support clang 10.
>
> Fixes: ff3daafe3fd3 ("mm, slub: change run-time assertion in kmalloc_index() to compile-time")
> Link: https://lore.kernel.org/r/CA+G9fYvYxqVhUTkertjZjcrUq8LWPnO7qC==Wum3gYCwWF9D6Q@mail.gmail.com/
> Link: https://lkml.org/lkml/2021/5/11/872
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Suggested-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>

Thanks for the patch; hopefully this isn't too much burden in order to
help us support clang-10 a little bit longer.  We will rip it out when
dropping clang-10 someday; grepping for CLANG_VERSION should turn this
up easily.

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  include/linux/slab.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 9d316aac0aba..8d8dd8571261 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -413,7 +413,7 @@ static __always_inline unsigned int __kmalloc_index(size_t size,
>         if (size <=  16 * 1024 * 1024) return 24;
>         if (size <=  32 * 1024 * 1024) return 25;
>
> -       if (size_is_constant)
> +       if ((IS_ENABLED(CONFIG_CC_IS_GCC) || CONFIG_CLANG_VERSION >= 110000) && size_is_constant)
>                 BUILD_BUG_ON_MSG(1, "unexpected size in kmalloc_index()");
>         else
>                 BUG();
> --
> 2.25.1
>


-- 
Thanks,
~Nick Desaulniers


      parent reply	other threads:[~2021-05-18 20:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 18:12 Hyeonggon Yoo
2021-05-18 18:16 ` Hyeonggon Yoo
2021-05-18 18:21   ` Hyeonggon Yoo
2021-05-18 20:30 ` Nick Desaulniers [this message]

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='CAKwvOdk+BZjNeGNjW3a0_yRoGhonP0=Jr6C7=KxWQphkU_dRkA@mail.gmail.com' \
    --to=ndesaulniers@google.com \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naresh.kamboju@linaro.org \
    --cc=nathan@kernel.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=sfr@canb.auug.org.au \
    --cc=vbabka@suse.cz \
    /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