mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH PM/for-6.19] freezer: Clarify that only cgroup1 freezer uses PM freezer
@ 2025-10-20 17:55 Tejun Heo
  2025-10-30 19:11 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2025-10-20 17:55 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Qu Wenruo, linux-pm, linux-kernel

cgroup1 freezer piggybacks on the PM freezer, which inadvertently allowed
userspace to produce uninterruptible tasks at will. To avoid the issue,
cgroup2 freezer switched to a separate job control based mechanism. While
this happened a long time ago, the code and comment haven't been updated
making it confusing to people who aren't familiar with the history.

Rename cgroup_freezing() to cgroup1_freezing() and update comments on top of
freezing() and frozen() to clarify that cgroup2 freezer isn't covered by the
PM freezer mechanism.

Signed-off-by: Tejun Heo <tj@kernel.org>
Suggested-by: Qu Wenruo <wqu@suse.com>
---
 include/linux/freezer.h        |   12 ++++++++----
 kernel/cgroup/legacy_freezer.c |    2 +-
 kernel/freezer.c               |    2 +-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index 32884c9721e5..0a8c6c4d1a82 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -22,14 +22,18 @@ extern bool pm_nosig_freezing;		/* PM nosig freezing in effect */
 extern unsigned int freeze_timeout_msecs;
 
 /*
- * Check if a process has been frozen
+ * Check if a process has been frozen for PM or cgroup1 freezer. Note that
+ * cgroup2 freezer uses the job control mechanism and does not interact with
+ * the PM freezer.
  */
 extern bool frozen(struct task_struct *p);
 
 extern bool freezing_slow_path(struct task_struct *p);
 
 /*
- * Check if there is a request to freeze a process
+ * Check if there is a request to freeze a task from PM or cgroup1 freezer.
+ * Note that cgroup2 freezer uses the job control mechanism and does not
+ * interact with the PM freezer.
  */
 static inline bool freezing(struct task_struct *p)
 {
@@ -63,9 +67,9 @@ extern bool freeze_task(struct task_struct *p);
 extern bool set_freezable(void);
 
 #ifdef CONFIG_CGROUP_FREEZER
-extern bool cgroup_freezing(struct task_struct *task);
+extern bool cgroup1_freezing(struct task_struct *task);
 #else /* !CONFIG_CGROUP_FREEZER */
-static inline bool cgroup_freezing(struct task_struct *task)
+static inline bool cgroup1_freezing(struct task_struct *task)
 {
 	return false;
 }
diff --git a/kernel/cgroup/legacy_freezer.c b/kernel/cgroup/legacy_freezer.c
index dd9417425d92..915b02f65980 100644
--- a/kernel/cgroup/legacy_freezer.c
+++ b/kernel/cgroup/legacy_freezer.c
@@ -63,7 +63,7 @@ static struct freezer *parent_freezer(struct freezer *freezer)
 	return css_freezer(freezer->css.parent);
 }
 
-bool cgroup_freezing(struct task_struct *task)
+bool cgroup1_freezing(struct task_struct *task)
 {
 	bool ret;
 
diff --git a/kernel/freezer.c b/kernel/freezer.c
index ddc11a8bd2ea..a76bf957fb32 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -44,7 +44,7 @@ bool freezing_slow_path(struct task_struct *p)
 	if (tsk_is_oom_victim(p))
 		return false;
 
-	if (pm_nosig_freezing || cgroup_freezing(p))
+	if (pm_nosig_freezing || cgroup1_freezing(p))
 		return true;
 
 	if (pm_freezing && !(p->flags & PF_KTHREAD))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH PM/for-6.19] freezer: Clarify that only cgroup1 freezer uses PM freezer
  2025-10-20 17:55 [PATCH PM/for-6.19] freezer: Clarify that only cgroup1 freezer uses PM freezer Tejun Heo
@ 2025-10-30 19:11 ` Rafael J. Wysocki
  2025-11-01  0:48   ` Tejun Heo
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2025-10-30 19:11 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Rafael J. Wysocki, Qu Wenruo, linux-pm, linux-kernel

