* [PATCH v3] freezer, sched: report the frozen task stat as 'D'
@ 2024-12-17 0:48 Chen Ridong
2024-12-17 10:53 ` Michal Koutný
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Chen Ridong @ 2024-12-17 0:48 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid, tj, mkoutny, roman.gushchin
Cc: linux-kernel, cgroups, chenridong, wangweiyang2
From: Chen Ridong <chenridong@huawei.com>
Before the commit f5d39b020809 ("freezer,sched: Rewrite core freezer
logic"), the frozen task stat was reported as 'D' in cgroup v1.
However, after rewriting core freezer logic, the frozen task stat is
reported as 'R'. This is confusing, especially when a task with stat of
'S' is frozen.
This can be reproduced as bellow step:
cd /sys/fs/cgroup/freezer/
mkdir test
sleep 1000 &
[1] 739 // task whose stat is 'S'
echo 739 > test/cgroup.procs
echo FROZEN > test/freezer.state
ps -aux | grep 739
root 739 0.1 0.0 8376 1812 pts/0 R 10:56 0:00 sleep 1000
As shown above, a task whose stat is 'S' was changed to 'R' when it was
frozen. To solve this issue, simply maintain the same reported state as
before the rewrite.
Fixes: f5d39b020809 ("freezer,sched: Rewrite core freezer logic")
Signed-off-by: Chen Ridong <chenridong@huawei.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
include/linux/sched.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index d380bffee2ef..fdcb7c75386c 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1630,8 +1630,9 @@ static inline unsigned int __task_state_index(unsigned int tsk_state,
* We're lying here, but rather than expose a completely new task state
* to userspace, we can make this appear as if the task has gone through
* a regular rt_mutex_lock() call.
+ * Report the frozen task uninterruptible.
*/
- if (tsk_state & TASK_RTLOCK_WAIT)
+ if ((tsk_state & TASK_RTLOCK_WAIT) || (tsk_state & TASK_FROZEN))
state = TASK_UNINTERRUPTIBLE;
return fls(state);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] freezer, sched: report the frozen task stat as 'D'
2024-12-17 0:48 [PATCH v3] freezer, sched: report the frozen task stat as 'D' Chen Ridong
@ 2024-12-17 10:53 ` Michal Koutný
2024-12-17 12:04 ` Peter Zijlstra
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michal Koutný @ 2024-12-17 10:53 UTC (permalink / raw)
To: Chen Ridong
Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid, tj, roman.gushchin,
linux-kernel, cgroups, chenridong, wangweiyang2
[-- Attachment #1: Type: text/plain, Size: 220 bytes --]
On Tue, Dec 17, 2024 at 12:48:18AM GMT, Chen Ridong <chenridong@huaweicloud.com> wrote:
> include/linux/sched.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
Acked-by: Michal Koutný <mkoutny@suse.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] freezer, sched: report the frozen task stat as 'D'
2024-12-17 0:48 [PATCH v3] freezer, sched: report the frozen task stat as 'D' Chen Ridong
2024-12-17 10:53 ` Michal Koutný
@ 2024-12-17 12:04 ` Peter Zijlstra
2024-12-17 22:12 ` Roman Gushchin
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2024-12-17 12:04 UTC (permalink / raw)
To: Chen Ridong
Cc: mingo, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt,
bsegall, mgorman, vschneid, tj, mkoutny, roman.gushchin,
linux-kernel, cgroups, chenridong, wangweiyang2
On Tue, Dec 17, 2024 at 12:48:18AM +0000, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> Before the commit f5d39b020809 ("freezer,sched: Rewrite core freezer
> logic"), the frozen task stat was reported as 'D' in cgroup v1.
> However, after rewriting core freezer logic, the frozen task stat is
> reported as 'R'. This is confusing, especially when a task with stat of
> 'S' is frozen.
>
> This can be reproduced as bellow step:
> cd /sys/fs/cgroup/freezer/
> mkdir test
> sleep 1000 &
> [1] 739 // task whose stat is 'S'
> echo 739 > test/cgroup.procs
> echo FROZEN > test/freezer.state
> ps -aux | grep 739
> root 739 0.1 0.0 8376 1812 pts/0 R 10:56 0:00 sleep 1000
>
> As shown above, a task whose stat is 'S' was changed to 'R' when it was
> frozen. To solve this issue, simply maintain the same reported state as
> before the rewrite.
>
> Fixes: f5d39b020809 ("freezer,sched: Rewrite core freezer logic")
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> Acked-by: Tejun Heo <tj@kernel.org>
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] freezer, sched: report the frozen task stat as 'D'
2024-12-17 0:48 [PATCH v3] freezer, sched: report the frozen task stat as 'D' Chen Ridong
2024-12-17 10:53 ` Michal Koutný
2024-12-17 12:04 ` Peter Zijlstra
@ 2024-12-17 22:12 ` Roman Gushchin
2024-12-24 9:47 ` [tip: sched/urgent] " tip-bot2 for Chen Ridong
2024-12-29 9:18 ` [tip: sched/urgent] freezer, sched: Report frozen tasks as 'D' instead of 'R' tip-bot2 for Chen Ridong
4 siblings, 0 replies; 6+ messages in thread
From: Roman Gushchin @ 2024-12-17 22:12 UTC (permalink / raw)
To: Chen Ridong
Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid, tj, mkoutny, linux-kernel,
cgroups, chenridong, wangweiyang2
On Tue, Dec 17, 2024 at 12:48:18AM +0000, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> Before the commit f5d39b020809 ("freezer,sched: Rewrite core freezer
> logic"), the frozen task stat was reported as 'D' in cgroup v1.
> However, after rewriting core freezer logic, the frozen task stat is
> reported as 'R'. This is confusing, especially when a task with stat of
> 'S' is frozen.
>
> This can be reproduced as bellow step:
> cd /sys/fs/cgroup/freezer/
> mkdir test
> sleep 1000 &
> [1] 739 // task whose stat is 'S'
> echo 739 > test/cgroup.procs
> echo FROZEN > test/freezer.state
> ps -aux | grep 739
> root 739 0.1 0.0 8376 1812 pts/0 R 10:56 0:00 sleep 1000
>
> As shown above, a task whose stat is 'S' was changed to 'R' when it was
> frozen. To solve this issue, simply maintain the same reported state as
> before the rewrite.
>
> Fixes: f5d39b020809 ("freezer,sched: Rewrite core freezer logic")
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Roman Gushchin <roman.gushchin@linux.dev>
Thank you!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip: sched/urgent] freezer, sched: report the frozen task stat as 'D'
2024-12-17 0:48 [PATCH v3] freezer, sched: report the frozen task stat as 'D' Chen Ridong
` (2 preceding siblings ...)
2024-12-17 22:12 ` Roman Gushchin
@ 2024-12-24 9:47 ` tip-bot2 for Chen Ridong
2024-12-29 9:18 ` [tip: sched/urgent] freezer, sched: Report frozen tasks as 'D' instead of 'R' tip-bot2 for Chen Ridong
4 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Chen Ridong @ 2024-12-24 9:47 UTC (permalink / raw)
To: linux-tip-commits
Cc: Chen Ridong, Peter Zijlstra (Intel), Tejun Heo, mkoutny, x86,
linux-kernel
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: 2357a7f934ae01985b0b8b70c3ca59ea38b9ed5b
Gitweb: https://git.kernel.org/tip/2357a7f934ae01985b0b8b70c3ca59ea38b9ed5b
Author: Chen Ridong <chenridong@huawei.com>
AuthorDate: Tue, 17 Dec 2024 00:48:18
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 17 Dec 2024 17:47:20 +01:00
freezer, sched: report the frozen task stat as 'D'
Before the commit f5d39b020809 ("freezer,sched: Rewrite core freezer
logic"), the frozen task stat was reported as 'D' in cgroup v1.
However, after rewriting core freezer logic, the frozen task stat is
reported as 'R'. This is confusing, especially when a task with stat of
'S' is frozen.
This can be reproduced as bellow step:
cd /sys/fs/cgroup/freezer/
mkdir test
sleep 1000 &
[1] 739 // task whose stat is 'S'
echo 739 > test/cgroup.procs
echo FROZEN > test/freezer.state
ps -aux | grep 739
root 739 0.1 0.0 8376 1812 pts/0 R 10:56 0:00 sleep 1000
As shown above, a task whose stat is 'S' was changed to 'R' when it was
frozen. To solve this issue, simply maintain the same reported state as
before the rewrite.
Fixes: f5d39b020809 ("freezer,sched: Rewrite core freezer logic")
Signed-off-by: Chen Ridong <chenridong@huawei.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Michal Koutný <mkoutny@suse.com>
Link: https://lore.kernel.org/r/20241217004818.3200515-1-chenridong@huaweicloud.com
---
include/linux/sched.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 66b311f..6c98649 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1637,8 +1637,9 @@ static inline unsigned int __task_state_index(unsigned int tsk_state,
* We're lying here, but rather than expose a completely new task state
* to userspace, we can make this appear as if the task has gone through
* a regular rt_mutex_lock() call.
+ * Report the frozen task uninterruptible.
*/
- if (tsk_state & TASK_RTLOCK_WAIT)
+ if ((tsk_state & TASK_RTLOCK_WAIT) || (tsk_state & TASK_FROZEN))
state = TASK_UNINTERRUPTIBLE;
return fls(state);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [tip: sched/urgent] freezer, sched: Report frozen tasks as 'D' instead of 'R'
2024-12-17 0:48 [PATCH v3] freezer, sched: report the frozen task stat as 'D' Chen Ridong
` (3 preceding siblings ...)
2024-12-24 9:47 ` [tip: sched/urgent] " tip-bot2 for Chen Ridong
@ 2024-12-29 9:18 ` tip-bot2 for Chen Ridong
4 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Chen Ridong @ 2024-12-29 9:18 UTC (permalink / raw)
To: linux-tip-commits
Cc: Chen Ridong, Peter Zijlstra (Intel), Ingo Molnar, Tejun Heo,
mkoutny, x86, linux-kernel
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: f718faf3940e95d5d34af9041f279f598396ab7d
Gitweb: https://git.kernel.org/tip/f718faf3940e95d5d34af9041f279f598396ab7d
Author: Chen Ridong <chenridong@huawei.com>
AuthorDate: Tue, 17 Dec 2024 00:48:18
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Sun, 29 Dec 2024 10:14:20 +01:00
freezer, sched: Report frozen tasks as 'D' instead of 'R'
Before commit:
f5d39b020809 ("freezer,sched: Rewrite core freezer logic")
the frozen task stat was reported as 'D' in cgroup v1.
However, after rewriting the core freezer logic, the frozen task stat is
reported as 'R'. This is confusing, especially when a task with stat of
'S' is frozen.
This bug can be reproduced with these steps:
$ cd /sys/fs/cgroup/freezer/
$ mkdir test
$ sleep 1000 &
[1] 739 // task whose stat is 'S'
$ echo 739 > test/cgroup.procs
$ echo FROZEN > test/freezer.state
$ ps -aux | grep 739
root 739 0.1 0.0 8376 1812 pts/0 R 10:56 0:00 sleep 1000
As shown above, a task whose stat is 'S' was changed to 'R' when it was
frozen.
To solve this regression, simply maintain the same reported state as
before the rewrite.
[ mingo: Enhanced the changelog and comments ]
Fixes: f5d39b020809 ("freezer,sched: Rewrite core freezer logic")
Signed-off-by: Chen Ridong <chenridong@huawei.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Michal Koutný <mkoutny@suse.com>
Link: https://lore.kernel.org/r/20241217004818.3200515-1-chenridong@huaweicloud.com
---
include/linux/sched.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 66b311f..64934e0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1637,8 +1637,9 @@ static inline unsigned int __task_state_index(unsigned int tsk_state,
* We're lying here, but rather than expose a completely new task state
* to userspace, we can make this appear as if the task has gone through
* a regular rt_mutex_lock() call.
+ * Report frozen tasks as uninterruptible.
*/
- if (tsk_state & TASK_RTLOCK_WAIT)
+ if ((tsk_state & TASK_RTLOCK_WAIT) || (tsk_state & TASK_FROZEN))
state = TASK_UNINTERRUPTIBLE;
return fls(state);
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-12-29 9:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-17 0:48 [PATCH v3] freezer, sched: report the frozen task stat as 'D' Chen Ridong
2024-12-17 10:53 ` Michal Koutný
2024-12-17 12:04 ` Peter Zijlstra
2024-12-17 22:12 ` Roman Gushchin
2024-12-24 9:47 ` [tip: sched/urgent] " tip-bot2 for Chen Ridong
2024-12-29 9:18 ` [tip: sched/urgent] freezer, sched: Report frozen tasks as 'D' instead of 'R' tip-bot2 for Chen Ridong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox