lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231003103639.GD1539@noisy.programming.kicks-ass.net>
Date:   Tue, 3 Oct 2023 12:36:39 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Yajun Deng <yajun.deng@...ux.dev>
Cc:     mingo@...hat.com, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com, vschneid@...hat.com,
        linux-kernel@...r.kernel.org,
        kernel test robot <oliver.sang@...el.com>
Subject: Re: [PATCH v4] sched/rt: move back to RT_GROUP_SCHED and rename it
 child

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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