TIF_MEMDIE usage fixlet
Subsystems (2)
cover TIF_MEMDIE usage fixlet
Hi,
while I was looking to move TIF_MEMDIE out of the thread info for other purpose I have noticed these two usages which are not correct. I do not think any of them warrant a stable backport because it is highly unlikely they would ever hit but it is better to have them fixed.
I would route them via Andrew unless anybody has anything against.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/2 freezer, oom: check TIF_MEMDIE on the correct task
From: Michal Hocko <[email protected]>
freezing_slow_path is checking TIF_MEMDIE to skip OOM killed tasks. It is, however, checking the flag on the current task rather than the given one. This is really confusing because freezing() can be called also on !current tasks. It would end up working correctly for its main purpose because __refrigerator will be always called on the current task so the oom victim will never get frozen. But it could lead to surprising results when a task which is freezing a cgroup got oom killed because only part of the cgroup would get frozen. This is highly unlikely but worth fixing as the resulting code would be more clear anyway.
--- kernel/freezer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/freezer.c +1 -1
@@ -42,7 +42,7 @@ bool freezing_slow_path(struct task_struct *p)if (p->flags & (PF_NOFREEZE |PF_SUSPEND_TASK ))return false; -if (test_thread_flag (TIF_MEMDIE )) +if (test_tsk_thread_flag (p,TIF_MEMDIE ))return false;if (pm_nosig_freezing ||cgroup_freezing (p))
Signature · 7 lines
2.8.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Rafael J. Wysocki
maintainerRe: [PATCH 1/2] freezer, oom: check TIF_MEMDIE on the correct task
Quoted 12 lines · Michal Hocko
From: Michal Hocko <[email protected]>
freezing_slow_pathis checkingTIF_MEMDIEto skip OOM killed tasks. It is, however, checking the flag on the current task rather than the given one. This is really confusing becausefreezing()can be called also on !current tasks. It would end up working correctly for its main purpose because__refrigeratorwill be always called on the current task so the oom victim will never get frozen. But it could lead to surprising results when a task which is freezing a cgroup got oom killed because only part of the cgroup would get frozen. This is highly unlikely but worth fixing as the resulting code would be more clear anyway.
Quoted 1 line
Signed-off-by Michal Hocko <[email protected]>
Looks reasonable to me, so ACK.
Quoted 9 lines
--- kernel/freezer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/freezer.c +0
-0
kernel/freezer.c bool freezing_slow_path(struct task_struct *p)
Quoted 9 lines
kernel/freezer.c +1
-2@@ -42,7 +42,7 @@ bool freezing_slow_path(struct task_struct *p)if (p->flags & (PF_NOFREEZE |PF_SUSPEND_TASK ))return false; -if (test_thread_flag (TIF_MEMDIE )) +if (test_tsk_thread_flag (p,TIF_MEMDIE ))return false;if (pm_nosig_freezing ||cgroup_freezing (p)) --
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/2 cpuset, mm: fix TIF_MEMDIE check in cpuset_change_task_nodemask
In reply to Michal HockoFrom: Michal Hocko <[email protected]>
c0ff7453bb5c ("cpuset,mm: fix no node to alloc memory when changing cpuset's mems") has added TIF_MEMDIE and PF_EXITING check but it is checking the flag on the current task rather than the given one. This doesn't make much sense and it is actually wrong. If the current task which updates the nodemask of a cpuset got killed by the OOM killer then a part of the cpuset cgroup processes would have incompatible nodemask which is surprising to say the least.
The comment suggests the intention was to skip oom victim or an exiting task so we should be checking the given task. But even then it would be layering violation becuase it is the memory allocator to interpret the TIF_MEMDIE meaning. Simply drop both checks. All tasks in the cpuset should simply follow the same mask.
--- kernel/cpuset.c | 9 --------- 1 file changed, 9 deletions(-)
kernel/cpuset.c +0 -9
@@ -1034,15 +1034,6 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk, {bool need_loop; -/* -* Allow tasks that have access to memory reserves because they have -* been OOM killed to get memory anywhere. -*/ -if (unlikely (test_thread_flag (TIF_MEMDIE ))) -return ; -if (current->flags &PF_EXITING )/* Let dying task have memory */ -return ; -task_lock (tsk);/* * Determine if a loop is necessary if another thread is doing
Signature · 7 lines
2.8.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>