Skip to content

Commit dc3f21e

Browse files
rientjestorvalds
authored andcommitted
mm, oom: introduce independent oom killer ratelimit state
printk_ratelimit() uses the global ratelimit state for all printks. The oom killer should not be subjected to this state just because another subsystem or driver may be flooding the kernel log. This patch introduces printk ratelimiting specifically for the oom killer. Signed-off-by: David Rientjes <[email protected]> Acked-by: KOSAKI Motohiro <[email protected]> Reviewed-by: KAMEZAWA Hiroyuki <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8447d95 commit dc3f21e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mm/oom_kill.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/ptrace.h>
3535
#include <linux/freezer.h>
3636
#include <linux/ftrace.h>
37+
#include <linux/ratelimit.h>
3738

3839
#define CREATE_TRACE_POINTS
3940
#include <trace/events/oom.h>
@@ -444,6 +445,8 @@ static void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
444445
struct task_struct *t = p;
445446
struct mm_struct *mm;
446447
unsigned int victim_points = 0;
448+
static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL,
449+
DEFAULT_RATELIMIT_BURST);
447450

448451
/*
449452
* If the task is already exiting, don't alarm the sysadmin or kill
@@ -454,7 +457,7 @@ static void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
454457
return;
455458
}
456459

457-
if (printk_ratelimit())
460+
if (__ratelimit(&oom_rs))
458461
dump_header(p, gfp_mask, order, memcg, nodemask);
459462

460463
task_lock(p);

0 commit comments

Comments
 (0)