Re: [PATCH v3] mm: memcontrol: Don't flood OOM messages with no eligible task.

From: Sergey Senozhatsky
Date: Wed Oct 17 2018 - 07:17:32 EST


On (10/17/18 12:28), Michal Hocko wrote:
> > Michal proposed ratelimiting dump_header() [2]. But I don't think that
> > that patch is appropriate because that patch does not ratelimit
> >
> > "%s invoked oom-killer: gfp_mask=%#x(%pGg), nodemask=%*pbl, order=%d, oom_score_adj=%hd\n"
> > "Out of memory and no killable processes...\n"
[..]
> > Let's make sure that next dump_header() waits for at least 60 seconds from
> > previous "Out of memory and no killable processes..." message.
>
> Could you explain why this is any better than using a well established
> ratelimit approach?

Tetsuo, let's use a well established rate-limit approach both in
dump_hedaer() and out_of_memory(). I actually was under impression
that Michal added rate-limiting to both of these functions.

The appropriate rate-limit value looks like something that printk()
should know and be able to tell to the rest of the kernel. I don't
think that middle ground will ever be found elsewhere.


printk() knows what consoles are registered, and printk() also knows
(sometimes) what console="..." options the kernel was provided with.
If baud rates ware not provided as console= options, then serial
consoles usually use some default value. We can probably ask consoles.

So *maybe* we can do something like this

//
// WARNING: this is just a sketch. A silly idea.
// I don't know if we can make it usable.
//

---

int printk_ratelimit_interval(void)
{
int ret = DEFAULT_RATELIMIT_INTERVAL;
struct tty_driver *driver = NULL;
speed_t min_baud = MAX_INT;

console_lock();
for_each_console(c) {
speed_t br;

if (!c->device)
continue;
if (!(c->flags & CON_ENABLED))
continue;
if (!c->write)
continue;
driver = c->device(c, index);
if (!driver)
continue;

br = tty_get_baud_rate(tty_driver to tty_struct [???]);
min_baud = min(min_baud, br);
}
console_unlock();

switch (min_baud) {
case 115200:
return ret;

case ...blah blah...:
return ret * 2;

case 9600:
return ret * 4;
}
return ret;
}

---

-ss