mm: oom_kill: reap memory of a task that receives SIGKILL

Free the pages parallely for a task that receives SIGKILL using the
oom_reaper. This freeing of pages will help to give the pages to buddy
system well advance.
This reaps for the process which received SIGKILL through
either sys_kill from user or kill_pid from kernel and that sending
process has CAP_KILL capability.
Also sysctl interface, reap_mem_on_sigkill, is added to turn on/off this
feature.

Change-Id: I21adb95de5e380a80d7eb0b87d9b5b553f52e28a
Signed-off-by: Charan Teja Reddy <[email protected]>
[[email protected]: Fix merge conflicts]
Signed-off-by: Swathi Sridhar <[email protected]>
[[email protected]: Fix merge conflicts]
Signed-off-by: Isaac J. Manjarres <[email protected]>
This commit is contained in:
Charan Teja Reddy 2018-05-01 20:20:20 +05:30 • committed by Isaac J. Manjarres
commit 372242b532
5 changed files with 74 additions and 9 deletions

View file

@ -46,6 +46,7 @@
#include <linux/livepatch.h>
#include <linux/cgroup.h>
#include <linux/audit.h>
#include <linux/oom.h>
#define CREATE_TRACE_POINTS
#include <trace/events/signal.h>
@ -1404,8 +1405,11 @@ 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 (capable(CAP_KILL) && sig == SIGKILL)
add_to_oom_reaper(p);
}
return ret;
}