From patchwork Tue May 18 18:12:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 12265423 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBD50C433B4 for ; Tue, 18 May 2021 18:12:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4349A61006 for ; Tue, 18 May 2021 18:12:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4349A61006 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C50BB6B0155; Tue, 18 May 2021 14:12:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD9708E002F; Tue, 18 May 2021 14:12:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7A586B0158; Tue, 18 May 2021 14:12:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id 72BF36B0155 for ; Tue, 18 May 2021 14:12:56 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 119D18249980 for ; Tue, 18 May 2021 18:12:56 +0000 (UTC) X-FDA: 78155147952.16.1360A97 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf15.hostedemail.com (Postfix) with ESMTP id 05E8AA0001A4 for ; Tue, 18 May 2021 18:12:53 +0000 (UTC) Received: by mail-pg1-f176.google.com with SMTP id f22so6641331pgb.9 for ; Tue, 18 May 2021 11:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=9UF6JPc9kDNTRCs7ffieF/jBad0EDQKUws2Yd0IxgKo=; b=mF2+K3rbAZ0Yt5/HqP3OFrc/Xx54XHooQYogRvZoEYAimzTp2eOmKQ3T5njQWNfslm SIJvM9kv40LnTXqBoEg4OnbhyxlzQOZEHXyqyZ3kt9RpvMX3tMxgwpanZrsuczEI+s/m 7mHCnVs+2eOPFnA43kYZsY5dbADtuu8NXTcpd1JJkTOC0QsqpuU0nCIaPJv0M/eWJySf rL/wNW2G6JnQmlN1zIdfZZZ+2ZHa4FuZeLFlOuPY5s2zxCpxTimFfuUF14PYILkRgZA7 JUUEZgTeJWWZjZaLo+ESU/ec2+W07oX7+9Wytj++jA9y6t6QRmD0EU7wF/iYnmCXQvGh qLqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=9UF6JPc9kDNTRCs7ffieF/jBad0EDQKUws2Yd0IxgKo=; b=HOi/lDFo6EngfjxXupB60j0SJkgnrlOy5e+aeM/Qh75/38LADU6RoQcsiXoJaEwBDZ 9fBboMjZDlUOG9de6x/FE3hpFCZiZgZDYP8y1zWqAgBOx+0bXCiXCTYdNzlX+Yv0YOUU i+ctzoysfKUSPNtOo6XF5q3pZCLKhsqHCDtxDkz4/XsyKxTXctdVUT8cjlTkccK9+PmB 2PSqEd4aweoZto8OeUoQK4cc5crTM9DkxRI4GgrkdMOfL9+AEI1uL1x9sdFS9klJ6VVB QbW2xy4ppLqUqIyxxkT4o+SPwvlaNhi6l0GOIaH3vP9jHLNMSZZ3hFrSe7F/xZ4kHpCk eaLw== X-Gm-Message-State: AOAM533ebQDO1c+0fJk1ufy8+dhnuVp1tS1AKAp33A/G29GiW9yrhheg 2fuXxMk6mF2P8OVi3ChG8mA= X-Google-Smtp-Source: ABdhPJxlIMg35Y34lyvIH7pG1V8clcjDW70mvdmqgCHA/6d/t4M75yoaEILr9aNOKOIYkc6qb8B5Zg== X-Received: by 2002:a63:4145:: with SMTP id o66mr6395237pga.4.1621361574683; Tue, 18 May 2021 11:12:54 -0700 (PDT) Received: from hyeyoo ([183.99.11.150]) by smtp.gmail.com with ESMTPSA id gz18sm2463721pjb.19.2021.05.18.11.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 11:12:54 -0700 (PDT) Date: Wed, 19 May 2021 03:12:47 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Nathan Chancellor , Nick Desaulniers , Stephen Rothwell Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Naresh Kamboju Subject: [PATCH] mm, slub: Fix support for clang 10 Message-ID: <20210518181247.GA10062@hyeyoo> MIME-Version: 1.0 Content-Disposition: inline X-Rspamd-Queue-Id: 05E8AA0001A4 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=mF2+K3rb; spf=pass (imf15.hostedemail.com: domain of 42hyeyoo@gmail.com designates 209.85.215.176 as permitted sender) smtp.mailfrom=42hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: thxp4qxakh9qeigqpk7xegjr1e6fsiid X-HE-Tag: 1621361573-39090 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Suggested-by: Nathan Chancellor Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Nick Desaulniers --- 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();