From eac1548df3e64c0fae0c7f6d612a372e6e2e60c5 Mon Sep 17 00:00:00 2001 From: Johannes Weiner Date: Thu, 6 Aug 2020 10:35:02 +0000 Subject: [PATCH] mm/page_alloc.c: ratelimit allocation failure warnings more aggressively mainline inclusion from v5.4-rc6 commit 1be334e5c0886197cc82923ff0ac5836111b7b57 category: feature bugzilla: NA CVE: NA ------------------------------------------------- While investigating a bug related to higher atomic allocation failures, we noticed the failure warnings positively drowning the console, and in our case trigger lockup warnings because of a serial console too slow to handle all that output. But even if we had a faster console, it's unclear what additional information the current level of repetition provides. Allocation failures happen for three reasons: The machine is OOM, the VM is failing to handle reasonable requests, or somebody is making unreasonable requests (and didn't acknowledge their opportunism with __GFP_NOWARN). Having the memory dump, a callstack, and the ratelimit stats on skipped failure warnings should provide enough information to let users/admins/developers know whether something is wrong and point them in the right direction for debugging, bpftracing etc. Limit allocation failure warnings to one spew every ten seconds. Link: http://lkml.kernel.org/r/20191028194906.26899-1-hannes@cmpxchg.org Signed-off-by: Johannes Weiner Acked-by: David Rientjes Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Conflicts: mm/page_alloc.c Signed-off-by: Chen Jun Reviewed-by: Kefeng Wang Signed-off-by: Yang Yingliang --- mm/page_alloc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7a62ddd59bcc..e9ccd9819d16 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3497,10 +3497,6 @@ static inline bool should_suppress_show_mem(void) static void warn_alloc_show_mem(gfp_t gfp_mask, nodemask_t *nodemask) { unsigned int filter = SHOW_MEM_FILTER_NODES; - static DEFINE_RATELIMIT_STATE(show_mem_rs, HZ, 1); - - if (should_suppress_show_mem() || !__ratelimit(&show_mem_rs)) - return; /* * This documents exceptions given to allocations in certain @@ -3521,8 +3517,7 @@ void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...) { struct va_format vaf; va_list args; - static DEFINE_RATELIMIT_STATE(nopage_rs, DEFAULT_RATELIMIT_INTERVAL, - DEFAULT_RATELIMIT_BURST); + static DEFINE_RATELIMIT_STATE(nopage_rs, 10*HZ, 1); if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs)) return; -- GitLab