The patch titled Subject: mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3 has been added to the -mm tree. Its filename is mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Suren Baghdasaryan <surenb@xxxxxxxxxx> Subject: mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3 - Addressed Eric Biederman's comments from: https://lore.kernel.org/linux-mm/87imd6n0qk.fsf@xxxxxxxxxxxxxxxxxxxxx/ -- renabled oom_adj_lock back to oom_adj_mutex -- renamed MMF_PROC_SHARED into MMF_MULTIPROCESS and fixed its comment - Updated description to reflect the change Link: https://lkml.kernel.org/r/20200902012558.2335613-1-surenb@xxxxxxxxxx Fixes: 44a70adec910 ("mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj") Reported-by: Tim Murray <timmurray@xxxxxxxxxx> Debugged-by: Minchan Kim <minchan@xxxxxxxxxx> Suggested-by: Michal Hocko <mhocko@xxxxxxxxxx> Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx> Cc: Christian Brauner <christian.brauner@xxxxxxxxxx> Cc: Oleg Nesterov <oleg@xxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: Eugene Syromiatnikov <esyr@xxxxxxxxxx> Cc: Christian Kellner <christian@xxxxxxxxxx> Cc: Adrian Reber <areber@xxxxxxxxxx> Cc: Shakeel Butt <shakeelb@xxxxxxxxxx> Cc: Aleksa Sarai <cyphar@xxxxxxxxxx> Cc: Alexey Dobriyan <adobriyan@xxxxxxxxx> Cc: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx> Cc: Alexey Gladkov <gladkov.alexey@xxxxxxxxx> Cc: Michel Lespinasse <walken@xxxxxxxxxx> Cc: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx> Cc: Andrei Vagin <avagin@xxxxxxxxx> Cc: Bernd Edlinger <bernd.edlinger@xxxxxxxxxx> Cc: John Johansen <john.johansen@xxxxxxxxxxxxx> Cc: Yafang Shao <laoar.shao@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/proc/base.c | 6 +++--- include/linux/oom.h | 2 +- include/linux/sched/coredump.h | 2 +- kernel/fork.c | 6 +++--- mm/oom_kill.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) --- a/fs/proc/base.c~mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3 +++ a/fs/proc/base.c @@ -1063,7 +1063,7 @@ static int __set_oom_adj(struct file *fi if (!task) return -ESRCH; - mutex_lock(&oom_adj_lock); + mutex_lock(&oom_adj_mutex); if (legacy) { if (oom_adj < task->signal->oom_score_adj && !capable(CAP_SYS_RESOURCE)) { @@ -1094,7 +1094,7 @@ static int __set_oom_adj(struct file *fi struct task_struct *p = find_lock_task_mm(task); if (p) { - if (test_bit(MMF_PROC_SHARED, &p->mm->flags)) { + if (test_bit(MMF_MULTIPROCESS, &p->mm->flags)) { mm = p->mm; mmgrab(mm); } @@ -1131,7 +1131,7 @@ static int __set_oom_adj(struct file *fi mmdrop(mm); } err_unlock: - mutex_unlock(&oom_adj_lock); + mutex_unlock(&oom_adj_mutex); put_task_struct(task); return err; } --- a/include/linux/oom.h~mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3 +++ a/include/linux/oom.h @@ -55,7 +55,7 @@ struct oom_control { }; extern struct mutex oom_lock; -extern struct mutex oom_adj_lock; +extern struct mutex oom_adj_mutex; static inline void set_current_oom_origin(void) { --- a/include/linux/sched/coredump.h~mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3 +++ a/include/linux/sched/coredump.h @@ -72,7 +72,7 @@ static inline int get_dumpable(struct mm #define MMF_DISABLE_THP 24 /* disable THP for all VMAs */ #define MMF_OOM_VICTIM 25 /* mm is the oom victim */ #define MMF_OOM_REAP_QUEUED 26 /* mm was queued for oom_reaper */ -#define MMF_PROC_SHARED 27 /* mm is shared while sighand is not */ +#define MMF_MULTIPROCESS 27 /* mm is shared between processes */ #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP) #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\ --- a/kernel/fork.c~mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3 +++ a/kernel/fork.c @@ -1819,12 +1819,12 @@ static void copy_oom_score_adj(u64 clone return; /* We need to synchronize with __set_oom_adj */ - mutex_lock(&oom_adj_lock); - set_bit(MMF_PROC_SHARED, &tsk->mm->flags); + mutex_lock(&oom_adj_mutex); + set_bit(MMF_MULTIPROCESS, &tsk->mm->flags); /* Update the values in case they were changed after copy_signal */ tsk->signal->oom_score_adj = current->signal->oom_score_adj; tsk->signal->oom_score_adj_min = current->signal->oom_score_adj_min; - mutex_unlock(&oom_adj_lock); + mutex_unlock(&oom_adj_mutex); } /* --- a/mm/oom_kill.c~mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3 +++ a/mm/oom_kill.c @@ -65,7 +65,7 @@ int sysctl_oom_dump_tasks = 1; */ DEFINE_MUTEX(oom_lock); /* Serializes oom_score_adj and oom_score_adj_min updates */ -DEFINE_MUTEX(oom_adj_lock); +DEFINE_MUTEX(oom_adj_mutex); static inline bool is_memcg_oom(struct oom_control *oc) { _ Patches currently in -mm which might be from surenb@xxxxxxxxxx are mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary.patch mm-oom_adj-dont-loop-through-tasks-in-__set_oom_adj-when-not-necessary-v3.patch