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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CB61C3DA41 for ; Wed, 10 Jul 2024 15:02:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1A3F6B00A2; Wed, 10 Jul 2024 11:02:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC9716B00A4; Wed, 10 Jul 2024 11:02:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 992396B00A7; Wed, 10 Jul 2024 11:02:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7A66C6B00A2 for ; Wed, 10 Jul 2024 11:02:05 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2D9EE1A0187 for ; Wed, 10 Jul 2024 15:02:05 +0000 (UTC) X-FDA: 82324158210.28.0BC8BD2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id 24E82140044 for ; Wed, 10 Jul 2024 15:01:58 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nkjc4JAM; spf=pass (imf26.hostedemail.com: domain of nathan@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720623703; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=f7pTpvIAoqN0VfxNg0cl5xu/MpYnB3bJ1QPw2L/PmEE=; b=0R2jXVNaxSLSdkNod+ThnMyLGQzRmUZuDmk9fRYw0FTrtAfMRtsMVn/N0J+0FDZk+Py8L2 Xpquf8zVLhYtKwbj2eslYZftlYzPanttT9qHZlznM4vpxLjqUfr0gUCMLFWPwAIynzIKkl NsuZnUholG2vYUbljtjLZD58ko6qw3g= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nkjc4JAM; spf=pass (imf26.hostedemail.com: domain of nathan@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720623703; a=rsa-sha256; cv=none; b=dIZIIr31Vp6s4F8y5+ty+2c8SK2JzAzCXU5XvY2vIPMYTBPlkFS+I49yXDnqiq/RTY6eLT ttuAdLo2G46OZbJ9qT1I/5VO9+D/LNrQ1Kv2g3PpcWizQ2GAdh9C06O0uKdnN74qH+MgSl P4xA7Xcv8AXtQKB4SbMdvEqPG3p4jv8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DE77161A90; Wed, 10 Jul 2024 15:01:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A002CC32781; Wed, 10 Jul 2024 15:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720623717; bh=9GpPEqrxGU8rpTktXRrEpW0O4vhd27+dwvUB6phuEy4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nkjc4JAMA17eXOiiHeFs87S3AMp9M+/UjmcPP/IGhNbVqoL+QNTUja2xZSgqr0uF4 udATUrC2e25rsvJD8PahWekPC4oFMy7KTwATCCqG/vdHnD3qV55QACdY00Qqimxa3W vpVlAXZhElyxPDjnr0OLufSue09fpVgsnA5MBiMfJSsmt17I5PIWzkp9Vncslc5bBU K6LM2/24AMX9Ry6/EvkkUb9XXm0dxWjpbhkVmYnDD335SBGRZuOp/tdX3HZwhc+CYR 8VSPqDudePAd3V0Wd8II1OdeW08maHc6wPceaSIGFUZHDW/nR+5xSXvTsvkDu38qow sat8AmF00dEkA== Date: Wed, 10 Jul 2024 08:01:54 -0700 From: Nathan Chancellor To: Matthew Wilcox Cc: sxwjean@me.com, vbabka@suse.cz, surenb@google.com, cl@linux.co, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, xiongwei.song@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel test robot , llvm@lists.linux.dev, Nick Desaulniers Subject: Re: [PATCH] mm/slub: quiet the clang warning with -Wunused-function enabled Message-ID: <20240710150154.GA1684801@thelio-3990X> References: <20240710025418.394321-1-sxwjean@me.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 24E82140044 X-Stat-Signature: a4fxfz36s54ijmpdrz7wahd1fepc58kp X-Rspam-User: X-HE-Tag: 1720623718-876340 X-HE-Meta: U2FsdGVkX18JjISFey6Fvn6LFp+0GXblc6egKc54FmqJAxkmDAI6jhkWlTngmWMf8axtB/DFpI1klMW/C13iR3dUIlXrr8y+eSUITxAUPGkRdkkz/oyB2nXcTI/nabGmq+ssl58MnZJQJXChequFdKauc5bRhGew0EYVjJs76qz2wX0qoKU46JLyqBZlkfQNcfhUQf4OYTVP5bOSSzxoPUClM+LpLYhge95iiorzQlEj7RDaW2uKIzpNsoZcH2EBhPdrWbPJNgTph1/xQBLw39ifwj5toinEFDDUrQC6qDBtDLjW4YEXYDBRKGiR98/mjs3otC8ciDj5wSjodd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lE4jt/0qU1S9k8vGa+4YDUa14uMcmL 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: List-Subscribe: List-Unsubscribe: On Wed, Jul 10, 2024 at 04:03:33AM +0100, Matthew Wilcox wrote: > On Wed, Jul 10, 2024 at 10:54:18AM +0800, sxwjean@me.com wrote: > > From: Xiongwei Song > > > > The only user of prepare_slab_obj_exts_hook() is > > alloc_tagging_slab_alloc_hook(), which can build with > > CONFIG_MEM_ALLOC_PROFILING enabled. So, the warning was triggerred > > when disabling CONFIG_MEM_ALLOC_PROFILING. Let's add "__maybe_unused" > > for prepare_slab_obj_exts_hook(). > > Perhaps instead clang can be fixed to match gcc's behaviour? Clang only differs from GCC on warning for unused static inline functions in .c files, not .h files. The kernel already handles this in include/linux/compiler_types.h but it disables this workaround for W=1 to catch unused functions like this as a result of commit 6863f5643dd7 ("kbuild: allow Clang to find unused static inline functions for W=1 build"): /* * GCC does not warn about unused static inline functions for -Wunused-function. * Suppress the warning in clang as well by using __maybe_unused, but enable it * for W=1 build. This will allow clang to find unused functions. Remove the * __inline_maybe_unused entirely after fixing most of -Wunused-function warnings. */ #ifdef KBUILD_EXTRA_WARN1 #define __inline_maybe_unused #else #define __inline_maybe_unused __maybe_unused #endif So I don't really think there is much for clang to do here and I think having the ability to find unused static inline functions in .c files is useful (you might disagree, perhaps a revert could still be discussed). I guess IS_ENABLED() can't be used there, so it seems like either taking this patch, ignoring the warning, or refactoring the code in some other way are the only options I see. > > Reported-by: kernel test robot > > Closes: https://lore.kernel.org/oe-kbuild-all/202407050845.zNONqauD-lkp@intel.com/ > > Signed-off-by: Xiongwei Song > > --- > > mm/slub.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/mm/slub.c b/mm/slub.c > > index ce39544acf7c..2e26f20759c0 100644 > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -2027,7 +2027,7 @@ static inline bool need_slab_obj_ext(void) > > return false; > > } > > > > -static inline struct slabobj_ext * > > +static inline struct slabobj_ext * __maybe_unused > > prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p) > > { > > struct slab *slab; > > @@ -2068,7 +2068,7 @@ static inline bool need_slab_obj_ext(void) > > return false; > > } > > > > -static inline struct slabobj_ext * > > +static inline struct slabobj_ext * __maybe_unused > > prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p) > > { > > return NULL; > > -- > > 2.34.1 > > > >