Skip to content

Commit 455c0e5

Browse files
oleg-nesterovtorvalds
authored andcommitted
oom: check PF_KTHREAD instead of !mm to skip kthreads
select_bad_process() thinks a kernel thread can't have ->mm != NULL, this is not true due to use_mm(). Change the code to check PF_KTHREAD. Reviewed-by: KAMEZAWA Hiroyuki <[email protected]> Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: David Rientjes <[email protected]> Acked-by: KOSAKI Motohiro <[email protected]> Cc: Balbir Singh <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent a9877cc commit 455c0e5

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

mm/oom_kill.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,11 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
256256
for_each_process(p) {
257257
unsigned long points;
258258

259-
/*
260-
* skip kernel threads and tasks which have already released
261-
* their mm.
262-
*/
259+
/* skip tasks that have already released their mm */
263260
if (!p->mm)
264261
continue;
265-
/* skip the init task */
266-
if (is_global_init(p))
262+
/* skip the init task and kthreads */
263+
if (is_global_init(p) || (p->flags & PF_KTHREAD))
267264
continue;
268265
if (mem && !task_in_mem_cgroup(p, mem))
269266
continue;

0 commit comments

Comments
 (0)