Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp702422imw; Fri, 15 Jul 2022 11:12:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1smvlmfSUw6jdlATgFjdQJkINAVfHc+zgqIwDkVWy9TuNeyyzA2PJl6B+sBqhuPhldt4Qm1 X-Received: by 2002:a05:6871:5c7:b0:10c:24de:509a with SMTP id v7-20020a05687105c700b0010c24de509amr11101816oan.202.1657908777954; Fri, 15 Jul 2022 11:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657908777; cv=none; d=google.com; s=arc-20160816; b=gUQs20p/7fzAyJ5bsB9II3daVcwZh2V2qM06PZ7adMVkw8FIfO8ZOgpaVcg3IqCtt8 oQHBM8lnjPNewjVGuJ31pEnFUA+1VzlQHDb069eKThvaBvnkO4Q29E5P33V1x6NA/rRr uYj17B7VJrbAF32hxVJCXHq2m8m1HgSaX+C8dggVIu3x4omvpVEGPyDgcOinlkaaw5wf j/nIAMU1o3oUXIx7gG6LT0M8aEhT/22/kEplCKPmlcSNVeYMMlOovZNaqkqPJWBFi261 xt+vI3TVXDgeUqeNOtkYYZVgfOZ3nAaRtsYqJ+JCu5UzwhcPFv8yIP1sZW4e56h8oIRl uUCg== 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=c3AAc+ZWRep7EdC36jKYHok1cQbg6aR7AuxmKHVGFG4=; b=mbGHLdPKU8uTm2Is+Z+nxOJXCpM6Sh1L4cjgJ3pMFpp6wAL5uzHoOx+J9pfjIUnMvx lHw9wBrBZkqD7PA/CeHQ03zN6zs3SvpbBxtrR9RKfSL2WtLxnExfcEi0QFvIwUL0n+82 zurrh3Qpvm88Ff4nmSMRrsmhiQugKY7W5G8LHH3HBvJw6F7TXg5IJQaSTS5tSAadWszX 8KtoWWZehWqUTb8GaST5rq4QBMLVMr+PUaTBA2/n+GyXrV78EooKP5b2DtweGF1crKEG 78SMrzz5kAxDYjKvvHve0FTdSsMhLBfCO5ZSivhbCVoG5+cyk7U2hmAiASubS64n2mGn v1mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@conchuod.ie header.s=google header.b="gVM/YKXv"; 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 v34-20020a05687070a200b000f19cf30677si2560788oae.22.2022.07.15.11.12.45; Fri, 15 Jul 2022 11:12:57 -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="gVM/YKXv"; 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 S229718AbiGORx6 (ORCPT + 99 others); Fri, 15 Jul 2022 13:53:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbiGORxq (ORCPT ); Fri, 15 Jul 2022 13:53:46 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F03EE270E for ; Fri, 15 Jul 2022 10:53:42 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id c187-20020a1c35c4000000b003a30d88fe8eso1260098wma.2 for ; Fri, 15 Jul 2022 10:53:42 -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=c3AAc+ZWRep7EdC36jKYHok1cQbg6aR7AuxmKHVGFG4=; b=gVM/YKXv8JXkoDC7eqAwEizXbVSH+uSr0nqKVg+ctMmY8hVlCRDjc/9ZZTsDcoN+2H mtpDWTezfDAJ43oAGeqE36TTu5rUoVYKhDs1f4b2F6EKLws8FDsuM4rARFFbKcbykf6/ NvYfX4ScKZecFSytDDMovm3vqoSutLN3tR9YKPCpljzUiNgYMq9UwV4MX/M4bfQ1E64v 02lRrWHmPVTmESUgn6sncWSekVfe8UJ0moOad7MBpLOeMZy+hWMVdcJL29q1ZEZ1ohZU EqmLJ7Gdg5FNlW4ImRIHlJGFyMceS9FsAuryPKNgOY32cWQPJ/0V7fB/bJqQPiBN/Sx+ N2ZQ== 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=c3AAc+ZWRep7EdC36jKYHok1cQbg6aR7AuxmKHVGFG4=; b=euOuEEeR0xxcjF0ZMU+srKrytmdxX25QiO+ZCarq+RFQQd5ApkFwfahPt4fBipsmKl qlh/WLmBM81/XpwANa9sPbFrUwG4rtxakA4thskrNmFXHE+DZvUObzgE9dQrpZstm1ra GQHwUN/FKuYreUVqv06ap5eTzKxE7EzxIzYp8SelgtwuGVCJA4kg6ZcuZ7Zhn7fbgaiJ 1uNmu5ecGF6czbkLV/sOI6ho3yrBUA6B353awpIhglBqTEqVzz9DWRYoWGwm3ex++yOm beV0iKhVdxNC1MceZBLm1oJHkcpy11Ngn8hbjqvZsAb00PwXNDIgjbgCqBD/Vx+oK2FV gtqg== X-Gm-Message-State: AJIora8OJo1H8XSkMsQlCSWhsrWiM2XzD00W44gt9jsK6iYgTIrwZkdf smWPUPt/ap/gEWs1xpn1rflmRg== X-Received: by 2002:a05:600c:190a:b0:3a2:e8cc:57ca with SMTP id j10-20020a05600c190a00b003a2e8cc57camr15642409wmq.118.1657907621417; Fri, 15 Jul 2022 10:53:41 -0700 (PDT) Received: from henark71.. ([51.37.234.167]) by smtp.gmail.com with ESMTPSA id n9-20020a5d4c49000000b002167efdd549sm4364131wrt.38.2022.07.15.10.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 10:53:40 -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 v4 2/2] riscv: topology: fix default topology reporting Date: Fri, 15 Jul 2022 18:51:56 +0100 Message-Id: <20220715175155.3567243-3-mail@conchuod.ie> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220715175155.3567243-1-mail@conchuod.ie> References: <20220715175155.3567243-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 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 Reviewed-by: Sudeep Holla --- arch/riscv/Kconfig | 2 +- arch/riscv/kernel/smpboot.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 205c1e2f539c..7ffac8818060 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..b4d5524b1077 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -49,6 +49,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) 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); @@ -161,9 +162,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.1