mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 06:14:39 +01:00
get_task_mm: check PF_KTHREAD lockless
Nowadays PF_KTHREAD is sticky and it was never protected by ->alloc_lock. Move the PF_KTHREAD check outside of task_lock() section to make this code more understandable. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Oleg Nesterov <[email protected]> Acked-by: Michal Hocko <[email protected]> Cc: Eric W. Biederman <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
1 parent
d73d003521
commit
8ac5dc6659
1 file changed
+5
-6
+5
-6
@@ -1536,14 +1536,13 @@ struct mm_struct *get_task_mm(struct task_struct *task)
|
||||
{
|
||||
struct mm_struct *mm;
|
||||
|
||||
if (task->flags & PF_KTHREAD)
|
||||
return NULL;
|
||||
|
||||
task_lock(task);
|
||||
mm = task->mm;
|
||||
if (mm) {
|
||||
if (task->flags & PF_KTHREAD)
|
||||
mm = NULL;
|
||||
else
|
||||
mmget(mm);
|
||||
}
|
||||
if (mm)
|
||||
mmget(mm);
|
||||
task_unlock(task);
|
||||
return mm;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user