From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 B381EC433ED for ; Tue, 18 May 2021 09:28:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 500AA6135C for ; Tue, 18 May 2021 09:28:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 500AA6135C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D679B8E001E; Tue, 18 May 2021 05:28:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D16FF8D0001; Tue, 18 May 2021 05:28:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDF7C8E001E; Tue, 18 May 2021 05:28:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id 8CA8A8D0001 for ; Tue, 18 May 2021 05:28:21 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 29A28180AD838 for ; Tue, 18 May 2021 09:28:21 +0000 (UTC) X-FDA: 78153826002.36.D17CD28 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf25.hostedemail.com (Postfix) with ESMTP id 2C83D6000107 for ; Tue, 18 May 2021 09:28:18 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 60CE4AE8D; Tue, 18 May 2021 09:28:19 +0000 (UTC) Subject: Re: [PATCH v3] mm, slub: change run-time assertion in kmalloc_index() to compile-time To: Nathan Chancellor , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: akpm@linux-foundation.org, iamjoonsoo.kim@lge.com, rientjes@google.com, penberg@kernel.org, cl@linux.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, naresh.kamboju@linaro.org, clang-built-linux@googlegroups.com, linux-next@vger.kernel.org, ndesaulniers@google.com, lkft-triage@lists.linaro.org, sfr@canb.auug.org.au, arnd@arndb.de, Marco Elver References: <20210511173448.GA54466@hyeyoo> <20210515210950.GA52841@hyeyoo> <41c65455-a35b-3ad3-54f9-49ca7105bfa9@suse.cz> <20210518003859.GC80297@hyeyoo> From: Vlastimil Babka Message-ID: <71416382-2e4c-5e03-df9c-265fda41c2de@suse.cz> Date: Tue, 18 May 2021 11:28:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf25.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2C83D6000107 X-Stat-Signature: k55w4bmspomrpdyopcgun9gde5jpt5oy X-HE-Tag: 1621330098-195695 Content-Transfer-Encoding: quoted-printable 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: On 5/18/21 2:43 AM, Nathan Chancellor wrote: > On 5/17/2021 5:38 PM, Hyeonggon Yoo wrote: >> On Sat, May 15, 2021 at 11:34:49PM -0700, Nathan Chancellor wrote: >>> This should work I think: >> >> compiled well with clang-10.0.1, clang-11.0.0, >> and gcc-10.2.0 with x86_64 default config. >> >> is the condition CONFIG_CLANG_VERSION > 110000, >> not including 110000 it self? Good spot. > Ah sorry, that should definitely be >=3D :( >=20 > That is what I get for writing an email that late... in reality, it pro= bably > won't matter due to the availability of 11.0.1 and 11.1.0 but it should > absolutely be changed. >=20 > I have not given Nick's patch a go yet but would something like this be > acceptable? Yes. > If so, did you want me to send a formal fixup patch or did you want > to send a v4? I have no personal preference. At this point a fixup is the usual way. Andrew might squash it to the ori= ginal patch (also with Marco's fixup) before sending to Linus. >>> diff --git a/include/linux/slab.h b/include/linux/slab.h >>> index 9d316aac0aba..1b653266f2aa 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, >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (size <=3D=C2=A0 16 * 1024 * 1024) = return 24; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (size <=3D=C2=A0 32 * 1024 * 1024) = return 25; >>> =C2=A0 -=C2=A0=C2=A0=C2=A0 if (size_is_constant) >>> +=C2=A0=C2=A0=C2=A0 if ((IS_ENABLED(CONFIG_CC_IS_GCC) || CONFIG_CLANG= _VERSION > 110000) && >>> size_is_constant) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BUILD_BUG_ON_M= SG(1, "unexpected size in kmalloc_index()"); >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 BUG(); >=20