Re: [PATCH] freezer,sched: Rewrite core freezer logic

From: Peter Zijlstra
Date: Fri Jun 11 2021 - 04:48:21 EST


On Fri, Jun 11, 2021 at 10:45:00AM +0200, Peter Zijlstra wrote:
> @@ -52,41 +52,67 @@ bool freezing_slow_path(struct task_stru
> }
> EXPORT_SYMBOL(freezing_slow_path);
>
> +/* Recursion relies on tail-call optimization to not blow away the stack */
> +static bool __frozen(struct task_struct *p)
> +{
> + if (p->state == TASK_FROZEN)
> + return true;
> +
> + /*
> + * If stuck in TRACED, and the ptracer is FROZEN, we're frozen too.
> + */
> + if (task_is_traced(p))
> + return frozen(rcu_dereference(p->parent));
> +
> + /*
> + * If stuck in STOPPED and the parent is FROZEN, we're frozen too.
> + */
> + if (task_is_stopped(p))
> + return frozen(rcu_dereference(p->real_parent));
> +
> + return false;
> +}
> +
> +bool frozen(struct task_struct *p)
> +{
> + bool ret;
> +
> + rcu_read_lock();
> + ret = __frozen(p);
> + rcu_read_unlock();
> +
> + return ret;
> +}

Oleg, this bit in particular we'd like some feedback on, if possible.

Thanks!