Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5474721imw; Wed, 20 Jul 2022 06:30:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vt9QXpIVWYvV8GrJ671Gu8vk8alEyCuJwc8qBFGyTbwRRsLIAaCK/XBzU8xLBgrjTCDIy9 X-Received: by 2002:a17:906:8a5a:b0:72b:6b60:2d9f with SMTP id gx26-20020a1709068a5a00b0072b6b602d9fmr35958989ejc.324.1658323849866; Wed, 20 Jul 2022 06:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658323849; cv=none; d=google.com; s=arc-20160816; b=fyLxqZU/q3QE/Zh8Exgf072agEh3HRnYTaOy5zFOJ2klxDH4Lyr75yYTZdKXUAgm1G ++yYzD9MU7/Wxqo4709QKjvUO0QY6N/df1yfCPSLua8wQL4Q+Zw8HHbDnzvsfJOronXE e8o14+sBiQ1qaW6q8DVpLGVXl22O9sr++dIG5bVxs/gwKGsQtL3wFB4Wa0Izmw5HRd1m 4uHi9p/isr4/5La954vczkCgYaLuu/egC+PG24pi0jP9b1OENnwQaNgRVSQMymKskeKa f8rEb/KlIVm0sSdp/vJ50BBmb8WXdDA+OtREpToZQKEw6HrbXynnCJPqB33cYMS9m6Hl hX0w== 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=4YEYTRkXjMubA23ljwAbKPOW3yS5St5DwJ9Hkx+01sE=; b=IcLJ0nSV8d064r8qwf2KQm6wN9W/hqh6dn3okBctX6NKJBR+07Xn1pAWMrErjI7iU9 uX8FdDwRjbc0gvBfqhJXKUjbj6aLHwYMbEVrKjdthCnTli3X+yKFTVznILcwGnfmC24U fXgq8eUGGYTgRIjcu7G5VjRZS0xGbOwzQtqxWqOJ09si/X7rFF1nUMvCq4nJNS86hrJT lqn/ZZHkn5Rq9Csi6q3nSd+V+Qu3NMIAHi4SQoBwoCO4USB4+z0qZaJlzj0oFbmImyNS PysaJheetm+qo85I6vkkoH/I2QT1CViwUAH6mn+wlz7Bt5vdDqGgybwKGlV5VnEmzSQQ e28w== 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 o8-20020a170906974800b0072a9ec4c1fdsi27709101ejy.594.2022.07.20.06.30.23; Wed, 20 Jul 2022 06:30:49 -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 S240297AbiGTM4V (ORCPT + 99 others); Wed, 20 Jul 2022 08:56:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237447AbiGTM4H (ORCPT ); Wed, 20 Jul 2022 08:56:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6AD5C3F31A; Wed, 20 Jul 2022 05:56:06 -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 B593615DB; Wed, 20 Jul 2022 05:56:06 -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 8FBD63F70D; Wed, 20 Jul 2022 05:56:04 -0700 (PDT) From: Sudeep Holla To: Sudeep Holla , "Rafael J. Wysocki" , Greg Kroah-Hartman Cc: Dietmar Eggemann , Pierre Gondois , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Guenter Roeck , linux-acpi@vger.kernel.org, Conor Dooley , linux-kernel@vger.kernel.org, Geert Uytterhoeven , Ionela Voinescu Subject: [PATCH v3 3/3] arch_topology: Fix cache attributes detection in the CPU hotplug path Date: Wed, 20 Jul 2022 13:55:40 +0100 Message-Id: <20220720-arch_topo_fixes-v3-3-43d696288e84@arm.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220720-arch_topo_fixes-v3-0-43d696288e84@arm.com> References: <20220720-arch_topo_fixes-v3-0-43d696288e84@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Conor Dooley Reviewed-by: Ionela Voinescu Tested-by: Geert Uytterhoeven Tested-by: Ionela Voinescu Signed-off-by: Sudeep Holla 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 -- b4 0.10.0-dev-54fef