lkml.org 
[lkml]   [2018]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC 28/60] cosched: Add is_sd_se() to distinguish SD-SEs from TG-SEs
    Date
    Add a function is_sd_se() to easily distinguish SD-SEs from a TG-SEs.

    Internally, we distinguish tasks, SD-SEs, and TG-SEs based on the my_q
    field. For tasks it is empty, for TG-SEs it is a pointer, and for
    SD-SEs it is a magic value.

    Also modify propagate_entity_load_avg() to not page fault on SD-SEs.

    Signed-off-by: Jan H. Schönherr <jschoenh@amazon.de>
    ---
    kernel/sched/fair.c | 12 +++++-------
    kernel/sched/sched.h | 14 ++++++++++++++
    2 files changed, 19 insertions(+), 7 deletions(-)

    diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
    index 18b1d81951f1..9cbdd027d449 100644
    --- a/kernel/sched/fair.c
    +++ b/kernel/sched/fair.c
    @@ -279,6 +279,8 @@ static inline struct cfs_rq *cfs_rq_of(struct sched_entity *se)
    /* runqueue "owned" by this group */
    static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp)
    {
    + if (grp->my_q == INDIRECT_GROUP)
    + return NULL;
    return grp->my_q;
    }

    @@ -3240,13 +3242,9 @@ static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum
    /* Update task and its cfs_rq load average */
    static inline int propagate_entity_load_avg(struct sched_entity *se)
    {
    - struct cfs_rq *cfs_rq, *gcfs_rq;
    -
    - if (entity_is_task(se))
    - return 0;
    + struct cfs_rq *cfs_rq, *gcfs_rq = group_cfs_rq(se);

    - gcfs_rq = group_cfs_rq(se);
    - if (!gcfs_rq->propagate)
    + if (!gcfs_rq || !gcfs_rq->propagate)
    return 0;

    gcfs_rq->propagate = 0;
    @@ -9931,7 +9929,7 @@ void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
    /* se is NULL for root_task_group */
    if (se) {
    set_entity_cfs(se, parent);
    - se->my_q = cfs_rq;
    + se->my_q = cfs_rq ?: INDIRECT_GROUP;

    /* guarantee group entities always have weight */
    update_load_set(&se->load, NICE_0_LOAD);
    diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
    index 456b266b8a2c..5e2d231b1dbf 100644
    --- a/kernel/sched/sched.h
    +++ b/kernel/sched/sched.h
    @@ -1146,6 +1146,13 @@ static inline struct rq *parent_rq(struct rq *rq)
    return NULL;
    return container_of(rq->sdrq_data.parent, struct rq, sdrq_data);
    }
    +
    +#define INDIRECT_GROUP ERR_PTR(-EREMOTE)
    +
    +static inline bool is_sd_se(struct sched_entity *se)
    +{
    + return se->my_q == INDIRECT_GROUP;
    +}
    #else /* !CONFIG_COSCHEDULING */
    static inline int node_of(struct rq *rq)
    {
    @@ -1161,6 +1168,13 @@ static inline struct rq *parent_rq(struct rq *rq)
    {
    return NULL;
    }
    +
    +#define INDIRECT_GROUP NULL
    +
    +static inline bool is_sd_se(struct sched_entity *se)
    +{
    + return false;
    +}
    #endif /* !CONFIG_COSCHEDULING */

    #ifdef CONFIG_COSCHEDULING
    --
    2.9.3.1.gcba166c.dirty
    \
     
     \ /
      Last update: 2018-09-07 23:47    [W:5.214 / U:0.080 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site