Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3261010rwb; Mon, 15 Aug 2022 22:35:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR7v/R1QsZwBAyx3+/X46CzZ4knx0pieiOKAuFm6BJHV+OuZ20LFDPl/7wvD8lNsZdyiuse3 X-Received: by 2002:a63:e011:0:b0:41c:506f:cf04 with SMTP id e17-20020a63e011000000b0041c506fcf04mr16405871pgh.120.1660628145852; Mon, 15 Aug 2022 22:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660628145; cv=none; d=google.com; s=arc-20160816; b=1HHcn1iu0T+LX2UkPGT8NAEeJGpcRZKDUe4yPwqlV6/S682tLLZHgaB5g1yHGD1lqM N+KSVQlnRy8qwxWeGY6C9UympKmB9FSBgnZ47fm3si3CuPkRZYV3fPzx33VgJBWSkAbI 9d6OJ0w5Jpy9G5p5Mbcw7KRLjfhobF7JzU8X/bgj81ZCWcqzTZQfcZLSGW2dFeNX1kvZ 8OPLw8tEh1f+8CbgjCUUx/iudAPgLqq06UAMbVcRKfgKOwzZ7+4SAtRur5omjnrnxjHI xYT0AFIV+NHpCisTBX6LbcquiC1BoHel6FbpCUfvo6EvBfynnUdKJlq78haWsZjz6RBs RCpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yfjIPamV3nV8aUyX2Ej1uduXC6E10eLsBwdc4JN4Mc4=; b=0ZTOcg03dEzDpjWugijKgRfiFOI0fxDhSVR4vcduOVFL1D0rni7BELm1ZIktLF4zii AoIGY3QTDey4F/58h+GDdOPSMCSGRt3/3vPBxXzfDImvnesZ80um/Pw39OrBxyWaoWRV yO/BpyMd7sBt8zkJBSaaSXEGASDfBuKIDvf5Z+VbPTAj+aEAInJ8waBNCkkOoeOhUZEh WRhtSsI1sBNLKADgU1NZLsedGGk1IDYIXOL5wGY1CBRdFLMVJsb60iALw06KfY58noIE TGk0rEaK4D3UTrIrFlVIV0+kILaQjoEfFulva2FLqzVGIsGMUl3Cdt9amGnbaZHncf0l Xcsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CEMCQsyr; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 66-20020a630245000000b0041bf0a54ad0si12959744pgc.729.2022.08.15.22.35.35; Mon, 15 Aug 2022 22:35:45 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=CEMCQsyr; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232690AbiHPErw (ORCPT + 99 others); Tue, 16 Aug 2022 00:47:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232424AbiHPEpc (ORCPT ); Tue, 16 Aug 2022 00:45:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38C08D8046; Mon, 15 Aug 2022 13:44:17 -0700 (PDT) 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 51E08611E2; Mon, 15 Aug 2022 20:44:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 428C5C433D6; Mon, 15 Aug 2022 20:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596255; bh=i0Q7KMBwpnuSbMDsMG/RH6Tk1dLZHV3lTCNdlvGU9MU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CEMCQsyr1YQASUK4uf5yLIPnyhQTV7uG5L6tXXN5jTAPbzPT4ZF/1cCvOOBj9/Def gifdquUbjjMm0lFn+BCC455g8iv2767y42s48leVgzmfIayDUv9YqeqynN29g2udqT d71Aq4KWMDCj4nvcmGi/vKu6pDdWJHtpLPOQvg1k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Siddh Raman Pant , Ingo Molnar , Sasha Levin Subject: [PATCH 5.19 1022/1157] x86/numa: Use cpumask_available instead of hardcoded NULL check Date: Mon, 15 Aug 2022 20:06:18 +0200 Message-Id: <20220815180520.796744383@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 From: Siddh Raman Pant [ Upstream commit 625395c4a0f4775e0fe00f616888d2e6c1ba49db ] GCC-12 started triggering a new warning: arch/x86/mm/numa.c: In function ‘cpumask_of_node’: arch/x86/mm/numa.c:916:39: warning: the comparison will always evaluate as ‘false’ for the address of ‘node_to_cpumask_map’ will never be NULL [-Waddress] 916 | if (node_to_cpumask_map[node] == NULL) { | ^~ node_to_cpumask_map is of type cpumask_var_t[]. When CONFIG_CPUMASK_OFFSTACK is set, cpumask_var_t is typedef'd to a pointer for dynamic allocation, else to an array of one element. The "wicked game" can be checked on line 700 of include/linux/cpumask.h. The original code in debug_cpumask_set_cpu() and cpumask_of_node() were probably written by the original authors with CONFIG_CPUMASK_OFFSTACK=y (i.e. dynamic allocation) in mind, checking if the cpumask was available via a direct NULL check. When CONFIG_CPUMASK_OFFSTACK is not set, GCC gives the above warning while compiling the kernel. Fix that by using cpumask_available(), which does the NULL check when CONFIG_CPUMASK_OFFSTACK is set, otherwise returns true. Use it wherever such checks are made. Conditional definitions of cpumask_available() can be found along with the definition of cpumask_var_t. Check the cpumask.h reference mentioned above. Fixes: c032ef60d1aa ("cpumask: convert node_to_cpumask_map[] to cpumask_var_t") Fixes: de2d9445f162 ("x86: Unify node_to_cpumask_map handling between 32 and 64bit") Signed-off-by: Siddh Raman Pant Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20220731160913.632092-1-code@siddh.me Signed-off-by: Sasha Levin --- arch/x86/mm/numa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index e8b061557887..2aadb2019b4f 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -867,7 +867,7 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable) return; } mask = node_to_cpumask_map[node]; - if (!mask) { + if (!cpumask_available(mask)) { pr_err("node_to_cpumask_map[%i] NULL\n", node); dump_stack(); return; @@ -913,7 +913,7 @@ const struct cpumask *cpumask_of_node(int node) dump_stack(); return cpu_none_mask; } - if (node_to_cpumask_map[node] == NULL) { + if (!cpumask_available(node_to_cpumask_map[node])) { printk(KERN_WARNING "cpumask_of_node(%d): no node_to_cpumask_map!\n", node); -- 2.35.1