All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Chen Ridong <chenridong@huaweicloud.com>
Cc: Michal Koutn?? <mkoutny@suse.com>,
	rafael@kernel.org, pavel@kernel.org, timvp@google.com,
	tj@kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, lujialin4@huawei.com,
	chenridong@huawei.com
Subject: Re: [PATCH next] sched,freezer: prevent tasks from escaping being frozen
Date: Fri, 4 Jul 2025 09:57:18 +0200	[thread overview]
Message-ID: <20250704075718.GA2001818@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <8dae8006-e63d-467f-bb7c-e8470878e534@huaweicloud.com>

On Fri, Jul 04, 2025 at 11:11:52AM +0800, Chen Ridong wrote:

Your patches are mangled; please educate your MUA.

> --- a/kernel/freezer.c
> +++ b/kernel/freezer.c
> @@ -71,19 +71,20 @@ bool __refrigerator(bool check_kthr_stop)
>         for (;;) {
>                 bool freeze;
> 
> -               raw_spin_lock_irq(&current->pi_lock);
> -               WRITE_ONCE(current->__state, TASK_FROZEN);
> -               /* unstale saved_state so that __thaw_task() will wake
> us up */
> -               current->saved_state = TASK_RUNNING;
> -               raw_spin_unlock_irq(&current->pi_lock);
> -
>                 spin_lock_irq(&freezer_lock);
> -               freeze = freezing(current) && !(check_kthr_stop &&
> kthread_should_stop());
> +               freeze = (freezing(current) || !cgroup_thawed(current))
> +                        && !(check_kthr_stop && kthread_should_stop());

This makes no sense to me; why can't this stay in cgroup_freezing()?

Also, can someone please fix that broken comment style there.

>                 spin_unlock_irq(&freezer_lock);
> 
>                 if (!freeze)
>                         break;
> 
> +               raw_spin_lock_irq(&current->pi_lock);
> +               WRITE_ONCE(current->__state, TASK_FROZEN);
> +               /* unstale saved_state so that __thaw_task() will wake
> us up */
> +               current->saved_state = TASK_RUNNING;
> +               raw_spin_unlock_irq(&current->pi_lock);
> +

And I'm not quite sure I understand this hunk either. If we bail out,
current->__state is reset to TASK_RUNNING, so what's the problem?

  reply	other threads:[~2025-07-04  7:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03 13:34 [PATCH next] sched,freezer: prevent tasks from escaping being frozen Chen Ridong
2025-07-03 17:01 ` Michal Koutný
2025-07-04  3:02   ` Chen Ridong
2025-07-04  3:11     ` Chen Ridong
2025-07-04  7:57       ` Peter Zijlstra [this message]
2025-07-04 10:25         ` Chen Ridong
2025-07-07  4:02           ` Chen Ridong
2025-07-07 10:10             ` Peter Zijlstra
2025-07-07 11:32               ` Chen Ridong
2025-07-08  7:28                 ` Peter Zijlstra
2025-07-08 15:35                   ` Tim Van Patten
2025-07-10 15:44             ` Michal Koutný
2025-07-11  0:51               ` Chen Ridong
2025-07-07 16:38     ` Michal Koutný
2025-07-08  1:38       ` Chen Ridong

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=20250704075718.GA2001818@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=chenridong@huawei.com \
    --cc=chenridong@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lujialin4@huawei.com \
    --cc=mkoutny@suse.com \
    --cc=pavel@kernel.org \
    --cc=rafael@kernel.org \
    --cc=timvp@google.com \
    --cc=tj@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.