Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2869209rwb; Mon, 15 Aug 2022 13:00:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR4wrwb9B3L2+xHzxAQAmwpnUWGFXSZ1PusP/nLgjqF/RsKBzjj4p7hjE5xN8blvRVIDi/Dc X-Received: by 2002:a05:6402:358a:b0:43d:aa71:3033 with SMTP id y10-20020a056402358a00b0043daa713033mr15853011edc.248.1660593605419; Mon, 15 Aug 2022 13:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660593605; cv=none; d=google.com; s=arc-20160816; b=Scta/kGlHNvQZj2XhO3W/Dnkhg/0mGBG0bFc7wLQCrHiIucF3WT/u+JOND0Xel3a9E YSGXJDGem4KAf99aKoDK8UzLvhWhc12V+0FgUFIASjjO4oHojxImUQE7PJDmTTuwzy1K 6TZg1DE6MKm/GICetIf5QRTRxmeF648h9kklnWLrLqSPskNG//nbWdWPqmGD5iFRpRiK zjvXNrSUbO63O9n7q0AM1giW3niGMGgHxr2mElmt8cxruSwm1iBo1KfZ2SIz2WMicabU xVQkN0o0pBBixN92eUJ+SSAB3E3FPdBsRq76Q75xKWFGlBEvyB0p/+hr+dNy/Q+97WUj uDJw== 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=NVgqb28HHZSRflIpkIdQVcgRDcxZdYfNg+fUo3Cgr/U=; b=quf4jKJ3FOdLBZPJg2sYmCUIIvWUbppycW5A84ZebSk3X5dJM9S+0w4YN0GbwXatpC dCUsjZlirGzUvfdvcZpugKqeG+U4QRRZt1IJonB0FDO9pkC5LZuhrHqmvz0QBxZOec0f YBvVh6LR4x5e4o5Chp0bfihGh8tDYCiE/Fo1pnbHdD/0ynl5aDLpVm1qwpsuNSKgWKiW RCKxeIXgQlQq1l0+BkatyagCPoJ64aK2CsHdva+ywmhtlxGnzearlgKsyqXQVMCZXTY/ 42KzBuXfqjfx7EJyE3kDAY82ctmzTSq3AmqbDJj6uRJBAHc1jBXoIgBh8aPGf+fvelWp Cbeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0nmDmKoG; 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 ds1-20020a170907724100b00731148bc546si9702800ejc.38.2022.08.15.12.59.34; Mon, 15 Aug 2022 13:00:05 -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=0nmDmKoG; 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 S1344756AbiHOTof (ORCPT + 99 others); Mon, 15 Aug 2022 15:44:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344703AbiHOTlY (ORCPT ); Mon, 15 Aug 2022 15:41:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498FC65836; Mon, 15 Aug 2022 11:47:29 -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 ams.source.kernel.org (Postfix) with ESMTPS id BAF80B810A0; Mon, 15 Aug 2022 18:47:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02B6BC433D6; Mon, 15 Aug 2022 18:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589246; bh=Gpq+I7u/RwPSeuzvhjXCYNqP5aQ3HsWjVO9K27J+oxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0nmDmKoGWHyYqpRsQnTKMlLkZNcDUJXnt1KfRAxkAnknH/EPR8I6bMpN7A40fwyeb F/AOo0Tff1Z6rYjH67MX58NO7LZ+kPVhx4f2uuK/DTMKTL+AXUf7cMRlN2fMN1skty xmU4+gSf8lBpv9aSQ6DpXjNQl0tekxfhrK41NRoo= 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.15 657/779] x86/numa: Use cpumask_available instead of hardcoded NULL check Date: Mon, 15 Aug 2022 20:05:01 +0200 Message-Id: <20220815180405.454442467@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 1e9b93b088db..e360c6892a58 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -860,7 +860,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; @@ -906,7 +906,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