Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3931335rwi; Sat, 22 Oct 2022 02:25:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4rmt3B9QmRqruTcNmHbNAvPWHOLLgOdbgunsWG6efFpSIs7OrgBwuFM+DxGYdU7e0F1smk X-Received: by 2002:aa7:d744:0:b0:45c:e353:e891 with SMTP id a4-20020aa7d744000000b0045ce353e891mr21813041eds.36.1666430748483; Sat, 22 Oct 2022 02:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666430748; cv=none; d=google.com; s=arc-20160816; b=OUXmTFFYoGsPbCTWupcMa/797rbK4goDan6IcXsCCdyIS53ViT3KhmtgmvjVhAWx7b LHxsvPuOEo/OPg/ZsWYTAhEqliptXvn/gNgsq4Xlb4QHALXuuSQPBGrifFe8h0gbQu5s WgstCbYLQeSHxbKbtFlB1W+3t8rFA6Vlazdb8gYSFk4CTC732UIl69P0c0ZSbZSsbFFr 3FFTS+fCuI1m2Fy5VM0IABp9AlB6EB5D7ivkNEpDXid9B+EukoJBPm6CT+jBccEXPAoC DPwFcx4jrnPbQ59gYfyZx7ieOj1c1vn0gXk3ZALmpDDd/jb5or8RapZEo1qwF9lKdq9K xkiw== 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=e/kxpKOZQLrI7gvn8ngNudVJwJgXTOJfaF7uDHm6rMg=; b=DuRIj9QjkL4OfJiJDD2Jp3JkUrDKI3fbEqIcLls3gZ2/VLOCFhe8ymi7SzCIkZZmVw YJjipMGM/qrvUcDuci9uHylwtET3K/r5rTkp6hdZgDyOjbad3wLQ+fuE1SJKjU8tR4Ab l47UpvuKu1vHHHEzPz2+yUrooDRfkW2lAIWIlPn5Fuv0r+GH1V/uO+hWaz33PePx04Nf 9xXo2aEZ4q/NQvHKcqk50g0eji6f2+c9QKGwaMjpZHfXTzSsf2k6gY0m41YnKflEw33R rWcWwIMYGl3xkfi/31FodSFLDJ9Mt9PH3EpMVPVwIbOixBaFlbl38hCbcsyJ7OZcufEk lRzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HXE815gp; 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 hv9-20020a17090760c900b0078c31a71f47si21171356ejc.220.2022.10.22.02.25.23; Sat, 22 Oct 2022 02:25:48 -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=HXE815gp; 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 S231146AbiJVHju (ORCPT + 99 others); Sat, 22 Oct 2022 03:39:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbiJVHiw (ORCPT ); Sat, 22 Oct 2022 03:38:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4744429F66C; Sat, 22 Oct 2022 00:36:17 -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 27F3AB82DB2; Sat, 22 Oct 2022 07:36:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89947C433C1; Sat, 22 Oct 2022 07:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424173; bh=GGLjFMYoJGfidgbt/07BvGlVlVrcFtoL5SxMq3ZmWTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HXE815gpEaUtvVP+RofFO1KWzz5vTm6VDo2uifXT7TSqHmhdHvVvc40HHDKLygJv2 9wKo6BVb3hwkjBXAtRaslOXoHcBkym5r5boPKCIz2VJd8fk23dX42E8MawC5fIFzkZ G1X9sQzBfiSSY0MRp5go5Xz2ppngUKV0dXeR0TuU= 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.19 050/717] riscv: topology: fix default topology reporting Date: Sat, 22 Oct 2022 09:18:49 +0200 Message-Id: <20221022072423.955103270@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@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.3 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 @@ -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 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -49,6 +49,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); @@ -161,9 +162,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); /*