Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1139990pxb; Wed, 16 Feb 2022 11:56:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnanQ4X30oemfCTDhZIcHplHM6AQZSiJOZj/NbiUkG7FxD/cGRabYRdglK/tF5olxRxcNA X-Received: by 2002:a50:9d08:0:b0:410:1013:f3b2 with SMTP id v8-20020a509d08000000b004101013f3b2mr4765494ede.13.1645041380605; Wed, 16 Feb 2022 11:56:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645041380; cv=none; d=google.com; s=arc-20160816; b=0phqxhlu3WIrDa8PSHCQ4XlnbF/ZxgRYkmXp3EoT3uuhVWj8LzcAtA227RqPcAfDj2 eF8mj385P8GM/HJc8idKbRGPUAS4BwErLS38+ljnIioT4VEKQhwhRkQOtCWbQDLsxUqA wWMRxjkpoLL2gJ+Rbr+y3UYfiC0xdReHJfsRT9lGXAFga0ktRqSqt37V+eSwz/TZzGvq 9gRLE1wm8z7HFw1kCBz3p2RKfVJErCCl8Vlv6n0rElQqobTEJDqfs3zn7G5TKFgBHkGQ 9pqJPrteiX76UFwdzeI80ANXUxd9uWvJ3X1TOftl2aSKJWqXwPygW4F/Gex7tChjnbRg EblA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dBcA9H79ww8nB0EMKBmkpVT8vLJuenThpNOWG/mJ3Aw=; b=nVf1396XptyeEvOPN7sU9xJRh0qOKmHHqvo1I+aq7DemyfaJsJdKHhk7JyaZOTIOZZ cuH8fu97rCo/4srvrIpG3xE6gVlJ94McdoFDj5ouDf89Mkpe+LDU4n+MH6Vbk0nemS6K snUpDMTXdgA/lXu5/HnpRdAFXMZCw264vLUZn+h0nxYwxpR3nMnmkHO/hxjnwZaKc4qX VNZAWDHjANwW/++geEtQ5jdBgypEZoEYuu4yWqwaEDb6HaOa8M/z4wU/pdZ7w+5rcig5 vKBJTrzhPgGkDZo++Zhf+uT3HJ//XHGla39EdFhfPascmWFuLVqEMpbfLIW68BzHHSXg rXuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oj5fpci1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eq17si2412989edb.52.2022.02.16.11.55.57; Wed, 16 Feb 2022 11:56:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oj5fpci1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235764AbiBPPvT (ORCPT + 99 others); Wed, 16 Feb 2022 10:51:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235769AbiBPPvL (ORCPT ); Wed, 16 Feb 2022 10:51:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 521952A82E2 for ; Wed, 16 Feb 2022 07:50:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E236761A5C for ; Wed, 16 Feb 2022 15:50:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE471C004E1; Wed, 16 Feb 2022 15:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645026655; bh=SFNdUdbviVuwsH4h90rOML9Z996F328RaBfL4P8s3dM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oj5fpci1jHz1H55wQp76gOIJCXMFRUFI3BjWhaSX82iHKgncmP6hA1UUjEUoWqeYI 3Ab9eS1RHRzahzf3lCXWT2D6Dq66/gtrVdFac+2RpOmnUEu2A4A8mdyuv1rJ/3DM/L 1eGThY/89DyIfpV3MtlDe5RxlCpgfnNPbGVpTwamRd7eoq5itZFNcREkDfmCSQvc8B dv5Ra3sfarVvztyXI9UUU0NHTE3ziM3eyxfjJ9gzXrIgtSyNxuXWN6pTdXHDF1vGY6 UbVAjuSyqeUXjU44QFQBbJyBzDTzyb74dA3t6p6qgEfdpZzoQxfa/1g7o9UjLwlt2x ZMOchAVzzvaAw== Date: Wed, 16 Feb 2022 08:50:51 -0700 From: Nathan Chancellor To: Sebastian Andrzej Siewior Cc: Andrew Morton , Peter Zijlstra , Nick Desaulniers , linux-mm@kvack.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, "kernelci.org bot" Subject: Re: [PATCH] mm/page_alloc: Mark pagesets as __maybe_unused Message-ID: References: <20220215184322.440969-1-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 16, 2022 at 09:00:09AM +0100, Sebastian Andrzej Siewior wrote: > On 2022-02-15 11:43:22 [-0700], Nathan Chancellor wrote: > > Commit 9983a9d577db ("locking/local_lock: Make the empty local_lock_*() > > function a macro.") in the -tip tree converted the local_lock_*() > > functions into macros, which causes a warning with clang with > > CONFIG_PREEMPT_RT=n + CONFIG_DEBUG_LOCK_ALLOC=n: > > > > mm/page_alloc.c:131:40: error: variable 'pagesets' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] > > static DEFINE_PER_CPU(struct pagesets, pagesets) = { > > ^ > > 1 error generated. > > > > Prior to that change, clang was not able to tell that pagesets was > > unused in this configuration because it does not perform cross function > > analysis in the frontend. After that change, it sees that the macros > > just do a typecheck on the lock member of pagesets, which is evaluated > > at compile time (so the variable is technically "used"), meaning the > > variable is not needed in the final assembly, as the warning states. > > > > Mark the variable as __maybe_unused to make it clear to clang that this > > is expected in this configuration so there is no more warning. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1593 > > Reported-by: "kernelci.org bot" > > Suggested-by: Nick Desaulniers > > Signed-off-by: Nathan Chancellor > > --- > > mm/page_alloc.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 7ff1efc84205..406f5d0c610f 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -128,7 +128,7 @@ static DEFINE_MUTEX(pcp_batch_high_lock); > > struct pagesets { > > local_lock_t lock; > > }; > > -static DEFINE_PER_CPU(struct pagesets, pagesets) = { > > +static DEFINE_PER_CPU(struct pagesets, pagesets) __maybe_unused = { > > No, I need to think of something else then for the local_lock thing. I > haven't seen it with gcc. There is probably more than just this one. As far as I am aware, this is a clang only warning. From my brief audit of uses of local_lock_t, I believe this is the only one that will trigger this warning because every other structure that has a local_lock_t also has another member that is unconditionally used, meaning an instance of that structure will not just be used at compile time. In this case, 'struct pagesets' ONLY contains a local_lock_t, which is only used at compile time in this configuration, hence the warning. Of course, if you can think of something that works for your use case and doesn't make clang warn, that would be ideal but I don't see this patch as the worst solution. I'll run through my full set of builds tonight and see if there are any other instances of this warning; this particular instance was visible in several defconfigs so I fixed it first. Cheers, Nathan