[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1648545322-14531-4-git-send-email-wangqing@vivo.com>
Date: Tue, 29 Mar 2022 02:15:21 -0700
From: Qing Wang <wangqing@...o.com>
To: Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Michael Ellerman <mpe@...erman.id.au>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
Sudeep Holla <sudeep.holla@....com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org
Cc: Wang Qing <wangqing@...o.com>
Subject: [PATCH 3/3] arm64: add arm64 default topology
From: Wang Qing <wangqing@...o.com>
default_topology does not fit arm64, especially CPU and cache topology.
Add arm64_topology, so we can do more based on CONFIG_GENERIC_ARCH_TOPOLOGY.
arm64_xxx_flags() prefer to get the cache attribute from DT.
Signed-off-by: Wang Qing <wangqing@...o.com>
---
arch/arm64/kernel/smp.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 27df5c1..d245012
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -715,6 +715,60 @@ void __init smp_init_cpus(void)
}
}
+#ifdef CONFIG_SCHED_CLUSTER
+static int arm64_cluster_flags(const struct cpumask *cpu_map)
+{
+ int flag = cpu_cluster_flags();
+ int ret = cpu_share_private_cache(cpu_map);
+ if (ret == 1)
+ flag |= SD_SHARE_PKG_RESOURCES;
+ else if (ret == 0)
+ flag &= ~SD_SHARE_PKG_RESOURCES;
+
+ return flag;
+}
+#endif
+
+#ifdef CONFIG_SCHED_MC
+static int arm64_core_flags(const struct cpumask *cpu_map)
+{
+ int flag = cpu_core_flags();
+ int ret = cpu_share_private_cache(cpu_map);
+ if (ret == 1)
+ flag |= SD_SHARE_PKG_RESOURCES;
+ else if (ret == 0)
+ flag &= ~SD_SHARE_PKG_RESOURCES;
+
+ return flag;
+}
+#endif
+
+static int arm64_die_flags(const struct cpumask *cpu_map)
+{
+ int flag = 0;
+ int ret = cpu_share_private_cache(cpu_map);
+ if (ret == 1)
+ flag |= SD_SHARE_PKG_RESOURCES;
+ else if (ret == 0)
+ flag &= ~SD_SHARE_PKG_RESOURCES;
+
+ return flag;
+}
+
+static struct sched_domain_topology_level arm64_topology[] = {
+#ifdef CONFIG_SCHED_SMT
+ { cpu_smt_mask, cpu_smt_flags, SD_INIT_NAME(SMT) },
+#endif
+#ifdef CONFIG_SCHED_CLUSTER
+ { cpu_clustergroup_mask, arm64_cluster_flags, SD_INIT_NAME(CLS) },
+#endif
+#ifdef CONFIG_SCHED_MC
+ { cpu_coregroup_mask, arm64_core_flags, SD_INIT_NAME(MC) },
+#endif
+ { cpu_cpu_mask, arm64_die_flags, SD_INIT_NAME(DIE) },
+ { NULL, },
+};
+
void __init smp_prepare_cpus(unsigned int max_cpus)
{
const struct cpu_operations *ops;
@@ -723,6 +777,8 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
unsigned int this_cpu;
init_cpu_topology();
+ init_cpu_cache_topology();
+ set_sched_topology(arm64_topology);
this_cpu = smp_processor_id();
store_cpu_topology(this_cpu);
--
2.7.4
Powered by blists - more mailing lists