Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1856834rwb; Fri, 19 Aug 2022 10:31:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mcJkIs4+5sJfXyroKMgY1mHJ4KZKgw54apmEEEWcTRb9UsujUijH+GbstapnEKRNNYQy2 X-Received: by 2002:a17:90b:4a92:b0:1f7:2ee5:a2ed with SMTP id lp18-20020a17090b4a9200b001f72ee5a2edmr14950200pjb.127.1660930290838; Fri, 19 Aug 2022 10:31:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930290; cv=none; d=google.com; s=arc-20160816; b=Sn9cBI2UROhUBMj40pDWGisugnfG0UUpSixpxMTZ45HwSSA1gspw3a+c87wYEoGqGI L+yH8fVbWw+YI+F1pzHqHIm6wisFpjQH7EwHMvOwnMWdlpudP+g6sN4i0xwe5ugDghl0 TXVugFcKBKPsRXuTBA7DxosPWhLNJUefQGF4azRGKkLGfgfltAfmDhXrCaGql0CGRxnX YW4FVrKg2W2wdb43+yStbhIINnnJyCBE3eZdrbwFfezLfOy/vrr34VPRXiyGNPBvO7Og q3XVw//YqczZy3SJn1d2L9f2/3wHroNrYKRN+nPxrHzRfdpZ5lGwD+6yJezGU9jn03Fo gXZA== 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=kB4RBw2qOM/e0Ioo4+1TQ57gxjv7bvXF2pGrtzdU1gk=; b=LAwxfNttAThLfhLsOpBeqLJnRo08OwntvUjq3l1YyhRCg2qBzv3+IAY6DFZbmuwpQN mW1kBf89L+1zAMHdCAKLFSi1QPMDJvAGKEixJQyMPTTbbvP1qWFLjjHi6Y/lNdC2ame4 cXgQKc9JDvAyj9TcKHH/ldpDBNvAyUN043b1YhU5DSquuzTF7JcycUlqcWL+3gdS5cMr f0vI7sKlUXN7ja6Dltz8gEYlFG+HdsQUzDU8np2Ufc8lTSU1nHCQQuYR3OxL2EoY0WYZ DCFK85a4HS8NHF3Tx0oXFebyaCrjSfD8n5AX0FBhmSGgmPTr9Px83i+kZ38l+iLOlAwq gtHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pKTZCeqY; 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 i13-20020a63130d000000b003fea0415b5asi4393820pgl.834.2022.08.19.10.31.19; Fri, 19 Aug 2022 10:31:30 -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=pKTZCeqY; 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 S1353452AbiHSQkN (ORCPT + 99 others); Fri, 19 Aug 2022 12:40:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353368AbiHSQjZ (ORCPT ); Fri, 19 Aug 2022 12:39:25 -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 98BC49109E; Fri, 19 Aug 2022 09:08:18 -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 27050614DA; Fri, 19 Aug 2022 16:07:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DDC2C433C1; Fri, 19 Aug 2022 16:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925249; bh=fw9i8RhpOoj2gMS4VBjk+TrGpw1xeKcJG7ORRDyhstA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pKTZCeqYKL9PCZRiGqLG/i9SVut/pBxuoDQY19pfr1X4u6lAkwJiXGjv8E1XgUkAl e1glqmszu/fzqCiaAlXDRUernvl1Mjwm8Ml0hRbCxc5e4xT83C4lgxIPTScRDKFRwc zoKA5s8jyT5KDj6coD5cGAd9Y1rnJQSqtRlxlmIc= 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.10 431/545] x86/numa: Use cpumask_available instead of hardcoded NULL check Date: Fri, 19 Aug 2022 17:43:21 +0200 Message-Id: <20220819153848.703712858@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 e94da744386f..9dc31996c7ed 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -861,7 +861,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; @@ -907,7 +907,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