ck: mm: restrict the print message frequency further when memcg oom triggers.
fix #31801703 It is because too much memcg oom printed message will trigger the softlockup. In general, we use the same ratelimit oom_rc between system and memcg to limit the print message. But it is more frequent to exceed its limit of the memcg, thus it would will result in oom easily. And A lot of printed information will be outputed. It's likely to trigger softlockup. The patch use different ratelimit to limit the memcg and system oom. And we test the patch using the default value in the memcg, The issue will go. Signed-off-by: zhongjiang-ali <zhongjiang-ali@linux.alibaba.com> Acked-by: Xunlei Pang <xlpang@linux.alibaba.com>
This commit is contained in:
parent
a235a0d6fb
commit
e8e17ddfc2
|
@ -41,6 +41,7 @@ ratelimit_set_flags(struct ratelimit_state *rs, unsigned long flags)
|
|||
}
|
||||
|
||||
extern struct ratelimit_state printk_ratelimit_state;
|
||||
extern struct ratelimit_state oom_memcg_rs;
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
|
||||
|
|
|
@ -2243,6 +2243,20 @@ static struct ctl_table kern_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{
|
||||
.procname = "printk_memcg_oom_interval",
|
||||
.data = &oom_memcg_rs.interval,
|
||||
.maxlen = sizeof(int),
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{
|
||||
.procname = "printk_memcg_oom_burst",
|
||||
.data = &oom_memcg_rs.burst,
|
||||
.maxlen = sizeof(int),
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{
|
||||
.procname = "printk_ratelimit",
|
||||
.data = &printk_ratelimit_state.interval,
|
||||
|
|
|
@ -450,7 +450,7 @@ static void dump_oom_summary(struct oom_control *oc, struct task_struct *victim)
|
|||
from_kuid(&init_user_ns, task_uid(victim)));
|
||||
}
|
||||
|
||||
static void dump_header(struct oom_control *oc, struct task_struct *p)
|
||||
static void dump_header(struct oom_control *oc)
|
||||
{
|
||||
pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%hd\n",
|
||||
current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order,
|
||||
|
@ -459,13 +459,24 @@ static void dump_header(struct oom_control *oc, struct task_struct *p)
|
|||
pr_warn("COMPACTION is disabled!!!\n");
|
||||
|
||||
dump_stack();
|
||||
if (is_memcg_oom(oc))
|
||||
mem_cgroup_print_oom_meminfo(oc->memcg);
|
||||
else {
|
||||
show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask);
|
||||
if (is_dump_unreclaim_slabs())
|
||||
dump_unreclaimable_slab();
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_global_header(struct oom_control *oc, struct task_struct *p)
|
||||
{
|
||||
dump_header(oc);
|
||||
show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask);
|
||||
if (is_dump_unreclaim_slabs())
|
||||
dump_unreclaimable_slab();
|
||||
if (sysctl_oom_dump_tasks)
|
||||
dump_tasks(oc);
|
||||
if (p)
|
||||
dump_oom_summary(oc, p);
|
||||
}
|
||||
|
||||
static void dump_memcg_header(struct oom_control *oc, struct task_struct *p)
|
||||
{
|
||||
dump_header(oc);
|
||||
mem_cgroup_print_oom_meminfo(oc->memcg);
|
||||
if (sysctl_oom_dump_tasks)
|
||||
dump_tasks(oc);
|
||||
if (p)
|
||||
|
@ -978,11 +989,13 @@ static int oom_kill_memcg_member(struct task_struct *task, void *message)
|
|||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_RATELIMIT_STATE(oom_memcg_rs, 10 * HZ, 5);
|
||||
|
||||
static void oom_kill_process(struct oom_control *oc, const char *message)
|
||||
{
|
||||
struct task_struct *victim = oc->chosen;
|
||||
struct mem_cgroup *oom_group;
|
||||
static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL,
|
||||
static DEFINE_RATELIMIT_STATE(oom_global_rs, DEFAULT_RATELIMIT_INTERVAL,
|
||||
DEFAULT_RATELIMIT_BURST);
|
||||
|
||||
/*
|
||||
|
@ -1000,8 +1013,10 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
|
|||
}
|
||||
task_unlock(victim);
|
||||
|
||||
if (__ratelimit(&oom_rs))
|
||||
dump_header(oc, victim);
|
||||
if (is_memcg_oom(oc) && __ratelimit(&oom_memcg_rs))
|
||||
dump_memcg_header(oc, victim);
|
||||
else if (!is_memcg_oom(oc) && __ratelimit(&oom_global_rs))
|
||||
dump_global_header(oc, victim);
|
||||
|
||||
/*
|
||||
* Do we need to kill the entire memory cgroup?
|
||||
|
@ -1042,7 +1057,7 @@ static void check_panic_on_oom(struct oom_control *oc)
|
|||
/* Do not panic for oom kills triggered by sysrq */
|
||||
if (is_sysrq_oom(oc))
|
||||
return;
|
||||
dump_header(oc, NULL);
|
||||
dump_global_header(oc, NULL);
|
||||
panic("Out of memory: %s panic_on_oom is enabled\n",
|
||||
sysctl_panic_on_oom == 2 ? "compulsory" : "system-wide");
|
||||
}
|
||||
|
@ -1127,7 +1142,7 @@ bool out_of_memory(struct oom_control *oc)
|
|||
select_bad_process(oc);
|
||||
/* Found nothing?!?! */
|
||||
if (!oc->chosen) {
|
||||
dump_header(oc, NULL);
|
||||
dump_global_header(oc, NULL);
|
||||
pr_warn("Out of memory and no killable processes...\n");
|
||||
/*
|
||||
* If we got here due to an actual allocation at the
|
||||
|
|
Loading…
Reference in New Issue