|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 08/21] xen/sched: Link CPU topology to scheduler and display via xl info
Make CPU topology information available to the Xen scheduler.
Additionally, ensure that this topology information is displayed
when executing the 'xl info -n' command.
---
xen/arch/arm/include/asm/processor.h | 6 ++-
xen/arch/arm/smpboot.c | 10 +++--
xen/common/device-tree/cpu_topology.c | 54 +++++++++++++++++++++++++++
xen/common/sched/credit2.c | 3 ++
xen/common/sysctl.c | 1 +
xen/include/xen/cpu_topology.h | 3 ++
6 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/xen/arch/arm/include/asm/processor.h
b/xen/arch/arm/include/asm/processor.h
index 895d7cd502..066966b375 100644
--- a/xen/arch/arm/include/asm/processor.h
+++ b/xen/arch/arm/include/asm/processor.h
@@ -591,9 +591,13 @@ void show_stack(const struct cpu_user_regs *regs);
#define cpu_relax() barrier() /* Could yield? */
-/* All a bit UP for the moment */
+#ifdef CONFIG_DT_CPU_TOPOLOGY
+#define cpu_to_core(_cpu) (cpu_topology[_cpu].to_core)
+#define cpu_to_socket(_cpu) (cpu_topology[_cpu].to_socket)
+#else /* CONFIG_DT_CPU_TOPOLOGY */
#define cpu_to_core(_cpu) (0)
#define cpu_to_socket(_cpu) (0)
+#endif /* CONFIG_DT_CPU_TOPOLOGY */
struct vcpu;
void vcpu_regs_hyp_to_user(const struct vcpu *vcpu,
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index ff8b0d07e9..726f3720ce 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -93,13 +93,17 @@ static int setup_cpu_sibling_map(int cpu)
!zalloc_cpumask_var(&per_cpu(cpu_core_mask, cpu)) )
return -ENOMEM;
+#ifdef CONFIG_DT_CPU_TOPOLOGY
+ cpumask_copy(per_cpu(cpu_sibling_mask, cpu),
&cpu_topology[cpu].thread_sibling);
+ cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_topology[cpu].core_sibling);
+#else /* CONFIG_DT_CPU_TOPOLOGY */
/*
- * Currently we assume there is no multithread and NUMA, so
- * a CPU is a sibling with itself, and the all possible CPUs
- * are supposed to belong to the same socket (NUMA node).
+ * If CONFIG_DT_CPU_TOPOLOGY is disabled, it is assumed that
+ * all CPUs reside in the same socket and that SMT is not used.
*/
cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu));
cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map);
+#endif /* CONFIG_DT_CPU_TOPOLOGY */
return 0;
}
diff --git a/xen/common/device-tree/cpu_topology.c
b/xen/common/device-tree/cpu_topology.c
index 6c78a74778..f5d2a59e2c 100644
--- a/xen/common/device-tree/cpu_topology.c
+++ b/xen/common/device-tree/cpu_topology.c
@@ -275,6 +275,58 @@ static void __init fixup_topology(void)
}
+static void __init setup_topology_for_sched(void)
+{
+ int prev_socketid = 0;
+ int prev_clusterid = 0;
+ int prev_coreid = 0;
+ int prev_threadid = 0;
+ int coreid = 0;
+ int socketid = 0;
+ int clusterid = 0;
+ int threadid = 0;
+ int cpu;
+
+ for_each_possible_cpu(cpu)
+ {
+ struct cpu_topology *cpu_topo = &cpu_topology[cpu];
+
+ if (cpu_topo->package_id != prev_socketid)
+ {
+ prev_socketid = cpu_topo->package_id;
+ prev_clusterid = cpu_topo->cluster_id;
+ prev_coreid = cpu_topo->core_id;
+ socketid++;
+ clusterid++;
+ coreid++;
+ threadid++;
+ }
+ else if (cpu_topo->cluster_id != prev_clusterid)
+ {
+ prev_clusterid = cpu_topo->cluster_id;
+ prev_coreid = cpu_topo->core_id;
+ clusterid++;
+ coreid++;
+ threadid++;
+ }
+ else if (cpu_topo->core_id != prev_coreid)
+ {
+ prev_coreid = cpu_topo->core_id;
+ coreid++;
+ threadid++;
+ }
+ else if (cpu_topo->thread_id != prev_threadid)
+ {
+ threadid++;
+ }
+
+ cpu_topo->to_socket = socketid;
+ cpu_topo->to_core = coreid;
+ cpu_topo->num_siblings = cpumask_weight(&cpu_topo->thread_sibling);
+ }
+
+}
+
int __init parse_dt_topology(void)
{
struct dt_device_node *cpus;
@@ -304,4 +356,6 @@ void __init dt_init_cpu_topology(void)
for_each_possible_cpu(cpu)
setup_siblings_masks(cpu);
+
+ setup_topology_for_sched();
}
diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c
index 75316d42b7..34876b99c0 100644
--- a/xen/common/sched/credit2.c
+++ b/xen/common/sched/credit2.c
@@ -20,6 +20,7 @@
#include <xen/softirq.h>
#include <xen/time.h>
#include <xen/trace.h>
+#include <xen/cpu_topology.h>
#include <asm/div64.h>
@@ -38,6 +39,8 @@ static unsigned int cpu_nr_siblings(unsigned int cpu)
{
#ifdef CONFIG_X86
return cpu_data[cpu].x86_num_siblings;
+#elif CONFIG_DT_CPU_TOPOLOGY
+ return cpu_topology[cpu].num_siblings;
#else
return 1;
#endif
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 5207664252..806c885df1 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -28,6 +28,7 @@
#include <xen/pmstat.h>
#include <xen/livepatch.h>
#include <xen/coverage.h>
+#include <xen/cpu_topology.h>
long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
{
diff --git a/xen/include/xen/cpu_topology.h b/xen/include/xen/cpu_topology.h
index 0cdceb9bd0..c22224b3af 100644
--- a/xen/include/xen/cpu_topology.h
+++ b/xen/include/xen/cpu_topology.h
@@ -14,6 +14,9 @@ struct cpu_topology {
cpumask_t thread_sibling;
cpumask_t core_sibling;
cpumask_t cluster_sibling;
+ int to_core;
+ int to_socket;
+ int num_siblings;
};
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |