ANDROID: mm, oom: add vendor hook to prevent oom panic

In some cases we would like to bypass oom panic and give the system more
time to cleanup memory. Add vendor hook to allow skipping the oom panic.

Bug: 186875166
Change-Id: I64e74b2c013d6f18d74504777c6559d9ae07e008
Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
Signed-off-by: Sudarshan Rajagopalan <quic_sudaraja@quicinc.com>
This commit is contained in:
Prakash Gupta
2021-04-22 19:33:23 +05:30
committed by Suren Baghdasaryan
parent 24bfd162f9
commit 4d7fc7aaec
3 changed files with 15 additions and 0 deletions

View File

@@ -198,6 +198,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_memory_nx);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_memory_rw);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_module_permit_before_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_module_permit_after_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_check_panic);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_selinux_is_initialized);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_mmap_file);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_file_open);

View File

@@ -9,6 +9,8 @@
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/oom.h>
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
@@ -21,6 +23,9 @@ DECLARE_RESTRICTED_HOOK(android_rvh_set_gfp_zone_flags,
DECLARE_RESTRICTED_HOOK(android_rvh_set_readahead_gfp_mask,
TP_PROTO(gfp_t *flags),
TP_ARGS(flags), 1);
DECLARE_HOOK(android_vh_oom_check_panic,
TP_PROTO(struct oom_control *oc, int *ret),
TP_ARGS(oc, ret));
#endif /* _TRACE_HOOK_MM_H */

View File

@@ -52,6 +52,9 @@
#define CREATE_TRACE_POINTS
#include <trace/events/oom.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/mm.h>
int sysctl_panic_on_oom;
int sysctl_oom_kill_allocating_task;
int sysctl_oom_dump_tasks = 1;
@@ -1103,6 +1106,12 @@ bool out_of_memory(struct oom_control *oc)
select_bad_process(oc);
/* Found nothing?!?! */
if (!oc->chosen) {
int ret = false;
trace_android_vh_oom_check_panic(oc, &ret);
if (ret)
return true;
dump_header(oc, NULL);
pr_warn("Out of memory and no killable processes...\n");
/*