Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1815151imm; Wed, 10 Oct 2018 23:39:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV61Enre/5RG67tNCbICS7kfJsANpjahlQj/P0MlAORFjbAyu9dzDJSj1zKKsLY4vxDApwpBi X-Received: by 2002:a63:1342:: with SMTP id 2-v6mr277857pgt.19.1539239990392; Wed, 10 Oct 2018 23:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539239990; cv=none; d=google.com; s=arc-20160816; b=teknx3soiHiuaonwLWA0cHyD89+ih/yq1IFPZRnLOLSQJ4OuWna6KwZt3SCaE1c9Gq wXvCXl42CZdRC90QR+5OfH9S4mnxfujIAWDgvKBT3E/bQhtjZHf14ioeKqom2oloX/oz udjTKqRRZ6+ULI5kSAC8rvG/Pxm0dFqYbIIZ+kiq29igBb5O5l77Y7NtLA/A/WD+RI+X lGm/SlnXnyrrowQYSuyyvEkQHO1RrN9Dh0jt/qKbZ9b0kkUdQa7jjqDkAFaeVafNmqLc DXS99wFu0IeD9oFF0LrccJ/7FWb28sdhkKpvGJknaMOWh4dw5VmT5YWq3lENonxVBqMO w+8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:date:mime-version:cc:to:from:subject:message-id; bh=B92tmDVLb0NGfvB64Bbd0qu96VRPSUEJMn2ZBykpyqE=; b=lTUUtptTbjlInMbq1aPnQKcRTXT2K0A1kTAa1UKGaEKgS1ztUbYcuT427B0c6hFHHW z+bB+p83o56eqlZ4gquqAt1T0EPKDEU1D+Kl/J7m1XgA/gnZupI5gqo3VIm5KJeVo9ny 13K58XrE8W9amLdvMmmXLacavq5h1Rvm0Cjj4dCanudb0u7O+TY/fYc6jIzFhTYdk5l4 9vlnYy0Pfhx3YJEUTuK2DPCq+ZJGfBJqmyBsR1zp1cqbvEw1YqY1GR4XOR0HMkpJIT8d 3t0E/+9olLELV3gFvtjX4RDiP/2v46Ykvq0Zq9FB2hHCsIC0P4hDp7+JIYMc0dCMUZN2 AEiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37-v6si23965460plv.113.2018.10.10.23.39.35; Wed, 10 Oct 2018 23:39:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727589AbeJKODH (ORCPT + 99 others); Thu, 11 Oct 2018 10:03:07 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:25663 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726656AbeJKODH (ORCPT ); Thu, 11 Oct 2018 10:03:07 -0400 Received: from fsav305.sakura.ne.jp (fsav305.sakura.ne.jp [153.120.85.136]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w9B6b91H044193; Thu, 11 Oct 2018 15:37:09 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav305.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav305.sakura.ne.jp); Thu, 11 Oct 2018 15:37:09 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav305.sakura.ne.jp) Received: from www262.sakura.ne.jp (localhost [127.0.0.1]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w9B6b9Y0044189; Thu, 11 Oct 2018 15:37:09 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: (from i-love@localhost) by www262.sakura.ne.jp (8.15.2/8.15.2/Submit) id w9B6b9eH044188; Thu, 11 Oct 2018 15:37:09 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Message-Id: <201810110637.w9B6b9eH044188@www262.sakura.ne.jp> X-Authentication-Warning: www262.sakura.ne.jp: i-love set sender to penguin-kernel@i-love.sakura.ne.jp using -f Subject: Re: [RFC PATCH] memcg, oom: throttle =?ISO-2022-JP?B?ZHVtcF9oZWFkZXIgZm9y?= =?ISO-2022-JP?B?IG1lbWNnIG9vbXMgd2l0aG91dCBlbGlnaWJsZSB0YXNrcw==?= From: Tetsuo Handa To: Michal Hocko Cc: linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, Michal Hocko , guro@fb.com, hannes@cmpxchg.org, kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org, rientjes@google.com, yang.s@alibaba-inc.com MIME-Version: 1.0 Date: Thu, 11 Oct 2018 15:37:09 +0900 References: <000000000000dc48d40577d4a587@google.com> <20181010151135.25766-1-mhocko@kernel.org> In-Reply-To: <20181010151135.25766-1-mhocko@kernel.org> Content-Type: text/plain; charset="ISO-2022-JP" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michal Hocko wrote: > Once we are here, make sure that the reason to trigger the OOM is > printed without ratelimiting because this is really valuable to > debug what happened. Here is my version. From 0c9ab34fd01837d4c85794042ecb9e922c9eed5a Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Thu, 11 Oct 2018 15:27:42 +0900 Subject: [PATCH] mm: memcontrol: Don't flood OOM messages with no eligible task. syzbot is hitting RCU stall at shmem_fault() [1]. This is because memcg-OOM events with no eligible task (current thread is marked as OOM-unkillable) continued calling dump_header() from out_of_memory() enabled by commit 3100dab2aa09dc6e ("mm: memcontrol: print proper OOM header when no eligible victim left."). Let's make sure that next dump_header() waits for at least 60 seconds from previous "Out of memory and no killable processes..." message, if current thread already reported it. This change allows current thread to complete memory allocation requests for doing recovery operation, and also allows us to know whether the current thread is doing recovery operation. [1] https://syzkaller.appspot.com/bug?id=4ae3fff7fcf4c33a47c1192d2d62d2e03efffa64 Signed-off-by: Tetsuo Handa Reported-by: syzbot Cc: Johannes Weiner Cc: Michal Hocko --- include/linux/sched.h | 1 + mm/oom_kill.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 977cb57..701cf3c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -723,6 +723,7 @@ struct task_struct { #endif #ifdef CONFIG_MEMCG unsigned in_user_fault:1; + unsigned memcg_oom_no_eligible_warned:1; #ifdef CONFIG_MEMCG_KMEM unsigned memcg_kmem_skip_account:1; #endif diff --git a/mm/oom_kill.c b/mm/oom_kill.c index f10aa53..f954d99 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1106,6 +1106,21 @@ bool out_of_memory(struct oom_control *oc) select_bad_process(oc); /* Found nothing?!?! */ if (!oc->chosen) { +#ifdef CONFIG_MEMCG + /* + * Don't flood with dump_header() if already reported, in case + * current->signal->oom_score_adj == OOM_SCORE_ADJ_MIN. Maybe + * this variable should be per "struct mem_cgroup". But since + * we can't prove that multiple concurrent memcg OOM without + * eligible task won't cause flooding, choose global variable + * for safety. + */ + static u64 last_warned; + + if (is_memcg_oom(oc) && current->memcg_oom_no_eligible_warned + && time_before64(get_jiffies_64(), last_warned + 60 * HZ)) + return false; +#endif dump_header(oc, NULL); pr_warn("Out of memory and no killable processes...\n"); /* @@ -1115,6 +1130,14 @@ bool out_of_memory(struct oom_control *oc) */ if (!is_sysrq_oom(oc) && !is_memcg_oom(oc)) panic("System is deadlocked on memory\n"); +#ifdef CONFIG_MEMCG + if (is_memcg_oom(oc)) { + last_warned = get_jiffies_64(); + current->memcg_oom_no_eligible_warned = 1; + } + } else if (is_memcg_oom(oc)) { + current->memcg_oom_no_eligible_warned = 0; +#endif } if (oc->chosen && oc->chosen != (void *)-1UL) oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" : -- 1.8.3.1