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=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,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 CA9EBC47082 for ; Mon, 7 Jun 2021 11:40:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B34E61205 for ; Mon, 7 Jun 2021 11:40:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B34E61205 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 D182F6B006C; Mon, 7 Jun 2021 07:40:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC8236B006E; Mon, 7 Jun 2021 07:40:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACC6B6B0070; Mon, 7 Jun 2021 07:40:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id 74DD26B006C for ; Mon, 7 Jun 2021 07:40:06 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 75401181AC9CB for ; Mon, 7 Jun 2021 11:40:04 +0000 (UTC) X-FDA: 78226733928.10.5919679 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf05.hostedemail.com (Postfix) with ESMTP id 2A8E5E000272 for ; Mon, 7 Jun 2021 11:40:01 +0000 (UTC) Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 67A851FDC5; Mon, 7 Jun 2021 11:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623066002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NJ0cUZWn+ARocuag/PCbEw+Dw7bLetfHVUZDa80MF44=; b=LE96KJhFvt4BzhM0xjxWK2+JOE9xGlHME56lui9k/cvgbVOev85XDdkBk1VH2HWyksmnrd YgBE5BSscbbcGzjfbUd2qhGT0vL3x4bNEailzi/BASz3tO7nnIL6j/xRN8eDLEqBfH+Ulu uejxTu9xH3MLqmFDWX7FHMYnhB5eR0g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623066002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NJ0cUZWn+ARocuag/PCbEw+Dw7bLetfHVUZDa80MF44=; b=LY54xrQDfye/AWcaipetku8uKYHIPurPner5ZZfoVgYuTF3JjxfgfqsAIsPSLPdjlqw89Q AWxyZN3zThx7IVCQ== Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 48CB5118DD; Mon, 7 Jun 2021 11:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1623066002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NJ0cUZWn+ARocuag/PCbEw+Dw7bLetfHVUZDa80MF44=; b=LE96KJhFvt4BzhM0xjxWK2+JOE9xGlHME56lui9k/cvgbVOev85XDdkBk1VH2HWyksmnrd YgBE5BSscbbcGzjfbUd2qhGT0vL3x4bNEailzi/BASz3tO7nnIL6j/xRN8eDLEqBfH+Ulu uejxTu9xH3MLqmFDWX7FHMYnhB5eR0g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1623066002; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NJ0cUZWn+ARocuag/PCbEw+Dw7bLetfHVUZDa80MF44=; b=LY54xrQDfye/AWcaipetku8uKYHIPurPner5ZZfoVgYuTF3JjxfgfqsAIsPSLPdjlqw89Q AWxyZN3zThx7IVCQ== Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id CvYLEZIFvmDbXgAALh3uQQ (envelope-from ); Mon, 07 Jun 2021 11:40:02 +0000 To: Hyeonggon Yoo <42.hyeyoo@gmail.com>, kernel test robot Cc: kbuild-all@lists.01.org, Linux Memory Management List , Andrew Morton References: <202106051442.G1VJubTz-lkp@intel.com> <20210606110839.GA13828@hyeyoo> From: Vlastimil Babka Subject: Re: [linux-next:master 7012/7430] include/linux/compiler_types.h:328:38: error: call to '__compiletime_assert_183' declared with attribute error: unexpected size in kmalloc_index() Message-ID: Date: Mon, 7 Jun 2021 13:40:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <20210606110839.GA13828@hyeyoo> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=LE96KJhF; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LY54xrQD; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=LE96KJhF; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LY54xrQD; dmarc=none; spf=pass (imf05.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Stat-Signature: t1c9n7h7m7epr9hdgghsyw7byf6zupj8 X-Rspamd-Queue-Id: 2A8E5E000272 X-Rspamd-Server: rspam02 X-HE-Tag: 1623066001-866636 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 6/6/21 1:08 PM, Hyeonggon Yoo wrote: > On Sat, Jun 05, 2021 at 02:10:46PM +0800, kernel test robot wrote: >> tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-nex= t.git master >> head: ccc252d2e818f6a479441119ad453c3ce7c7c461 >> commit: a7ba988ff9de37f0961b4bf96d17aca73d0d2e25 [7012/7430] mm, slub:= change run-time assertion in kmalloc_index() to compile-time >> config: parisc-randconfig-r014-20210604 (attached as .config) >> compiler: hppa-linux-gcc (GCC) 9.3.0 >> reproduce (this is a W=3D1 build): >> wget https://raw.githubusercontent.com/intel/lkp-tests/master/= sbin/make.cross -O ~/bin/make.cross >> chmod +x ~/bin/make.cross >> # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-n= ext.git/commit/?id=3Da7ba988ff9de37f0961b4bf96d17aca73d0d2e25 >> git remote add linux-next https://git.kernel.org/pub/scm/linux= /kernel/git/next/linux-next.git >> git fetch --no-tags linux-next master >> git checkout a7ba988ff9de37f0961b4bf96d17aca73d0d2e25 >> # save the attached .config to linux build tree >> COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dgcc-9.3.0 make.c= ross ARCH=3Dparisc=20 >>=20 >> If you fix the issue, kindly add following tag as appropriate >> Reported-by: kernel test robot >>=20 >> All errors (new ones prefixed by >>): >> In file included from : >> In function 'kmalloc_index', >> inlined from 'kmalloc_node' at include/linux/slab.h:572:20, >> inlined from 'bpf_map_kmalloc_node.isra.0.part.0' at include/li= nux/bpf.h:1319:9: >> >> include/linux/compiler_types.h:328:38: error: call to '__compiletim= e_assert_183' declared with attribute error: unexpected size in kmalloc_i= ndex() >> 328 | _compiletime_assert(condition, msg, __compiletime_assert_,= __COUNTER__) >> | ^ >> include/linux/compiler_types.h:309:4: note: in definition of macro = '__compiletime_assert' >> 309 | prefix ## suffix(); \ >> | ^~~~~~ >> include/linux/compiler_types.h:328:2: note: in expansion of macro '= _compiletime_assert' >> 328 | _compiletime_assert(condition, msg, __compiletime_assert_,= __COUNTER__) >> | ^~~~~~~~~~~~~~~~~~~ >> include/linux/build_bug.h:39:37: note: in expansion of macro 'compi= letime_assert' >> 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(co= nd), msg) >> | ^~~~~~~~~~~~~~~~~~ >> include/linux/slab.h:389:2: note: in expansion of macro 'BUILD_BUG_= ON_MSG' >> 389 | BUILD_BUG_ON_MSG(1, "unexpected size in kmalloc_index()"); >> | ^~~~~~~~~~~~~~~~ >=20 > Reproduce with attached config, and read the code. > It has no problem in clang (clang-10/clang-11). it is problem with gcc. But what exactly is the gcc problem here? Did you have to reproduce it with specific gcc version and/or architectur= e? > I found two ways to solve the error (maybe there would be better > solution) Any thoughts or opinions? >=20 >=20 > First ways is to change condition of kmalloc_index macro. >=20 > diff --git a/include/linux/slab.h b/include/linux/slab.h > index 70e46db766ca..be2c900cba4b 100644 > --- a/include/linux/slab.h > +++ b/include/linux/slab.h > @@ -397,7 +397,7 @@ static __always_inline unsigned int __kmalloc_index= (size_t size, > /* Will never be reached. Needed because the compiler may compl= ain */ > return -1; > } > -#define kmalloc_index(s) __kmalloc_index(s, true) > +#define kmalloc_index(s) __kmalloc_index(s, __builtin_constant_p(s) &&= true) I wonder how this extra guard can possibly matter? bpf_map_kmalloc_node() kmalloc_node() if (__builtin_constant_p(size) ...) unsigned int i =3D kmalloc_index(size); We shouldn't be even reaching kmalloc_index() unless __builtin_constant_p= (size) is already true. > #endif /* !CONFIG_SLOB */ > =20 > void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment _= _malloc; >=20 >=20 > Second way is making bpf_map_kmalloc_node always inline. If bpf_map_kmalloc_node() is not being compiled as inline, how can it pos= sibly evaluate __builtin_constant_p(size) as true when processing the inlined kmalloc_node()? > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > index 02b02cb29ce2..09379d705349 100644 > --- a/include/linux/bpf.h > +++ b/include/linux/bpf.h > @@ -1312,7 +1312,7 @@ void *bpf_map_kzalloc(const struct bpf_map *map, = size_t size, gfp_t flags); > void __percpu *bpf_map_alloc_percpu(const struct bpf_map *map, size_t = size, > size_t align, gfp_t flags); > #else > -static inline void * > +static __always_inline void * > bpf_map_kmalloc_node(const struct bpf_map *map, size_t size, gfp_t fla= gs, > int node) > { >=20