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>
This commit is contained in:
Prakash Gupta
2021-04-22 19:33:23 +05:30
parent 83aa0320cf
commit 72488b3be4
3 changed files with 14 additions and 0 deletions

View File

@@ -285,6 +285,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_topology_flags_workfn);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_of_i2c_get_board_info);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_dirty_limits);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_check_panic);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterruptible_tasks);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterruptible_tasks_dn);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_blk_reset);

View File

@@ -10,6 +10,7 @@
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/oom.h>
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
@@ -78,6 +79,9 @@ DECLARE_HOOK(android_vh_mm_dirty_limits,
unsigned long nr_reclaimable, unsigned long pages_dirtied),
TP_ARGS(gdtc, strictlimit, dirty, bg_thresh,
nr_reclaimable, pages_dirtied));
DECLARE_HOOK(android_vh_oom_check_panic,
TP_PROTO(struct oom_control *oc, int *ret),
TP_ARGS(oc, ret));
DECLARE_HOOK(android_vh_save_vmalloc_stack,
TP_PROTO(unsigned long flags, struct vm_struct *vm),
TP_ARGS(flags, vm));

View File

@@ -51,6 +51,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;
@@ -1146,6 +1149,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");
/*