On Mon, Oct 20, 2025 at 7:55 PM Tejun Heo <tj@kernel.org> wrote:
>
> cgroup1 freezer piggybacks on the PM freezer, which inadvertently allowed
> userspace to produce uninterruptible tasks at will. To avoid the issue,
> cgroup2 freezer switched to a separate job control based mechanism. While
> this happened a long time ago, the code and comment haven't been updated
> making it confusing to people who aren't familiar with the history.
>
> Rename cgroup_freezing() to cgroup1_freezing() and update comments on top of
> freezing() and frozen() to clarify that cgroup2 freezer isn't covered by the
> PM freezer mechanism.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Suggested-by: Qu Wenruo <wqu@suse.com>
> ---
>  include/linux/freezer.h        |   12 ++++++++----
>  kernel/cgroup/legacy_freezer.c |    2 +-
>  kernel/freezer.c               |    2 +-
>  3 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/freezer.h b/include/linux/freezer.h
> index 32884c9721e5..0a8c6c4d1a82 100644
> --- a/include/linux/freezer.h
> +++ b/include/linux/freezer.h
> @@ -22,14 +22,18 @@ extern bool pm_nosig_freezing;              /* PM nosig freezing in effect */
>  extern unsigned int freeze_timeout_msecs;
>
>  /*
> - * Check if a process has been frozen
> + * Check if a process has been frozen for PM or cgroup1 freezer. Note that
> + * cgroup2 freezer uses the job control mechanism and does not interact with
> + * the PM freezer.
>   */
>  extern bool frozen(struct task_struct *p);
>
>  extern bool freezing_slow_path(struct task_struct *p);
>
>  /*
> - * Check if there is a request to freeze a process
> + * Check if there is a request to freeze a task from PM or cgroup1 freezer.
> + * Note that cgroup2 freezer uses the job control mechanism and does not
> + * interact with the PM freezer.
>   */
>  static inline bool freezing(struct task_struct *p)
>  {
> @@ -63,9 +67,9 @@ extern bool freeze_task(struct task_struct *p);
>  extern bool set_freezable(void);
>
>  #ifdef CONFIG_CGROUP_FREEZER
> -extern bool cgroup_freezing(struct task_struct *task);
> +extern bool cgroup1_freezing(struct task_struct *task);
>  #else /* !CONFIG_CGROUP_FREEZER */
> -static inline bool cgroup_freezing(struct task_struct *task)
> +static inline bool cgroup1_freezing(struct task_struct *task)
>  {
>         return false;
>  }
> diff --git a/kernel/cgroup/legacy_freezer.c b/kernel/cgroup/legacy_freezer.c
> index dd9417425d92..915b02f65980 100644
> --- a/kernel/cgroup/legacy_freezer.c
> +++ b/kernel/cgroup/legacy_freezer.c
> @@ -63,7 +63,7 @@ static struct freezer *parent_freezer(struct freezer *freezer)
>         return css_freezer(freezer->css.parent);
>  }
>
> -bool cgroup_freezing(struct task_struct *task)
> +bool cgroup1_freezing(struct task_struct *task)
>  {
>         bool ret;
>
> diff --git a/kernel/freezer.c b/kernel/freezer.c
> index ddc11a8bd2ea..a76bf957fb32 100644
> --- a/kernel/freezer.c
> +++ b/kernel/freezer.c
> @@ -44,7 +44,7 @@ bool freezing_slow_path(struct task_struct *p)
>         if (tsk_is_oom_victim(p))
>                 return false;
>
> -       if (pm_nosig_freezing || cgroup_freezing(p))
> +       if (pm_nosig_freezing || cgroup1_freezing(p))
>                 return true;
>
>         if (pm_freezing && !(p->flags & PF_KTHREAD))

I gather that this is for me to pick up, so applied.

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH PM/for-6.19] freezer: Clarify that only cgroup1 freezer uses PM freezer
  2025-10-30 19:11 ` Rafael J. Wysocki
@ 2025-11-01  0:48   ` Tejun Heo
  0 siblings, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2025-11-01  0:48 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Qu Wenruo, linux-pm, linux-kernel

On Thu, Oct 30, 2025 at 08:11:51PM +0100, Rafael J. Wysocki wrote:
> I gather that this is for me to pick up, so applied.

Right, I should have been clearer. Thanks!

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-01  0:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-20 17:55 [PATCH PM/for-6.19] freezer: Clarify that only cgroup1 freezer uses PM freezer Tejun Heo
2025-10-30 19:11 ` Rafael J. Wysocki
2025-11-01  0:48   ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®