Commit dc3f21ea authored by David Rientjes's avatar David Rientjes Committed by Linus Torvalds

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: default avatarDavid Rientjes <rientjes@google.com>
Acked-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8447d950
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/ftrace.h> #include <linux/ftrace.h>
#include <linux/ratelimit.h>
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/oom.h> #include <trace/events/oom.h>
...@@ -444,6 +445,8 @@ static void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order, ...@@ -444,6 +445,8 @@ static void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
struct task_struct *t = p; struct task_struct *t = p;
struct mm_struct *mm; struct mm_struct *mm;
unsigned int victim_points = 0; unsigned int victim_points = 0;
static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL,
DEFAULT_RATELIMIT_BURST);
/* /*
* If the task is already exiting, don't alarm the sysadmin or kill * 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, ...@@ -454,7 +457,7 @@ static void oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
return; return;
} }
if (printk_ratelimit()) if (__ratelimit(&oom_rs))
dump_header(p, gfp_mask, order, memcg, nodemask); dump_header(p, gfp_mask, order, memcg, nodemask);
task_lock(p); task_lock(p);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment