Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7353896rwi; Mon, 24 Oct 2022 13:25:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7kTNTjbBlZhc+FEJH8SSBYLlc03TjKRqqGK+7Syz2H+eR4GDw1niOB76wrOPvhrvXih0Sl X-Received: by 2002:a17:907:75d4:b0:78d:efa7:f78c with SMTP id jl20-20020a17090775d400b0078defa7f78cmr28597015ejc.454.1666643144529; Mon, 24 Oct 2022 13:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643144; cv=none; d=google.com; s=arc-20160816; b=BzLU0uN8y7vttJ+Af1H2suLJaN7Nrep8IVEa/lqTLffhhLpLtlWphCyUTzE237mOxM 65IvmdVr6szz6Ks7owiOUsCTQGSKtkwykkwIVVzSN/9gfM4SV1h/9o3VA4G1xRdYM1T3 ilnQN18YjnD383TJz8gHR5/QXrl8ncwh2jS0VVQbiIbPwCrMtczC5Enkoxleua84K2dl 66ce1eT3dpexnFN/JLxfTqidYMDNPcbDjMH/8+RIfjkV2NMrkL60qOAxLQo0sJ1Cqf4o FtPQOqTqqcla6euuK48zvRGANgp5VzVY9aldFPxo2Ju85WMetTgwtq2PU/guQ0L1038d xwYg== 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=1P1bdxDqKY5Xca1mdo3iW9D/5/zRoL9TptH4zb0Anjg=; b=meUtfvFFly2U2bqlHOs4/HOT9clYhOryMwTqxg16eC8UUcYoxXWoSawzfqf86c2B4G C2mvxVX5MBC+ZhVai5+HsYmAp+LaxgHakGIsO+v4wTKEzcp5XoxT3RUFITt1LtPPmASB 1D28nCp9LlUMUzIm6mb3Ewpw9TbxkQBfUgl3/EgblkJbGWdf2ja6wlSmEwFKaYvWviAL tdwNwlPVgxou2VaQaNddVGV8a4pggyJFwLW//hUhWRYBFIukC0qvcH49jTxnmH9yXFjf O5jWlgzHHHt9nE5LR7Ii77rHKTbhS7YZhmy39lMYp9DyK12sxNSc1LoqsavgEux+sTmx FHZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UX+kR0aZ; 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 b2-20020aa7df82000000b0045d0c00ead2si595239edy.157.2022.10.24.13.25.20; Mon, 24 Oct 2022 13:25:44 -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=UX+kR0aZ; 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 S233720AbiJXTwi (ORCPT + 99 others); Mon, 24 Oct 2022 15:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233572AbiJXTvs (ORCPT ); Mon, 24 Oct 2022 15:51:48 -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 72988114DE1; Mon, 24 Oct 2022 11:17:11 -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 3F8ECB817BF; Mon, 24 Oct 2022 12:36:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93A71C433D6; Mon, 24 Oct 2022 12:36:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614962; bh=tFfixY4/pqwPaFdGtoJbOHe7Ybm1zAZUS/nzuXpRp/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UX+kR0aZomuQhsZKZ4mIES0G73wPpZkwwm53AzNcuf0zKkhp964xsTn+B0vkGF7xb FhM0cGhziFE2zpAo0nYDH3ns0Ouu601Uj9wWrkKu+UscEY95dwZk+HOz9karjEP21T wh0t/KMA9KKvO0tNIsWuFxlMgEoziYA3p5UQapw0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brice Goglin , Sudeep Holla , Atish Patra , Conor Dooley Subject: [PATCH 5.15 039/530] riscv: topology: fix default topology reporting Date: Mon, 24 Oct 2022 13:26:23 +0200 Message-Id: <20221024113046.786018890@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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.6 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 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: Conor Dooley commit fbd92809997a391f28075f1c8b5ee314c225557c upstream. RISC-V has no sane defaults to fall back on where there is no cpu-map in the devicetree. Without sane defaults, the package, core and thread IDs are all set to -1. This causes user-visible inaccuracies for tools like hwloc/lstopo which rely on the sysfs cpu topology files to detect a system's topology. On a PolarFire SoC, which should have 4 harts with a thread each, lstopo currently reports: Machine (793MB total) Package L#0 NUMANode L#0 (P#0 793MB) Core L#0 L1d L#0 (32KB) + L1i L#0 (32KB) + PU L#0 (P#0) L1d L#1 (32KB) + L1i L#1 (32KB) + PU L#1 (P#1) L1d L#2 (32KB) + L1i L#2 (32KB) + PU L#2 (P#2) L1d L#3 (32KB) + L1i L#3 (32KB) + PU L#3 (P#3) Adding calls to store_cpu_topology() in {boot,smp} hart bringup code results in the correct topolgy being reported: Machine (793MB total) Package L#0 NUMANode L#0 (P#0 793MB) L1d L#0 (32KB) + L1i L#0 (32KB) + Core L#0 + PU L#0 (P#0) L1d L#1 (32KB) + L1i L#1 (32KB) + Core L#1 + PU L#1 (P#1) L1d L#2 (32KB) + L1i L#2 (32KB) + Core L#2 + PU L#2 (P#2) L1d L#3 (32KB) + L1i L#3 (32KB) + Core L#3 + PU L#3 (P#3) CC: stable@vger.kernel.org # 456797da792f: arm64: topology: move store_cpu_topology() to shared code Fixes: 03f11f03dbfe ("RISC-V: Parse cpu topology during boot.") Reported-by: Brice Goglin Link: https://github.com/open-mpi/hwloc/issues/536 Reviewed-by: Sudeep Holla Reviewed-by: Atish Patra Signed-off-by: Conor Dooley Signed-off-by: Greg Kroah-Hartman --- arch/riscv/Kconfig | 2 +- arch/riscv/kernel/smpboot.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -46,7 +46,7 @@ config RISCV select CLINT_TIMER if !MMU select COMMON_CLK select EDAC_SUPPORT - select GENERIC_ARCH_TOPOLOGY if SMP + select GENERIC_ARCH_TOPOLOGY select GENERIC_ATOMIC64 if !64BIT select GENERIC_CLOCKEVENTS_BROADCAST if SMP select GENERIC_EARLY_IOREMAP --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -53,6 +53,7 @@ void __init smp_prepare_cpus(unsigned in unsigned int curr_cpuid; curr_cpuid = smp_processor_id(); + store_cpu_topology(curr_cpuid); numa_store_cpu_info(curr_cpuid); numa_add_cpu(curr_cpuid); @@ -165,9 +166,9 @@ asmlinkage __visible void smp_callin(voi mmgrab(mm); current->active_mm = mm; + store_cpu_topology(curr_cpuid); notify_cpu_starting(curr_cpuid); numa_add_cpu(curr_cpuid); - update_siblings_masks(curr_cpuid); set_cpu_online(curr_cpuid, 1); /*