Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp327866imw; Fri, 15 Jul 2022 04:11:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tPmFQxOuliAYILzRJE5lKy4n3rnE43vZi77xYVMnM9qemY8B8VncSu/AyXASDSoM728XvH X-Received: by 2002:a05:6402:1d54:b0:43b:1795:d3c with SMTP id dz20-20020a0564021d5400b0043b17950d3cmr13812581edb.236.1657883506780; Fri, 15 Jul 2022 04:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657883506; cv=none; d=google.com; s=arc-20160816; b=d6i8LSXVctHuhQKZFT0Zc6mCLWYdTHTqgDTAxQ99AyqL3PqadxDWbiYJXsKzCjhvQd qYIebVAfI6gATLO932W6hA+FaUav/1xSuRDtl6PXkgW5yhmfr8xUesXTg+nDn/u1N5Is og0TheNFzsxPTySW6pxOGCZ4R6DcYePWXseEJZKz+qsGqJTnKdw63AqefW8E2AWa0RtI I5g04gtjaEeAnqI08qBhFR2jQ7m2N5SwoFMs71Qzh0Dzforrkub7Sn3FmN+pRnnYjX+0 vIDpvOgLfs6KbxB4AsWZS1Rg2ASEwPHdoPLJRoRbt437WAeleIXCdL6mnfWQinZbk54o uszQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Vkl94lPCoulyE/6B9+bMi0nbXpCssxeq3qXZGloCqsw=; b=oyqw6OJnPwQfnKLUSo6WxijYFR0uO1Excs0ONQJ+wHFnv2yZ4jhJAGHxIKIkM4+Zb7 GVymEb/Qqv5ryNFnbAclYnFO3/lop9NxLSWFcAivzjnbalZz5nGfn4y0b7jFHjvStMdV hjkyxySRkWE6snUYuCnqcu7/Z+oyTB4IIrdFMOcEWwi7MeYJQ79RLMnRlV4dqrmdsYI8 fE7IRQvJUdEiiMEEIIraDLg7XA1d7UsbOzM5VFHwD2h35NChsozptBKLrmafMcc5cBLM 2VE6YQW2QnpKOjL9kXjDUxRFxHd74HkGczQPRjMD45beSxpm20+qyyk0m3z2WF0bYCNM naKw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n19-20020a1709061d1300b00709521d4b92si3849380ejh.397.2022.07.15.04.11.21; Fri, 15 Jul 2022 04:11:46 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233196AbiGOK0Z (ORCPT + 99 others); Fri, 15 Jul 2022 06:26:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232538AbiGOK0W (ORCPT ); Fri, 15 Jul 2022 06:26:22 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A1BFA796A6 for ; Fri, 15 Jul 2022 03:26:21 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DB4281D13; Fri, 15 Jul 2022 03:26:21 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1E0403F792; Fri, 15 Jul 2022 03:26:20 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Conor Dooley Cc: Sudeep Holla , Vincent Guittot , Dietmar Eggemann , Ionela Voinescu , Pierre Gondois , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org Subject: [PATCH -next v2 2/2] arch_topology: Fix cache attributes detection in the CPU hotplug path Date: Fri, 15 Jul 2022 11:26:09 +0100 Message-Id: <20220715102609.2160689-2-sudeep.holla@arm.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220715102609.2160689-1-sudeep.holla@arm.com> References: <20220715102609.2160689-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE 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 init_cpu_topology() is called only once at the boot and all the cache attributes are detected early for all the possible CPUs. However when the CPUs are hotplugged out, the cacheinfo gets removed. While the attributes are added back when the CPUs are hotplugged back in as part of CPU hotplug state machine, it ends up called quite late after the update_siblings_masks() are called in the secondary_start_kernel() resulting in wrong llc_sibling_masks. Move the call to detect_cache_attributes() inside update_siblings_masks() to ensure the cacheinfo is updated before the LLC sibling masks are updated. This will fix the incorrect LLC sibling masks generated when the CPUs are hotplugged out and hotplugged back in again. Reported-by: Ionela Voinescu Tested-by: Ionela Voinescu Reviewed-by: Conor Dooley Reviewed-by: Ionela Voinescu Signed-off-by: Sudeep Holla --- drivers/base/arch_topology.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) v1->v2: - No change in this patch, but 1/2 was added to fix possible bug "sleeping in the atomic context" with this patch. - Added all the received tags diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 441e14ac33a4..0424b59b695e 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -732,7 +732,11 @@ const struct cpumask *cpu_clustergroup_mask(int cpu) void update_siblings_masks(unsigned int cpuid) { struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; - int cpu; + int cpu, ret; + + ret = detect_cache_attributes(cpuid); + if (ret) + pr_info("Early cacheinfo failed, ret = %d\n", ret); /* update core and thread sibling masks */ for_each_online_cpu(cpu) { @@ -821,7 +825,7 @@ __weak int __init parse_acpi_topology(void) #if defined(CONFIG_ARM64) || defined(CONFIG_RISCV) void __init init_cpu_topology(void) { - int ret, cpu; + int ret; reset_cpu_topology(); ret = parse_acpi_topology(); @@ -836,13 +840,5 @@ void __init init_cpu_topology(void) reset_cpu_topology(); return; } - - for_each_possible_cpu(cpu) { - ret = detect_cache_attributes(cpu); - if (ret) { - pr_info("Early cacheinfo failed, ret = %d\n", ret); - break; - } - } } #endif -- 2.37.1