From patchwork Wed Oct 19 08:22:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp203995wrs; Wed, 19 Oct 2022 01:44:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7afIahpPwZFmmqIEmV/cCPF632gI6oZIngYp1sZ/TiUYtb2sIqfAG6NG31dggMDTQ2JBhZ X-Received: by 2002:a05:6a00:2389:b0:565:328d:ed with SMTP id f9-20020a056a00238900b00565328d00edmr7368889pfc.84.1666169083742; Wed, 19 Oct 2022 01:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169083; cv=none; d=google.com; s=arc-20160816; b=dJbFT7npls9rfZljYiuOqoohc4JgSdJClyihsovqTFAMgBhJXqmIGCetNYKBLtqyMM J2RJnXDNVB9QkGt4vT4fi89cCduYb4qA3ofr9Za9+sKKQQV81lUMYnN0B2Tvjig2kNDM edqyDJ40lr5Fw1H4wDqTYgg7tc+2l/PF9FEloqZFy6UzSYDtbAlGvGdMbjK2Zu5jkr+M Hddd9NMK3yiXkOhLCNNJXRf+vb9nVF0yazcb9mRYKR9pGi420I7lkN+5e16XxTjiQx9Z xbJFbJzh+zkqfgO0aqqoFmZFihprR84w9NF9BpTfmMG35lLuLrcANRr8VamR88oKw8dM vuJA== 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=OYyDd0Eh3xL6PGaYojGuqPvarnc4dNhG94GPUfSJXcw=; b=qyASE/3JlGGqZ6ZFDK44M0EtadqWmnGRy6HxaOjKEiG/aNtCnQzA2a6h+vBBu4y7pH V+lhsF7nS6ENVUAUfgN+sUwIIUDQCrVd502mwLRNCp/ENv7UQsQp8Czw2AhGHhJFZIdw fxTgR1plYXDSW0Ee7e5IGVGi1vtaJp4iqs228kylLSsLoy1uj3PfVYnwzQgm7w5sS5gR LajAzngLyS+nRk2UNwCDFQn//kMsV+PYKXz9ECfMjvdFnnYLoszLrUE8YE46xQmm0/Pm t2+zYEQlYnHBdLn67jRgimRSz55V6qosC1JcSO00MnceLDGVbkjL7vxpyHIW0Qy4J4FJ 5bug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u+TfPuuT; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020a170902ec8600b0016efde92292si20902322plg.255.2022.10.19.01.44.29; Wed, 19 Oct 2022 01:44:43 -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=u+TfPuuT; 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 S231228AbiJSInk (ORCPT + 99 others); Wed, 19 Oct 2022 04:43:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbiJSIm4 (ORCPT ); Wed, 19 Oct 2022 04:42:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30DAD248C4; Wed, 19 Oct 2022 01:40:05 -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 24CC6B822CE; Wed, 19 Oct 2022 08:39:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 734A4C433D6; Wed, 19 Oct 2022 08:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168796; bh=H8BgRzjL1+2W+ogrWJW1r8i0ST+WS7ejeg1DeAkqdLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u+TfPuuT6ZyPqaTlxDBPfq6Y7OOlmziG/L6LoVY3qse3FQgPVk1hsqmInEbP7/np2 3tIuJa+9vbviqzxM9d5rcr/r5hQ38yXNB6dVZmaDVt3w9b7SyqifzYjLz/jCJJEqKx l7rTP1rePa7X18/OduTLjyg2yR9K+j5CUFSmzuMA= 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 6.0 056/862] riscv: topology: fix default topology reporting Date: Wed, 19 Oct 2022 10:22:23 +0200 Message-Id: <20221019083252.457314325@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747104912941243022?= X-GMAIL-MSGID: =?utf-8?q?1747104912941243022?= 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); @@ -162,9 +163,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); /*