Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1651006imw; Sat, 9 Jul 2022 08:43:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tsFJrezs6xd48rXr3GhO8szoockvQAx6f/0Gc8DVBmHwE7a7gKqYsXbc1QpEd+Bt32aW4K X-Received: by 2002:a05:6a00:d2:b0:525:a508:d798 with SMTP id e18-20020a056a0000d200b00525a508d798mr9616065pfj.10.1657381406768; Sat, 09 Jul 2022 08:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657381406; cv=none; d=google.com; s=arc-20160816; b=y+znZXHiIpRr4iV+tkZI3WKDLMGV0p44580T3Z6wrl7PLvIWGmGalxR+099jIjV4wR v+UyhFOTDNfC16xKj+5hBE2mA1lTaf0XFoDdapXYkPH3Qq5DURPqrYRn3JGr9QYmEjJl m5KCFPa+vBp7xHLkyF1cuHyu0KqHNUG0lCfB0QzPF9FiOwVQY/oLFRAq0ncp2WVAi1JG y+6Btra/wihF3hTYM8ViIeGP/envMCyzd3xdNc4lgD7fiS1P9CnmVQCvi/o/BZnA0PxO povoCJw0aOj/W5ur6HUlfJQ/qaQNF5qK3fA9VyRCVaF6JqfC+JEifZlkQWvx44niOgsK 1j2Q== 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 :dkim-signature; bh=e7OziW02Y/9peL0FmHLT2XkVqPVR8DGTtiJWYX8th9g=; b=mclMo+KQcW83KMKfpxdi3DiI6mIBDqmX/1JH8jpKB0D3yR10SimZehgq50kAyiDtkv rZCd0shIeuR4c7Z6aBECLfA7q+LGwS0mb3u/nmlkCHLELhgVZFWtTVXw3pC5kzDtYkbl 7Y+5OzuBSv7mS0ZZV6aCYEO/aI2qmzGae8lFmyaECnUZEubgZP4aHF2S5obIR2fUWE0s mKggu34ZL2+y7xFSjLwAQLEwx9WqgK8NSIbbrjp/bVXHrn5mBRyvkIfXUIshDJ5P17Wl vs7UNctiyO8Esu4VvfZzLPCYY+S5f9dC4mclJzVLOemK60jYsaMnWXAGbWLNRIRbKzti fuWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@conchuod.ie header.s=google header.b=ECZOuvVP; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=conchuod.ie Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a170902bc4b00b0016382c70069si2753385plz.150.2022.07.09.08.43.04; Sat, 09 Jul 2022 08:43:26 -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=@conchuod.ie header.s=google header.b=ECZOuvVP; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=conchuod.ie Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229558AbiGIPYx (ORCPT + 99 others); Sat, 9 Jul 2022 11:24:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbiGIPYp (ORCPT ); Sat, 9 Jul 2022 11:24:45 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C26C713E88 for ; Sat, 9 Jul 2022 08:24:43 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id v14so1859152wra.5 for ; Sat, 09 Jul 2022 08:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=conchuod.ie; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e7OziW02Y/9peL0FmHLT2XkVqPVR8DGTtiJWYX8th9g=; b=ECZOuvVPNJv4pwuzvrO842PwGYJwOVKmO+ePMzvMb2kiTRVtLSAGqq0e8HvKfnAoev XwWbnXBDPV7oUrxaHTMMCTA7ZrD3zrxzMKO3H43E3lHT8OiWHNMJahLSJ2aQpJKNnkxz DR7dBbK/xncoYRSghBvFnBFDf7pd1eFaR+Dq+r2peG656ErDx+tqLFcZHxyjrV1TVvOR JMe0VByofu+6AGcXSNmPaB3ZHm0n+/koQ98BaXg9Pnm3gpnt3Tx4PbplmbCw4rd8Pl7S rsgZrPPV825g3ar4sbMq9eDFKlj/mFEMjRm4PxtZD0jeW5r33d32r2r9X6r9YGTEg5nM lU/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e7OziW02Y/9peL0FmHLT2XkVqPVR8DGTtiJWYX8th9g=; b=P4kaFxzFJZ7GEUKc7gG8/nWg+POKTRHpoFczZgEai+Di3LRtvkrL76BLih8s7IPExU uXfGVanQ41icEtUaTsXhl4m/ctkTcMlM4w2c7WsJhchBXUzwpkWTYz/ObAa+x3BdFt7Y 01nTYejdt3Ok406Gf9wctLlVgLsUmdP0PgbFt1ng4OrDSgPonbhN1u85ltVHXolKiqYJ S4roStI7Bo0vNjjSiRQFcOwraVt91OqqVRx3qCPNN4mE0GfJ2r1aivucq6LxMrWAcl14 ZkAD1/DrpBEElCze2IMqU4UjNMLwHyNUWr6LoLcXDxKYRF+R/me2jO4D2ffCaDHpblE0 cLlg== X-Gm-Message-State: AJIora9yeNlHGHszVKL5x7jfX9vhR9UxOkMOSf3oLEkLjUGoui4i8Z2N TN42XSWAKnS5cYOEl9yOd30ajQ== X-Received: by 2002:a5d:6a01:0:b0:21a:338c:4862 with SMTP id m1-20020a5d6a01000000b0021a338c4862mr8262063wru.631.1657380282203; Sat, 09 Jul 2022 08:24:42 -0700 (PDT) Received: from henark71.. ([51.37.234.167]) by smtp.gmail.com with ESMTPSA id y12-20020a5d620c000000b0021d63fe0f03sm1626730wru.12.2022.07.09.08.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jul 2022 08:24:41 -0700 (PDT) From: Conor Dooley To: Paul Walmsley , Palmer Dabbelt , Palmer Dabbelt , Albert Ou , Sudeep Holla , Catalin Marinas , Will Deacon , Greg Kroah-Hartman , "Rafael J . Wysocki" Cc: Daire McNamara , Conor Dooley , Niklas Cassel , Damien Le Moal , Geert Uytterhoeven , Zong Li , Emil Renner Berthing , Jonas Hahnfeld , Guo Ren , Anup Patel , Atish Patra , Heiko Stuebner , Philipp Tomsich , Rob Herring , Marc Zyngier , Viresh Kumar , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Brice Goglin Subject: [PATCH v3 2/2] riscv: topology: fix default topology reporting Date: Sat, 9 Jul 2022 16:23:55 +0100 Message-Id: <20220709152354.2856586-3-mail@conchuod.ie> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220709152354.2856586-1-mail@conchuod.ie> References: <20220709152354.2856586-1-mail@conchuod.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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: Conor Dooley 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 Fixes: 03f11f03dbfe ("RISC-V: Parse cpu topology during boot.") Reported-by: Brice Goglin Link: https://github.com/open-mpi/hwloc/issues/536 Signed-off-by: Conor Dooley --- --- arch/riscv/Kconfig | 2 +- arch/riscv/kernel/smpboot.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 2af0701b7518..4b6c2fdbb57c 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -52,7 +52,7 @@ config RISCV select COMMON_CLK select CPU_PM if CPU_IDLE 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 diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index f1e4948a4b52..a1c861f84fe2 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -40,6 +40,8 @@ static DECLARE_COMPLETION(cpu_running); void __init smp_prepare_boot_cpu(void) { init_cpu_topology(); + + store_cpu_topology(smp_processor_id()); } void __init smp_prepare_cpus(unsigned int max_cpus) @@ -161,9 +163,9 @@ asmlinkage __visible void smp_callin(void) 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); /* -- 2.37.0