Skip to content

Commit

Permalink
Revert "mm: oom_kill: reap memory of a task that receives SIGKILL"
Browse files Browse the repository at this point in the history
This reverts commit f9920cf.

Change-Id: I19ec43024ccfb06b27a1f3a63391c423dcbd8f22
  • Loading branch information
kailashrs authored and PainKiller3 committed Mar 17, 2021
1 parent 7d20453 commit 53ec235
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 71 deletions.
19 changes: 0 additions & 19 deletions Documentation/sysctl/vm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Currently, these files are in /proc/sys/vm:
- nr_trim_pages (only if CONFIG_MMU=n)
- numa_zonelist_order
- oom_dump_tasks
- reap_mem_on_sigkill
- oom_kill_allocating_task
- overcommit_kbytes
- overcommit_memory
Expand Down Expand Up @@ -636,24 +635,6 @@ The default value is 1 (enabled).

==============================================================

reap_mem_on_sigkill

This enables or disables the memory reaping for a SIGKILL received
process and that the sending process must have the CAP_KILL capabilities.

If this is set to 1, when a process receives SIGKILL from a process
that has the capability, CAP_KILL, the process is added into the oom_reaper
queue which can be picked up by the oom_reaper thread to reap the memory of
that process. This reaps for the process which received SIGKILL through
either sys_kill from user or kill_pid from kernel.

If this is set to 0, we are not reaping memory of a SIGKILL, sent through
either sys_kill from user or kill_pid from kernel, received process.

The default value is 0 (disabled).

==============================================================

oom_kill_allocating_task

This enables or disables killing the OOM-triggering task in
Expand Down
4 changes: 0 additions & 4 deletions include/linux/oom.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,4 @@ extern void wake_oom_reaper(struct task_struct *tsk);
extern int sysctl_oom_dump_tasks;
extern int sysctl_oom_kill_allocating_task;
extern int sysctl_panic_on_oom;
extern int sysctl_reap_mem_on_sigkill;

/* calls for LMK reaper */
extern void add_to_oom_reaper(struct task_struct *p);
#endif /* _INCLUDE_LINUX_OOM_H */
7 changes: 1 addition & 6 deletions kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#include <linux/compat.h>
#include <linux/cn_proc.h>
#include <linux/compiler.h>
#include <linux/oom.h>
#include <linux/capability.h>

#define CREATE_TRACE_POINTS
#include <trace/events/signal.h>
Expand Down Expand Up @@ -1329,11 +1327,8 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
ret = check_kill_permission(sig, info, p);
rcu_read_unlock();

if (!ret && sig) {
if (!ret && sig)
ret = do_send_sig_info(sig, info, p, true);
if (capable(CAP_KILL) && sig == SIGKILL)
add_to_oom_reaper(p);
}

return ret;
}
Expand Down
7 changes: 0 additions & 7 deletions kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1452,13 +1452,6 @@ static struct ctl_table vm_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "reap_mem_on_sigkill",
.data = &sysctl_reap_mem_on_sigkill,
.maxlen = sizeof(sysctl_reap_mem_on_sigkill),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "overcommit_ratio",
.data = &sysctl_overcommit_ratio,
Expand Down
43 changes: 8 additions & 35 deletions mm/oom_kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
int sysctl_panic_on_oom;
int sysctl_oom_kill_allocating_task;
int sysctl_oom_dump_tasks = 1;
int sysctl_reap_mem_on_sigkill;

DEFINE_MUTEX(oom_lock);

Expand Down Expand Up @@ -615,10 +614,8 @@ void wake_oom_reaper(struct task_struct *tsk)
if (!oom_reaper_th)
return;

/*
* Move the lock here to avoid scenario of queuing
* the same task by both OOM killer and any other SIGKILL
* path.
/* move the lock here to avoid scenario of queuing
* the same task by both OOM killer and LMK.
*/
spin_lock(&oom_reaper_lock);

Expand Down Expand Up @@ -654,16 +651,6 @@ static inline void wake_oom_reaper(struct task_struct *tsk)
}
#endif /* CONFIG_MMU */

static void __mark_oom_victim(struct task_struct *tsk)
{
struct mm_struct *mm = tsk->mm;

if (!cmpxchg(&tsk->signal->oom_mm, NULL, mm)) {
atomic_inc(&tsk->signal->oom_mm->mm_count);
set_bit(MMF_OOM_VICTIM, &mm->flags);
}
}

/**
* mark_oom_victim - mark the given task as OOM victim
* @tsk: task to mark
Expand All @@ -676,13 +663,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)) {
atomic_inc(&tsk->signal->oom_mm->mm_count);
set_bit(MMF_OOM_VICTIM, &mm->flags);
}

/*
* Make sure that the task is woken up from uninterruptible sleep
Expand Down Expand Up @@ -1106,22 +1098,3 @@ void pagefault_out_of_memory(void)
out_of_memory(&oc);
mutex_unlock(&oom_lock);
}

void add_to_oom_reaper(struct task_struct *p)
__releases(p->alloc_lock)
{
if (!sysctl_reap_mem_on_sigkill)
return;

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);
}

0 comments on commit 53ec235

Please sign in to comment.