Loading include/linux/oom.h +11 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,17 @@ extern void oom_killer_enable(void); extern struct task_struct *find_lock_task_mm(struct task_struct *p); #ifdef CONFIG_HAVE_USERSPACE_LOW_MEMORY_KILLER extern bool should_ulmk_retry(void); extern void ulmk_update_last_kill(void); #else static inline bool should_ulmk_retry(void) { return false; } static inline void ulmk_update_last_kill(void) {} #endif /* sysctls */ extern int sysctl_oom_dump_tasks; extern int sysctl_oom_kill_allocating_task; Loading kernel/signal.c +3 −1 Original line number Diff line number Diff line Loading @@ -1407,8 +1407,10 @@ int group_send_sig_info(int sig, struct kernel_siginfo *info, if (!ret && sig) { ret = do_send_sig_info(sig, info, p, type); if (capable(CAP_KILL) && sig == SIGKILL) if (capable(CAP_KILL) && sig == SIGKILL) { add_to_oom_reaper(p); ulmk_update_last_kill(); } } return ret; Loading mm/Kconfig +11 −0 Original line number Diff line number Diff line Loading @@ -759,6 +759,17 @@ config PERCPU_STATS information includes global and per chunk statistics, which can be used to help understand percpu memory usage. config HAVE_USERSPACE_LOW_MEMORY_KILLER bool "Have userspace low memory killer" default n help The page allocator cannot directly call into a userspace low memory killer as it can call into the OOM killer. Therefore, add a timeout mechanism to give the userspace low memory killer a chance to run. config GUP_BENCHMARK bool "Enable infrastructure for get_user_pages_fast() benchmarking" help Loading mm/Kconfig.debug +8 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,14 @@ config SLUB_DEBUG_PANIC_ON investigating the root cause which may be rooted within cache or memory. config DEBUG_PANIC_ON_OOM bool "Enable to Panic on OOM detection" help Android primarily uses an alternative mechanism to detect low memory situations and kill processes as required. The kernel oom-killer can mask problems with this feature, which may be undesireable in a debug environment. config DEBUG_PAGEALLOC_ENABLE_DEFAULT bool "Enable debug page memory allocations by default?" depends on DEBUG_PAGEALLOC Loading mm/oom_kill.c +24 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ #define CREATE_TRACE_POINTS #include <trace/events/oom.h> int sysctl_panic_on_oom; int sysctl_panic_on_oom = IS_ENABLED(CONFIG_DEBUG_PANIC_ON_OOM) ? 2 : 0; int sysctl_oom_kill_allocating_task; int sysctl_oom_dump_tasks = 1; int sysctl_reap_mem_on_sigkill; Loading @@ -72,6 +73,28 @@ static inline bool is_memcg_oom(struct oom_control *oc) return oc->memcg != NULL; } /* * If ULMK has killed a process recently, * we are making progress. */ #ifdef CONFIG_HAVE_USERSPACE_LOW_MEMORY_KILLER static atomic64_t ulmk_kill_jiffies = ATOMIC64_INIT(INITIAL_JIFFIES); bool should_ulmk_retry(void) { unsigned long j = atomic64_read(&ulmk_kill_jiffies); return time_before(jiffies, j + 2 * HZ); } void ulmk_update_last_kill(void) { atomic64_set(&ulmk_kill_jiffies, jiffies); } #endif #ifdef CONFIG_NUMA /** * oom_cpuset_eligible() - check task eligiblity for kill Loading Loading
include/linux/oom.h +11 −0 Original line number Diff line number Diff line Loading @@ -122,6 +122,17 @@ extern void oom_killer_enable(void); extern struct task_struct *find_lock_task_mm(struct task_struct *p); #ifdef CONFIG_HAVE_USERSPACE_LOW_MEMORY_KILLER extern bool should_ulmk_retry(void); extern void ulmk_update_last_kill(void); #else static inline bool should_ulmk_retry(void) { return false; } static inline void ulmk_update_last_kill(void) {} #endif /* sysctls */ extern int sysctl_oom_dump_tasks; extern int sysctl_oom_kill_allocating_task; Loading
kernel/signal.c +3 −1 Original line number Diff line number Diff line Loading @@ -1407,8 +1407,10 @@ int group_send_sig_info(int sig, struct kernel_siginfo *info, if (!ret && sig) { ret = do_send_sig_info(sig, info, p, type); if (capable(CAP_KILL) && sig == SIGKILL) if (capable(CAP_KILL) && sig == SIGKILL) { add_to_oom_reaper(p); ulmk_update_last_kill(); } } return ret; Loading
mm/Kconfig +11 −0 Original line number Diff line number Diff line Loading @@ -759,6 +759,17 @@ config PERCPU_STATS information includes global and per chunk statistics, which can be used to help understand percpu memory usage. config HAVE_USERSPACE_LOW_MEMORY_KILLER bool "Have userspace low memory killer" default n help The page allocator cannot directly call into a userspace low memory killer as it can call into the OOM killer. Therefore, add a timeout mechanism to give the userspace low memory killer a chance to run. config GUP_BENCHMARK bool "Enable infrastructure for get_user_pages_fast() benchmarking" help Loading
mm/Kconfig.debug +8 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,14 @@ config SLUB_DEBUG_PANIC_ON investigating the root cause which may be rooted within cache or memory. config DEBUG_PANIC_ON_OOM bool "Enable to Panic on OOM detection" help Android primarily uses an alternative mechanism to detect low memory situations and kill processes as required. The kernel oom-killer can mask problems with this feature, which may be undesireable in a debug environment. config DEBUG_PAGEALLOC_ENABLE_DEFAULT bool "Enable debug page memory allocations by default?" depends on DEBUG_PAGEALLOC Loading
mm/oom_kill.c +24 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,8 @@ #define CREATE_TRACE_POINTS #include <trace/events/oom.h> int sysctl_panic_on_oom; int sysctl_panic_on_oom = IS_ENABLED(CONFIG_DEBUG_PANIC_ON_OOM) ? 2 : 0; int sysctl_oom_kill_allocating_task; int sysctl_oom_dump_tasks = 1; int sysctl_reap_mem_on_sigkill; Loading @@ -72,6 +73,28 @@ static inline bool is_memcg_oom(struct oom_control *oc) return oc->memcg != NULL; } /* * If ULMK has killed a process recently, * we are making progress. */ #ifdef CONFIG_HAVE_USERSPACE_LOW_MEMORY_KILLER static atomic64_t ulmk_kill_jiffies = ATOMIC64_INIT(INITIAL_JIFFIES); bool should_ulmk_retry(void) { unsigned long j = atomic64_read(&ulmk_kill_jiffies); return time_before(jiffies, j + 2 * HZ); } void ulmk_update_last_kill(void) { atomic64_set(&ulmk_kill_jiffies, jiffies); } #endif #ifdef CONFIG_NUMA /** * oom_cpuset_eligible() - check task eligiblity for kill Loading