From patchwork Sat Oct 22 07:18:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1088522wrr; Sat, 22 Oct 2022 00:40:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5NFaCnT86hDz98smgDaXXXbxWSMo0rNGtp36gX7JzMQ4jWWNM2irIpqtvdA/akQ/wdq5Ct X-Received: by 2002:a17:903:1110:b0:178:9f67:b524 with SMTP id n16-20020a170903111000b001789f67b524mr23499605plh.50.1666424418120; Sat, 22 Oct 2022 00:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424418; cv=none; d=google.com; s=arc-20160816; b=vxUNfcii7jT7A8QH6Sc3MpDV8PkecB33TXuMdBeYQH7BG/KWhMx2swNAaloim7JEwr J9PCK7yw0b1JSi2Nji0bC/y+RY3CPYs4reaVD74Fm+XMIiF431ZU3vHr2/pQ8THML3fv CKQOwCOjnWjlsPRpiZhAbPjV1skfdUOh7MsOAmyGraiUtB0i+eD07nd+0KWgvgrcayu9 cqMzGh0fv+eFb6+uiDUYPyRLgDAgGOBSCIesEjvD+p7X4foe8TORwlkyTARorcJGX355 5GdXXAJHpZ5kNiOIQu5ot1htbw+zsgiNZvCrj+aepdQ658ekvPPX7c1/59krCnNzLV0C E6ng== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a056a0023c500b00562040a507asi30678574pfc.85.2022.10.22.00.40.05; Sat, 22 Oct 2022 00:40:18 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747372650797175554?= X-GMAIL-MSGID: =?utf-8?q?1747372650797175554?= 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); /*