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 0D85AC3DA41 for ; Thu, 11 Jul 2024 13:56:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B8576B009F; Thu, 11 Jul 2024 09:56:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 841536B00A0; Thu, 11 Jul 2024 09:56:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E3066B00A1; Thu, 11 Jul 2024 09:56:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4CE0E6B009F for ; Thu, 11 Jul 2024 09:56:16 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C09C0140659 for ; Thu, 11 Jul 2024 13:56:15 +0000 (UTC) X-FDA: 82327621110.02.F2BF07C Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) by imf09.hostedemail.com (Postfix) with ESMTP id 0DE6114002B for ; Thu, 11 Jul 2024 13:56:12 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=EiLnsSMq; spf=pass (imf09.hostedemail.com: domain of surenb@google.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720706139; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MFTrnAbyX8vf3QQjlC5h5C0zllrIIeWFeKDzU5Qbf8s=; b=cZMdYaC2AzXJAAjmhYvdyEOSYsucAUcj3z2F4wmwnubMxxyM/wFhteqa/SKcqnrq40PDKj 9AhpsPefDZLoX/jbI1diK704Qyk7mvwrfypOthe9KtWl7qMscA27Ht7gpKoQnw943VNtMK 9y7DJt28fFYhl2/Z2icAkts5TDUNHaA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720706139; a=rsa-sha256; cv=none; b=8Etdhnj/hkCElAxOoSVrvrvuLRf2p59YQB3FQxFSQlzieuac0Af8HJp1+NU949CfIpd0RJ YVno3Qcw6Sh52cb8wbUlDUdZKqIX2FgKZZXnt02FWWQu7Cj+mQs4+06c+ZGMbiSonCN6fL a80PB9W7vU+tGSil8LTPvImo0kf8Qn8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=EiLnsSMq; spf=pass (imf09.hostedemail.com: domain of surenb@google.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-e03c689addcso837953276.0 for ; Thu, 11 Jul 2024 06:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720706172; x=1721310972; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MFTrnAbyX8vf3QQjlC5h5C0zllrIIeWFeKDzU5Qbf8s=; b=EiLnsSMqVAAwfKa4FX5/fAPUohc3wfLupMUcuVXkJDSifJfRl/55GuGWd16UazGRqA 8RraigFfYOFgOsW4SK88fCqfFbtnCWfNO1ExlFjWybFnCXQtxtRk9/RNZfSQWewr6Yhp Lha+QToWGURhleKzpt7t01axvZsAN7f3LkFu3j9H5QzkA2qDyS903nP2uo2tGcmG71+T C8nCdZbkmb1GTIC1FkhKizHuko4qCpDieJW+o2h31wGCg8j3MS5I4zDGTJBocow/7eYi vVILFxBflBAH76Fv9hsRd5C0+v+cWxs4PbU/4P3y7Rdd1jeOwaxXndSyFsR7V9T5fET7 ljSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720706172; x=1721310972; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MFTrnAbyX8vf3QQjlC5h5C0zllrIIeWFeKDzU5Qbf8s=; b=khqvMc7MpQRgyeddTBM5h0DZ3Z7T2gHWfIRU26/9xbOCc/WTdLoaqc8lG9gjYt3EKt EhlOBXcvDZjMvytQfNX41UCi7dzJtLLAAVZDeFw8aP8AKxBni81X85Qvp1Yw8YlrMojo UokDY6ena1SlBNyRp864JasRz0f/sBlGB9um1nj+YCBQRPk8eebvvjSEMIuKvdoUxo3o DhOKwhkAtFNmODKr3xahQFIyFQVNV1ZI6qtaQlAAAay8/RCPmpz2U0Nm11pDXuruM3aZ lZ0BeCRwgVfL2+TANAxkIqk+8qF4dJwS1mDSvU3E6CFLqcR45q/JzGkXt+a9p3xew6dO 6IJQ== X-Forwarded-Encrypted: i=1; AJvYcCXBCTv6iEBr6WmLskhtetDnJC8kUgRhFbda0FG7hjq90y5WKWAF21nF8N4l1h+VdXNUx80+8RV7jl7ng+jg+Tg08lc= X-Gm-Message-State: AOJu0Yzcge97Z1e5JwFPNnhVsTr2YLse1BrfTvijDB917QerFe4uibFV r9M1QMP8luRczoyXQcZa6flIBmihl75IUqqXIH7fD0z9ayEtqHbJvQJqBUQYr+gsnyHCEFv7DeH dHJDFwBeO806kXn+D9spVyzpzy9ux7tgDWrky X-Google-Smtp-Source: AGHT+IEzi2i3Lqz/5TdUvZHvPNb77C6MfS8NebUNLgPcBjgz6y6o+pM85oFGLgCJRIc8PuJgLqURHYqx/2OM1Q5xKhU= X-Received: by 2002:a25:b2a1:0:b0:e02:8ab0:c940 with SMTP id 3f1490d57ef6-e041b1e9795mr9335860276.47.1720706171781; Thu, 11 Jul 2024 06:56:11 -0700 (PDT) MIME-Version: 1.0 References: <20240710025418.394321-1-sxwjean@me.com> <20240710150154.GA1684801@thelio-3990X> <4b533d6c-b2f3-49eb-a7fb-807af482def8@suse.cz> In-Reply-To: <4b533d6c-b2f3-49eb-a7fb-807af482def8@suse.cz> From: Suren Baghdasaryan Date: Thu, 11 Jul 2024 06:56:00 -0700 Message-ID: Subject: Re: [PATCH] mm/slub: quiet the clang warning with -Wunused-function enabled To: Vlastimil Babka Cc: Nathan Chancellor , Matthew Wilcox , sxwjean@me.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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: tof1hzicsct5x4ncj8psrgq5c9x1bhm9 X-Rspamd-Queue-Id: 0DE6114002B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1720706172-383988 X-HE-Meta: U2FsdGVkX18G/R6lK/Dvn+X3BOkxcVu/6j6IMdWPGyfJgbDK7k6iagKmRb1K8ZOFhC20gCKehd5UaXpYUUq9ppixnjFZVeugN9+M2qeJ1IvR75xnBhgSZXq2hp5LB9Lc3E5KJQ2W2vik2kn1CtDSvTEspnDEwkHO2u+qfUUdNeGzqdSHrytNpE93KnYmqBzZoTAO37qTw9eR04IQEqpZsvoi4iIYc2nfB3JoD3OhChVS6eZUi1ytI62JIB7nVsLdtHNHtt9XT6WW5Jbdmkta0KnyEi2giYMCk4z1MecbZDAIwv/lCi+EH2+ZK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1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Jul 11, 2024 at 12:43=E2=80=AFAM Vlastimil Babka w= rote: > > On 7/10/24 11:40 PM, Suren Baghdasaryan wrote: > > On Wed, Jul 10, 2024 at 8:02=E2=80=AFAM Nathan Chancellor wrote: > >> > >> 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_unus= ed" > >> > > 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 functi= ons in .c > >> files, not .h files. The kernel already handles this in > >> include/linux/compiler_types.h but it disables this workaround for W= =3D1 to catch > >> unused functions like this as a result of commit 6863f5643dd7 ("kbuild= : allow > >> Clang to find unused static inline functions for W=3D1 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=3D1 build. This will allow clang to find unused functions. Re= move the > >> * __inline_maybe_unused entirely after fixing most of -Wunused-functi= on 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 usef= ul (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 th= e only > >> options I see. > > > > I think this is the consequence of the recent refactoring I've done in > > https://lore.kernel.org/all/20240704135941.1145038-1-surenb@google.com/= . > > There should be a cleaner way to fix this. I'll post it later today or > > tomorrow morning. > > Yeah looks like the non-empty prepare_slab_obj_exts_hook() could move to = the > #ifdef CONFIG_MEM_ALLOC_PROFILING section above > alloc_tagging_slab_alloc_hook() and the empty one just removed. Exactly my plan. I'll post a patch once I reach the office. > > > Thanks, > > Suren. > > > >> > >> > > Reported-by: kernel test robot > >> > > Closes: https://lore.kernel.org/oe-kbuild-all/202407050845.zNONqau= D-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, voi= d *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, voi= d *p) > >> > > { > >> > > return NULL; > >> > > -- > >> > > 2.34.1 > >> > > > >> > > >