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=-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_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 7C12EC47096 for ; Sun, 6 Jun 2021 11:08:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 217A76102A for ; Sun, 6 Jun 2021 11:08:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 217A76102A 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 5384E6B006C; Sun, 6 Jun 2021 07:08:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E8636B006E; Sun, 6 Jun 2021 07:08:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3645C6B0070; Sun, 6 Jun 2021 07:08:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0174.hostedemail.com [216.40.44.174]) by kanga.kvack.org (Postfix) with ESMTP id F35FD6B006C for ; Sun, 6 Jun 2021 07:08:45 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 756DE181AC9C6 for ; Sun, 6 Jun 2021 11:08:45 +0000 (UTC) X-FDA: 78223026210.06.97F546F Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf26.hostedemail.com (Postfix) with ESMTP id 481FF41AD7A4 for ; Sun, 6 Jun 2021 11:08:44 +0000 (UTC) Received: by mail-pg1-f181.google.com with SMTP id n12so11545409pgs.13 for ; Sun, 06 Jun 2021 04:08:44 -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:references:mime-version :content-disposition:in-reply-to; bh=fOKV/PEX0Gbw5hGJdD2E4quyHQ+st/wNQyTDQnLhadQ=; b=FDPfpb8anTwsBK6TNvqz/TzgArvFQsP4u8RMK0D3oQ5cxnPVaUYMRhg4hZhfI5+EVe WDr5Ionxph2ml8tHTtPUOyA8B9r+QhEjLWz+NJXOO8isH3PMk8CJtaPTXUbELCN5ow4G tvcWl0571524WVZ/iYRE5bqv+jwtPgyggZHdmBdBe/Mkt0javw64M0kDICHrkdY9NPrH i/AnCqpPqHv3MHIq11nByNDiq7Qu2TbsKqinG/q7GtmbirAEuiJhxX2qg8+G/wSHCi7+ ei4cTFI+j6OIfPniImLJN5LNd8Ocd2FbhAWAjT8mh2Yn556ha6LGLO3gYViwloF2TnCN gy+g== 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:references :mime-version:content-disposition:in-reply-to; bh=fOKV/PEX0Gbw5hGJdD2E4quyHQ+st/wNQyTDQnLhadQ=; b=MxEj/OBMfKOHWUDMCkioWsH+IloHQgn0BL/rhlAJMWFH/A0SnlyKjCMSYUsw6b/NPm LRryx4xGi/Ewgt7t/QPGHJTVZVfisEfhHgzf5ewnB4Vuj27kT9WRrGJro/Xx0kjThFLy TwBvvGSjS87VITkD7JlFqyQSHqLf7z5OJdOu1To6bAB7QMhX90DVomQOeVif0OC3JZAm Lz0vmljbIkB9oXw37pelfJMNUu+hMA5lGqougttCeg5E99PTkc15k9Y81MrQNxkeut8t fT1Uub4UITNSoEYPABe4HcJNWT9g75g9OHL9VkSSjr8SiKD2RP1AEPwv6oHpWQsM9fBA i9Sg== X-Gm-Message-State: AOAM5333dMyJTOHHzIPCmWxddhwCkvqTnXZZ/4k+BwfNQKRZuXig5IGg Nb0HshhxI9ntC8VoIk4Y+2Y= X-Google-Smtp-Source: ABdhPJzL5FZKLysm9FvGdS5P1fJddzj6wMN6DUUXXQ753TI9y/UJL7QG5v8I4zfBaxy44CAPu2TiRQ== X-Received: by 2002:a62:ab16:0:b029:2ed:8599:7df8 with SMTP id p22-20020a62ab160000b02902ed85997df8mr5187954pff.31.1622977724140; Sun, 06 Jun 2021 04:08:44 -0700 (PDT) Received: from hyeyoo ([175.203.199.208]) by smtp.gmail.com with ESMTPSA id n72sm5729110pfd.8.2021.06.06.04.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Jun 2021 04:08:43 -0700 (PDT) Date: Sun, 6 Jun 2021 20:08:39 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: kernel test robot Cc: kbuild-all@lists.01.org, Linux Memory Management List , Vlastimil Babka , Andrew Morton 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: <20210606110839.GA13828@hyeyoo> References: <202106051442.G1VJubTz-lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202106051442.G1VJubTz-lkp@intel.com> Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=FDPfpb8a; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 42hyeyoo@gmail.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=42hyeyoo@gmail.com X-Stat-Signature: f5a7frfkskfroo9hqz5ezqu4dmz95knd X-Rspamd-Queue-Id: 481FF41AD7A4 X-Rspamd-Server: rspam02 X-HE-Tag: 1622977724-941243 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 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-next.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=1 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-next.git/commit/?id=a7ba988ff9de37f0961b4bf96d17aca73d0d2e25 > 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=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=parisc > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > > 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/linux/bpf.h:1319:9: > >> include/linux/compiler_types.h:328:38: error: call to '__compiletime_assert_183' declared with attribute error: unexpected size in kmalloc_index() > 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 'compiletime_assert' > 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), 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()"); > | ^~~~~~~~~~~~~~~~ Reproduce with attached config, and read the code. It has no problem in clang (clang-10/clang-11). it is problem with gcc. I found two ways to solve the error (maybe there would be better solution) Any thoughts or opinions? First ways is to change condition of kmalloc_index macro. 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 complain */ return -1; } -#define kmalloc_index(s) __kmalloc_index(s, true) +#define kmalloc_index(s) __kmalloc_index(s, __builtin_constant_p(s) && true) #endif /* !CONFIG_SLOB */ void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment __malloc; Second way is making bpf_map_kmalloc_node always inline. 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 flags, int node) { From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============5375948603636780177==" MIME-Version: 1.0 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: kbuild-all@lists.01.org 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() Date: Sun, 06 Jun 2021 20:08:39 +0900 Message-ID: <20210606110839.GA13828@hyeyoo> In-Reply-To: <202106051442.G1VJubTz-lkp@intel.com> List-Id: --===============5375948603636780177== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-next.g= it master > head: ccc252d2e818f6a479441119ad453c3ce7c7c461 > commit: a7ba988ff9de37f0961b4bf96d17aca73d0d2e25 [7012/7430] mm, slub: ch= ange 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/sbi= n/make.cross -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next= .git/commit/?id=3Da7ba988ff9de37f0961b4bf96d17aca73d0d2e25 > git remote add linux-next https://git.kernel.org/pub/scm/linux/ke= rnel/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.cros= s ARCH=3Dparisc = > = > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > = > 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/linux= /bpf.h:1319:9: > >> include/linux/compiler_types.h:328:38: error: call to '__compiletime_a= ssert_183' declared with attribute error: unexpected size in kmalloc_index() > 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 '_co= mpiletime_assert' > 328 | _compiletime_assert(condition, msg, __compiletime_assert_, __= COUNTER__) > | ^~~~~~~~~~~~~~~~~~~ > include/linux/build_bug.h:39:37: note: in expansion of macro 'compilet= ime_assert' > 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond)= , 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()"); > | ^~~~~~~~~~~~~~~~ Reproduce with attached config, and read the code. It has no problem in clang (clang-10/clang-11). it is problem with gcc. I found two ways to solve the error (maybe there would be better solution) Any thoughts or opinions? First ways is to change condition of kmalloc_index macro. 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(siz= e_t size, /* Will never be reached. Needed because the compiler may complain = */ return -1; } -#define kmalloc_index(s) __kmalloc_index(s, true) +#define kmalloc_index(s) __kmalloc_index(s, __builtin_constant_p(s) && tru= e) #endif /* !CONFIG_SLOB */ = void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment __mal= loc; Second way is making bpf_map_kmalloc_node always inline. 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 flags, int node) { --===============5375948603636780177==--