[RFC 05/60] sched: Allow to retrieve the sched_domain_topology

From: Jan H. SchÃnherr
Date: Fri Sep 07 2018 - 17:41:30 EST


While it is possible to simply overwrite the sched_domain_topology,
it was not possible to retrieve the sched_domain_topology to modify
it instead. Add a function to enable that use case.

Note, that this does not help with the already existing potential
memory leak, when one dynamically allocated sched_domain_topology
is replaced with another one.

Signed-off-by: Jan H. SchÃnherr <jschoenh@xxxxxxxxx>
---
include/linux/sched/topology.h | 1 +
kernel/sched/topology.c | 5 +++++
2 files changed, 6 insertions(+)

diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h
index f78534f1cc1e..28d037d0050e 100644
--- a/include/linux/sched/topology.h
+++ b/include/linux/sched/topology.h
@@ -194,6 +194,7 @@ struct sched_domain_topology_level {
};

extern void set_sched_topology(struct sched_domain_topology_level *tl);
+struct sched_domain_topology_level *get_sched_topology(void);

#ifdef CONFIG_SCHED_DEBUG
# define SD_INIT_NAME(type) .name = #type
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 0f2c3aa0a097..f2db2368ac5f 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1226,6 +1226,11 @@ void set_sched_topology(struct sched_domain_topology_level *tl)
}
}

+struct sched_domain_topology_level *get_sched_topology(void)
+{
+ return sched_domain_topology;
+}
+
#ifdef CONFIG_NUMA

static const struct cpumask *
--
2.9.3.1.gcba166c.dirty