diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index d9c35eb3066a..ed42c3bad107 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4683,10 +4683,6 @@ (that will set all pages holding image data during restoration read-only). - reap_mem_when_killed_by= - The name of a process, the kill signal from which to a process - make its memory reaped with oom reaper. - retain_initrd [RAM] Keep initrd memory after extraction rfkill.default_state= diff --git a/include/linux/oom.h b/include/linux/oom.h index 106c1142b7bd..b0c1d73aeb58 100644 --- a/include/linux/oom.h +++ b/include/linux/oom.h @@ -129,7 +129,4 @@ extern struct task_struct *find_lock_task_mm(struct task_struct *p); extern int sysctl_oom_dump_tasks; extern int sysctl_oom_kill_allocating_task; extern int sysctl_panic_on_oom; - -/* calls for LMK reaper */ -extern void add_to_oom_reaper(struct task_struct *p); #endif /* _INCLUDE_LINUX_OOM_H */ diff --git a/kernel/signal.c b/kernel/signal.c index 0b0831d8b12c..2a1e8476cca0 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -46,7 +46,6 @@ #include #include #include -#include #define CREATE_TRACE_POINTS #include @@ -67,18 +66,6 @@ static struct kmem_cache *sigqueue_cachep; int print_fatal_signals __read_mostly; -static char reaper_comm[TASK_COMM_LEN]; - -static __init int setup_mem_reap(char *str) -{ - if (!str) - return 0; - strlcpy(reaper_comm, str, TASK_COMM_LEN); - - return 1; -} -__setup("reap_mem_when_killed_by=", setup_mem_reap); - static void __user *sig_handler(struct task_struct *t, int sig) { return t->sighand->action[sig - 1].sa.sa_handler; @@ -1426,12 +1413,8 @@ int group_send_sig_info(int sig, struct kernel_siginfo *info, ret = check_kill_permission(sig, info, p); rcu_read_unlock(); - if (!ret && sig) { + if (!ret && sig) ret = do_send_sig_info(sig, info, p, type); - if (!ret && sig == SIGKILL && - !strcmp(current->comm, reaper_comm)) - add_to_oom_reaper(p); - } return ret; } diff --git a/mm/oom_kill.c b/mm/oom_kill.c index acf064f3fc4e..e376f72d0d9a 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -724,20 +724,6 @@ static inline void wake_oom_reaper(struct task_struct *tsk) } #endif /* CONFIG_MMU */ -/** - * tsk->mm has to be non NULL and caller has to guarantee it is stable (either - * under task_lock or operate on the current). - */ -static void __mark_oom_victim(struct task_struct *tsk) -{ - struct mm_struct *mm = tsk->mm; - - if (!cmpxchg(&tsk->signal->oom_mm, NULL, mm)) { - mmgrab(tsk->signal->oom_mm); - set_bit(MMF_OOM_VICTIM, &mm->flags); - } -} - /** * mark_oom_victim - mark the given task as OOM victim * @tsk: task to mark @@ -750,13 +736,18 @@ static void __mark_oom_victim(struct task_struct *tsk) */ static void mark_oom_victim(struct task_struct *tsk) { + struct mm_struct *mm = tsk->mm; + WARN_ON(oom_killer_disabled); /* OOM killer might race with memcg OOM */ if (test_and_set_tsk_thread_flag(tsk, TIF_MEMDIE)) return; /* oom_mm is bound to the signal struct life time. */ - __mark_oom_victim(tsk); + if (!cmpxchg(&tsk->signal->oom_mm, NULL, mm)) { + mmgrab(tsk->signal->oom_mm); + set_bit(MMF_OOM_VICTIM, &mm->flags); + } /* * Make sure that the task is woken up from uninterruptible sleep @@ -1194,18 +1185,3 @@ void pagefault_out_of_memory(void) out_of_memory(&oc); mutex_unlock(&oom_lock); } - -void add_to_oom_reaper(struct task_struct *p) -{ - p = find_lock_task_mm(p); - if (!p) - return; - - get_task_struct(p); - if (task_will_free_mem(p)) { - __mark_oom_victim(p); - wake_oom_reaper(p); - } - task_unlock(p); - put_task_struct(p); -}