Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2183194lqe; Tue, 9 Apr 2024 11:50:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUby2edduc+t7f65mca4L0feU/x6MWpJDVmgO9DyRrr+TdPOzP0ttXFd2hKG2KZgolQTlQz5YQzAkv9IIKEPQMFFkL6kseOFERsojjjtw== X-Google-Smtp-Source: AGHT+IHEOVswV4p/6urSf9eigC50Aguy1fJswXefzBqgbzR2mNcaJBXsua4CFAkh7JjThM6lpNEE X-Received: by 2002:a05:6870:d690:b0:22e:de2d:8c00 with SMTP id z16-20020a056870d69000b0022ede2d8c00mr534577oap.24.1712688657855; Tue, 09 Apr 2024 11:50:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712688657; cv=pass; d=google.com; s=arc-20160816; b=BfktJQqzQsSzv2MPbsT1TIMz1ZkLFljz5hx8dSuWuEUqUhxTepCi/njS6pkHxc9P7O sY47NH4zGnJmfMTYN2PrdnZk70GbZTyUlUxBtPp9Ua6KEpLFnMuY6uGA4TCBnfkpKUuo EQN1jf8VovJ9UsPPBNGSseUwn1tc03EeWzZrTziMhHYCII3B9tn9LjTJkcWDvM+DSdbx yVee2+rw4mb/sSxf9WLH6jB5iXvrxjNX9cFx2ahwJJ/uhEiSt3qsrpMc2vuxLqpJ/0BJ u8l7D/A0XkDD8huiyrovK0/AwDgdsT502knQ88zDNZt8guGQc01/s+KwTiE7l+KaVvBr LvvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=6Cu5vQbjipd5Vvr76hI29Xx0XGiWclQL0xGVyvl/nvc=; fh=TB4O3bwf3dM997EgWg8zk9D8GxT+eyM/q/wmvrrEO8c=; b=S3GjgSSfKiWjj2PiiDyUVB/16Mpg29Bw9rkQ0DSLxVQ3kgW8AaniG/mSk9E9ZJ6Hv9 KJZQ1IYMKWZeU5WM9v/7HlMKzFVk7IpVNWNZUcZUKCB9P7kM3uesiCLz5MPhmDDEf1rz r5UAjzEIQbjPLCqYJMIHyLqWaag7pyRPJ95n61HMwIAkj6lWYerSWJT09C6LCoDXBQ5a Y2N4uK74jPgZJh75cK0cNP9eIIuDw/vXykZ+IJFsHYLBpGJgnf6JESALB4lMP0HihZY8 vzuE/Jm8ldg+Ju/734aYLhl3w9aEtEZGYtA6ZZ7xoJbhVkYYTZKqqwK81jVZ1GrDm8AF /iqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ancud.ru); spf=pass (google.com: domain of linux-kernel+bounces-137482-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137482-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i190-20020a636dc7000000b005dc957fe128si9023162pgc.74.2024.04.09.11.50.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 11:50:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137482-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ancud.ru); spf=pass (google.com: domain of linux-kernel+bounces-137482-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137482-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EF60A284764 for ; Tue, 9 Apr 2024 18:50:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AE2A156F39; Tue, 9 Apr 2024 18:50:51 +0000 (UTC) Received: from relay162.nicmail.ru (relay162.nicmail.ru [91.189.117.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21639156F2D for ; Tue, 9 Apr 2024 18:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.189.117.6 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712688651; cv=none; b=AjfqJa4KlXELu/KSytT6xZeBdRONRUjeLM0sAMCwd9gRY/lDOD595w4jBytw19xLzMByMffKOYUY/h/RpY04t5uceECkWyqPkwV3n9y6jy1QmnIfC7US80Xk2xiIeV3Ip1eMa343bpRPzWBAi5BqeaLOPA+n/E4YYJkOpofh4Ds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712688651; c=relaxed/simple; bh=7mpDaExakoQ07v+dHggo5nRAbVx93Whw/EtsFEU4P3c=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=AaoA/Kmrbr6iXhHAunR0pw5vaEbAqcFAd4QdqGBKgV6zkKLxHsELB8nP2iXD0ir7m2hLLGQeIlGvxTuKyc0mJzPErDIAyFrWMotmWBH3L1aM3I9yyK91yB7OAlB0D91p20WQUznhFYUjohbQTeCtMf8KIR/I8nmMxfAoc1ATfuk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru; spf=pass smtp.mailfrom=ancud.ru; arc=none smtp.client-ip=91.189.117.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ancud.ru Received: from [10.28.136.255] (port=5328 helo=mitx-gfx..) by relay.hosting.mail.nic.ru with esmtp (Exim 5.55) (envelope-from ) id 1ruGEe-00014w-9e; Tue, 09 Apr 2024 21:30:21 +0300 Received: from [87.245.155.195] (account kiryushin@ancud.ru HELO mitx-gfx..) by incarp1105.mail.hosting.nic.ru (Exim 5.55) with id 1ruGEe-007wXR-2s; Tue, 09 Apr 2024 21:30:20 +0300 From: Nikita Kiryushin To: Thomas Gleixner Cc: Nikita Kiryushin , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Ashok Raj , David Woodhouse , linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] x86/smpboot: Add map vars allocation check in smp_prepare_cpus_common Date: Tue, 9 Apr 2024 21:29:39 +0300 Message-Id: <20240409182940.664482-1-kiryushin@ancud.ru> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MS-Exchange-Organization-SCL: -1 As of now, zalloc_cpumask_var for various maps in smp_prepare_cpus_common is not checked. If allocation fails, it will not be known, unless the not-allocated map will be accessed. The situation seems not very realistic now, but could get more relevant in the future, as number of cores (and amount of allocated resources) grows. Add a cumulative status for all zalloc_cpumask_var() calls in smp_prepare_cpus_common() and error message in case the status signals that any of the map var allocations failed (per cpu). Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Nikita Kiryushin --- arch/x86/kernel/smpboot.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 76bb65045c64..3b24c2e1fa3b 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1042,11 +1042,16 @@ void __init smp_prepare_cpus_common(void) } for_each_possible_cpu(i) { - zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); - zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); - zalloc_cpumask_var(&per_cpu(cpu_die_map, i), GFP_KERNEL); - zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL); - zalloc_cpumask_var(&per_cpu(cpu_l2c_shared_map, i), GFP_KERNEL); + bool ret = true; + + ret &= zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL); + ret &= zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL); + ret &= zalloc_cpumask_var(&per_cpu(cpu_die_map, i), GFP_KERNEL); + ret &= zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL); + ret &= zalloc_cpumask_var(&per_cpu(cpu_l2c_shared_map, i), GFP_KERNEL); + + if (!ret) + pr_err("Failed to allocate map for CPU%u\n", i); } set_cpu_sibling_map(0); -- 2.34.1