From: Peter Zijlstra <peterz@infradead.org>
To: Yajun Deng <yajun.deng@linux.dev>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
bristot@redhat.com, vschneid@redhat.com,
linux-kernel@vger.kernel.org,
kernel test robot <oliver.sang@intel.com>
Subject: Re: [PATCH v4] sched/rt: move back to RT_GROUP_SCHED and rename it child
Date: Tue, 3 Oct 2023 12:36:39 +0200 [thread overview]
Message-ID: <20231003103639.GD1539@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20230803050317.2240948-1-yajun.deng@linux.dev>
On Thu, Aug 03, 2023 at 01:03:17PM +0800, Yajun Deng wrote:
> @@ -564,6 +566,9 @@ static inline struct task_group *next_task_group(struct task_group *tg)
> #define for_each_sched_rt_entity(rt_se) \
> for (; rt_se; rt_se = rt_se->parent)
>
> +#define for_each_sched_rt_entity_reverse(rt_se) \
> + for (; rt_se; rt_se = rt_se->child)
> +
> static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se)
> {
> return rt_se->my_q;
> @@ -669,6 +674,9 @@ typedef struct rt_rq *rt_rq_iter_t;
> #define for_each_sched_rt_entity(rt_se) \
> for (; rt_se; rt_se = NULL)
>
> +#define for_each_sched_rt_entity_reverse(rt_se) \
> + for_each_sched_rt_entity(rt_se)
> +
> static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se)
> {
> return NULL;
> @@ -1481,22 +1489,21 @@ static void __dequeue_rt_entity(struct sched_rt_entity *rt_se, unsigned int flag
> */
> static void dequeue_rt_stack(struct sched_rt_entity *rt_se, unsigned int flags)
> {
> - struct sched_rt_entity *back = NULL;
> + struct sched_rt_entity *root;
> unsigned int rt_nr_running;
>
> - for_each_sched_rt_entity(rt_se) {
> - rt_se->back = back;
> - back = rt_se;
> - }
> + for_each_sched_rt_entity(rt_se)
> + root = rt_se;
>
> - rt_nr_running = rt_rq_of_se(back)->rt_nr_running;
> + rt_nr_running = rt_rq_of_se(root)->rt_nr_running;
>
> - for (rt_se = back; rt_se; rt_se = rt_se->back) {
> + rt_se = root;
> + for_each_sched_rt_entity_reverse(rt_se) {
> if (on_rt_rq(rt_se))
> __dequeue_rt_entity(rt_se, flags);
> }
>
> - dequeue_top_rt_rq(rt_rq_of_se(back), rt_nr_running);
> + dequeue_top_rt_rq(rt_rq_of_se(root), rt_nr_running);
> }
Urgh, please don't do this. The whole thing is super fragile. Creating
these abstractions makes it appear like
for_each_sched_rt_entity_reverse() is somehow a sane thing to do. Aside
from the name being insanely long, the whole thing makes no sense
what-so-ever unless you first went and did the normal iteration and set
the back pointers.
It's called back for a reason, it walks back the path it first walked.
Normals and unambiguous iteration is up the tree, towards the root,
walking back down is not.
prev parent reply other threads:[~2023-10-03 10:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-03 5:03 [PATCH v4] sched/rt: move back to RT_GROUP_SCHED and rename it child Yajun Deng
2023-10-03 9:51 ` Ingo Molnar
2023-10-03 14:55 ` Yajun Deng
2023-10-03 16:37 ` Peter Zijlstra
2023-10-04 15:35 ` Yajun Deng
2023-10-03 10:36 ` Peter Zijlstra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231003103639.GD1539@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=oliver.sang@intel.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yajun.deng@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox