From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11E9BC433F5 for ; Mon, 14 Mar 2022 17:13:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/fIjxEW1q4a+qWGhYdz0Mpt/inK7pjZhJ7FlSR/SGNo=; b=n0s2p2zxijt4/p dZ3VPPg6lu+NIz1by95+YnJ+VP+DIRsshmD/TufGBrlMZWIi++30pWQcfsEffyB+G/roXmBeRfMWq ZzJBJB39a5Z+nrFIQXzYIeGhPknZsjyOWFMN+CJcds5CrTbJBPRegPOQw/zCWNknyJfDe3nOYDZgL x75STGaocA4GcOjcp6SoeNy/zFxdNSNSHSoEP9WIBpYsi6EexFLrR4lnVLYGodDOPC6FFTi6CCVnK H36udrbqI7kcqmSdpsSFxKKrdazUhKYbg8lvrtL+fPiDn/2Pn4eoZk/Ai7QJXLJbU08rL0z9nk6BB fotBFlCBs82KIUYIJXmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nToEX-006Hwj-U9; Mon, 14 Mar 2022 17:11:51 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nToD2-006HQe-PK for linux-arm-kernel@bombadil.infradead.org; Mon, 14 Mar 2022 17:10:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=qeQZVM1HybuTDC+dhkjOGJ3p4PBpIuwdC/J4CNauG68=; b=cO+y4TuYbx+lqKF91sa7IIdJPS GRBUi7NSDy64fU6/c0AxkRStxhVblXRp3Wr5Qg/m//LeBq65C/YiFhGfpGMVlWI2mulw5m+4gOHIK SGPQB/kmrGm29jSkzuoRDPBQ91EQVoLMYKY91CdnmvPK9ziEwxxPS92zcMA12ZOpDXCOnu18aByj2 q7pNau2wNTaz1HAmNGpX/F4ULpDgUt9jBGnprDzBy/1J1qF53DZH8FywAVnSUwy5U8My2QwEoRfnK ELqfsd1wlwESA/gClVXBs4yYNG1VE1bsoZCQ2VWFzElv8wigOPfbw4633uNfNUd0N2FMqYyB3eKnK l3gAsNPg==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nTnfC-000uJy-P9 for linux-arm-kernel@lists.infradead.org; Mon, 14 Mar 2022 16:35:25 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9D1D9D6E; Mon, 14 Mar 2022 09:35:15 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 322D63F766; Mon, 14 Mar 2022 09:35:13 -0700 (PDT) Message-ID: <9398d7ad-30e7-890a-3e18-c3011c383585@arm.com> Date: Mon, 14 Mar 2022 17:35:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3] topology: make core_mask include at least cluster_siblings Content-Language: en-US To: Darren Hart Cc: Vincent Guittot , Will Deacon , LKML , Linux Arm , Sudeep Holla , Greg Kroah-Hartman , "Rafael J. Wysocki" , Catalin Marinas , Peter Zijlstra , Barry Song , Valentin Schneider , "D . Scott Phillips" , Ilkka Koskinen , stable@vger.kernel.org References: <20220308103012.GA31267@willie-the-truck> <7ac47c67-0b5e-5caa-20bb-a0100a0cb78f@arm.com> From: Dietmar Eggemann In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220314_163519_236611_92D06C8C X-CRM114-Status: GOOD ( 27.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 09/03/2022 19:26, Darren Hart wrote: > On Wed, Mar 09, 2022 at 01:50:07PM +0100, Dietmar Eggemann wrote: >> On 08/03/2022 18:49, Darren Hart wrote: >>> On Tue, Mar 08, 2022 at 05:03:07PM +0100, Dietmar Eggemann wrote: >>>> On 08/03/2022 12:04, Vincent Guittot wrote: >>>>> On Tue, 8 Mar 2022 at 11:30, Will Deacon wrote: [...] >>>> I do not have any better idea than this tweak here either in case the >>>> platform can't provide a cleaner setup. >>> >>> I'd argue The platform is describing itself accurately in ACPI PPTT >>> terms. The topology doesn't fit nicely within the kernel abstractions >>> today. This is an area where I hope to continue to improve things going >>> forward. >> >> I see. And I assume lying about SCU/LLC boundaries in ACPI is not an >> option since it messes up /sys/devices/system/cpu/cpu0/cache/index*/. >> >> [...] > > I'm not aware of a way to accurately describe the SCU topology in the PPTT, and > the risk we run with lying about LLC topology is that lie has to be comprehended > by all OSes and not conflict with other lies people may ask for. In general, I > think it is preferable and more maintainable to describe the topology as > accurately and honestly as we can within the existing platform mechanisms (PPTT, > HMAT, etc) and work on the higher level abstractions to accommodate a broader > set of topologies as they emerge (as well as working to more fully describe the > topology with new platform level mechanisms as needed). > > As I mentioned, I intend to continue looking in to how to improve the current > abstractions. For now, it sounds like we have agreement that this patch can be > merged to address the BUG? What about swapping the CLS and MC cpumasks for such a machine? This would avoid that the task scheduler has to deal with a system which has CLS but no MC. We essentially promote the CLS cpumask up to MC in this case. cat /sys/kernel/debug/sched/domains/cpu0/domain*/name MC ^^ DIE NUMA cat /sys/kernel/debug/sched/domains/cpu0# cat domain*/flags SD_BALANCE_NEWIDLE SD_BALANCE_EXEC SD_BALANCE_FORK SD_WAKE_AFFINE SD_SHARE_PKG_RESOURCES SD_PREFER_SIBLING ^^^^^^^^^^^^^^^^^^^^^^ SD_BALANCE_NEWIDLE SD_BALANCE_EXEC SD_BALANCE_FORK SD_WAKE_AFFINE SD_PREFER_SIBLING SD_BALANCE_NEWIDLE SD_BALANCE_EXEC SD_BALANCE_FORK SD_WAKE_AFFINE SD_SERIALIZE SD_OVERLAP SD_NUMA Only very lightly tested on Altra and Juno-r0 (DT). --->8--- >From 54bef59e7f50fa41b7ae39190fd71af57209c27d Mon Sep 17 00:00:00 2001 From: Dietmar Eggemann Date: Mon, 14 Mar 2022 15:08:23 +0000 Subject: [PATCH] arch_topology: Swap MC & CLS SD mask if MC weight==1 & subset(MC,CLS) This avoids the issue of having a system with a CLS SD but no MC SD. CLS should be sub-SD of MC. The cpumask under /sys/devices/system/cpu/cpu*/cache/index* and /sys/devices/system/cpu/cpu*/topology are not changed by this. Signed-off-by: Dietmar Eggemann --- drivers/base/arch_topology.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 976154140f0b..9af90a5625c7 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -614,7 +614,7 @@ static int __init parse_dt_topology(void) struct cpu_topology cpu_topology[NR_CPUS]; EXPORT_SYMBOL_GPL(cpu_topology); -const struct cpumask *cpu_coregroup_mask(int cpu) +const struct cpumask *_cpu_coregroup_mask(int cpu) { const cpumask_t *core_mask = cpumask_of_node(cpu_to_node(cpu)); @@ -631,11 +631,37 @@ const struct cpumask *cpu_coregroup_mask(int cpu) return core_mask; } -const struct cpumask *cpu_clustergroup_mask(int cpu) +const struct cpumask *_cpu_clustergroup_mask(int cpu) { return &cpu_topology[cpu].cluster_sibling; } +static int +swap_masks(const cpumask_t *core_mask, const cpumask_t *cluster_mask) +{ + if (cpumask_weight(core_mask) == 1 && + cpumask_subset(core_mask, cluster_mask)) + return 1; + + return 0; +} + +const struct cpumask *cpu_coregroup_mask(int cpu) +{ + const cpumask_t *cluster_mask = _cpu_clustergroup_mask(cpu); + const cpumask_t *core_mask = _cpu_coregroup_mask(cpu); + + return swap_masks(core_mask, cluster_mask) ? cluster_mask : core_mask; +} + +const struct cpumask *cpu_clustergroup_mask(int cpu) +{ + const cpumask_t *cluster_mask = _cpu_clustergroup_mask(cpu); + const cpumask_t *core_mask = _cpu_coregroup_mask(cpu); + + return swap_masks(core_mask, cluster_mask) ? core_mask : cluster_mask; +} + void update_siblings_masks(unsigned int cpuid) { struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid]; -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel