[RFC 32/60] cosched: Specialize parent_cfs_rq() for hierarchical runqueues

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


Make parent_cfs_rq() coscheduling-aware.

Signed-off-by: Jan H. SchÃnherr <jschoenh@xxxxxxxxx>
---
kernel/sched/fair.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8504790944bf..8cba7b8fb6bd 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -284,12 +284,25 @@ static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp)
return grp->my_q;
}

+#ifdef CONFIG_COSCHEDULING
+static inline struct cfs_rq *parent_cfs_rq(struct cfs_rq *cfs_rq)
+{
+ /*
+ * Only return TG parent (if valid), don't switch levels.
+ * Callers stay or expect to stay within the same level.
+ */
+ if (!cfs_rq->sdrq.tg_parent || !cfs_rq->sdrq.is_root)
+ return NULL;
+ return cfs_rq->sdrq.tg_parent->cfs_rq;
+}
+#else /* !CONFIG_COSCHEDULING */
static inline struct cfs_rq *parent_cfs_rq(struct cfs_rq *cfs_rq)
{
if (!cfs_rq->tg->parent)
return NULL;
return cfs_rq->tg->parent->cfs_rq[cpu_of(rq_of(cfs_rq))];
}
+#endif /* !CONFIG_COSCHEDULING */

static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq)
{
--
2.9.3.1.gcba166c.dirty