[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABk29NutyV-m4ZMVerJwPzsGSDMwGGEvdERQSZzU+6xmomp1YA@mail.gmail.com>
Date: Thu, 15 Jan 2026 16:56:45 -0800
From: Josh Don <joshdon@...gle.com>
To: Zecheng Li <zli94@...u.edu>
Cc: Ingo Molnar <mingo@...hat.com>, 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>,
Valentin Schneider <vschneid@...hat.com>, Rik van Riel <riel@...riel.com>, Chris Mason <clm@...com>,
Madadi Vineeth Reddy <vineethr@...ux.ibm.com>, Xu Liu <xliuprof@...gle.com>,
Blake Jones <blakejones@...gle.com>, Nilay Vaish <nilayvaish@...gle.com>,
linux-kernel@...r.kernel.org, Zecheng Li <zecheng@...gle.com>
Subject: Re: [PATCH v6 2/3] sched/fair: Remove task_group->se pointer array
On Mon, Jan 12, 2026 at 10:51 AM Zecheng Li <zli94@...u.edu> wrote:
>
> From: Zecheng Li <zecheng@...gle.com>
>
> Now that struct sched_entity is co-located with struct cfs_rq for
> non-root task groups, the task_group->se pointer array is redundant. The
> associated sched_entity can be loaded directly from the cfs_rq.
>
> This patch performs the access conversion with the helpers:
>
> - is_root_task_group(tg): checks if a task group is the root task group.
> It compares the task group's address with the global root_task_group
> variable.
>
> - tg_se(tg, cpu): retrieves the cfs_rq and returns the address of the
> co-located se. This function checks if tg is the root task group to
> ensure behaving the same of previous tg->se[cpu]. Replaces all accesses
> that use the tg->se[cpu] pointer array with calls to the new tg_se(tg,
> cpu) accessor.
>
> - cfs_rq_se(cfs_rq): simplifies access paths like cfs_rq->tg->se[...] to
> use the co-located sched_entity. This function also checks if tg is the
> root task group to ensure same behavior.
>
> Since tg_se is not in very hot code paths, and the branch is a register
> comparison with an immediate value (`&root_task_group`), the performance
> impact is expected to be negligible.
>
> Signed-off-by: Zecheng Li <zecheng@...gle.com>
> Signed-off-by: Zecheng Li <zli94@...u.edu>
> ---
> kernel/sched/core.c | 7 ++-----
> kernel/sched/debug.c | 2 +-
> kernel/sched/fair.c | 25 +++++++++----------------
> kernel/sched/sched.h | 29 ++++++++++++++++++++++++-----
> 4 files changed, 36 insertions(+), 27 deletions(-)
[snip]
> +
> +static inline struct sched_entity *cfs_rq_se(struct cfs_rq *cfs_rq)
> +{
> + if (is_root_task_group(cfs_rq->tg))
> + return NULL;
> +
> + struct cfs_rq_with_se *combined =
> + container_of(cfs_rq, struct cfs_rq_with_se, cfs_rq);
> + return &combined->ses.se;
> +}
> #endif
>
This is fine, but just wanted to mention that we could also follow the
pattern of se->my_q and embed the se pointer inside the cfs_rq
instead. I think what you have now is ok though.
Powered by blists - more mailing lists