提交 0687aa19 编写于 作者: W Weilong chen 提交者: Xie XiuQi

kernel:mm: Support disable oom-killer and report oom events

ascend inclusion
category: feature
bugzilla: NA
CVE: NA

-------------------

Aascend support disable oom-killer and report oom events to bbox.
Signed-off-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZhou Guanghui <zhouguanghui1@huawei.com>
Signed-off-by: NChen Jun <chenjin102@huawei.com>
Signed-off-by: NLijun Fang <fanglijun3@huawei.com>
Reviewed-by: NLi Zefan <lizefan@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 30c9ba21
......@@ -117,4 +117,18 @@ extern struct task_struct *find_lock_task_mm(struct task_struct *p);
extern int sysctl_oom_dump_tasks;
extern int sysctl_oom_kill_allocating_task;
extern int sysctl_panic_on_oom;
#ifdef CONFIG_ARCH_ASCEND
extern int sysctl_enable_oom_killer;
extern int register_hisi_oom_notifier(struct notifier_block *nb);
extern int hisi_oom_notifier_call(unsigned long val, void *v);
extern int unregister_hisi_oom_notifier(struct notifier_block *nb);
#else
#define sysctl_enable_oom_killer 1
#define hisi_oom_notifier_call(val, p) ({NOTIFY_DONE; })
#endif
#endif /* _INCLUDE_LINUX_OOM_H */
......@@ -1264,6 +1264,17 @@ static struct ctl_table vm_table[] = {
.extra1 = &zero,
.extra2 = &two,
},
#ifdef CONFIG_ARCH_ASCEND
{
.procname = "enable_oom_killer",
.data = &sysctl_enable_oom_killer,
.maxlen = sizeof(sysctl_enable_oom_killer),
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
},
#endif
{
.procname = "oom_kill_allocating_task",
.data = &sysctl_oom_kill_allocating_task,
......
......@@ -1047,6 +1047,40 @@ int unregister_oom_notifier(struct notifier_block *nb)
}
EXPORT_SYMBOL_GPL(unregister_oom_notifier);
#ifdef CONFIG_ARCH_ASCEND
int sysctl_enable_oom_killer;
static BLOCKING_NOTIFIER_HEAD(hisi_oom_notify_list);
int register_hisi_oom_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&hisi_oom_notify_list, nb);
}
EXPORT_SYMBOL_GPL(register_hisi_oom_notifier);
static unsigned long last_jiffies;
int hisi_oom_notifier_call(unsigned long val, void *v)
{
/* Print time interval to 10 seconds */
if (time_after(jiffies, last_jiffies + 10 * HZ)) {
pr_warn("HISI_OOM_NOTIFIER: oom type %lu\n", val);
dump_stack();
show_mem(SHOW_MEM_FILTER_NODES, NULL);
dump_tasks(NULL, 0);
last_jiffies = jiffies;
}
return blocking_notifier_call_chain(&hisi_oom_notify_list, val, v);
}
EXPORT_SYMBOL_GPL(hisi_oom_notifier_call);
int unregister_hisi_oom_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&hisi_oom_notify_list, nb);
}
EXPORT_SYMBOL_GPL(unregister_hisi_oom_notifier);
#endif
/**
* out_of_memory - kill the "best" process when we run out of memory
* @oc: pointer to struct oom_control
......@@ -1064,6 +1098,11 @@ bool out_of_memory(struct oom_control *oc)
if (oom_killer_disabled)
return false;
if (!sysctl_enable_oom_killer) {
hisi_oom_notifier_call(0, NULL);
return false;
}
if (!is_memcg_oom(oc)) {
blocking_notifier_call_chain(&oom_notify_list, 0, &freed);
if (freed > 0)
......
......@@ -17,6 +17,7 @@
#include <asm/sections.h>
#include <linux/uaccess.h>
#include <linux/oom.h>
#include "internal.h"
......@@ -726,6 +727,7 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
if (percpu_counter_read_positive(&vm_committed_as) < allowed)
return 0;
error:
hisi_oom_notifier_call(1, NULL);
vm_unacct_memory(pages);
return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册