From patchwork Tue Aug 21 16:04:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 10572009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7A22921 for ; Tue, 21 Aug 2018 16:04:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6A352875F for ; Tue, 21 Aug 2018 16:04:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C34E12AAFB; Tue, 21 Aug 2018 16:04:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD29C2AA59 for ; Tue, 21 Aug 2018 16:04:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 828EE6B1F83; Tue, 21 Aug 2018 12:04:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7E1496B1F84; Tue, 21 Aug 2018 12:04:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 678666B1F85; Tue, 21 Aug 2018 12:04:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f71.google.com (mail-yw1-f71.google.com [209.85.161.71]) by kanga.kvack.org (Postfix) with ESMTP id 31BD76B1F83 for ; Tue, 21 Aug 2018 12:04:12 -0400 (EDT) Received: by mail-yw1-f71.google.com with SMTP id f126-v6so2553129ywh.4 for ; Tue, 21 Aug 2018 09:04:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=HQveg+wwOvTMgdq8w8V2TDKUdmzAZcRDjRhbO3q1zV8=; b=RwS+0hjLZ80MALmP6XBNFJoi1xcd7OXsAnwAtEQ8s2TIBqQRY7incvUOmrF4td3Mwh mYm/Gv7CuQo5VBDFZ/dmuy9MGD3p9nP1s1BwOazUoPup9Mk0YOV3tirMJrEofTMtCbbn 8DDCA68mbSOJDmcj+sLBqD0EoE7pLUqAffAJKdYGwY7e74IMrqLAw2O53mtzlc9eHFkd WSuJ1FJybSA5HgguacUHIoVSk945D88KOlgZaKZVZAcSVIQxgbPxvPKZn9GgcNKuvVln eEpldm+Gp6NPq3y61+xQJJANx1kuBdAW5UyaruzOXoV6EXAVzg7Rxq9UYoVsJ8rMtdXZ +rjg== X-Gm-Message-State: AOUpUlHwdQOfvnWpNCCGexFgK26RIlyAAzr2NuPMpbd8Sq9l4jXQtkav Be8zywyQPOtc3D3GDDTy2FYmuP1hA3HlsZv66VC2QqeTPOBWauT2jv0G5chcTEaMs36Pt6bhoJo 4Z5ti/G4JYUL6qhjTJ1P04kuVudv3sYkc8E9MWPdGy67xvwkU4z8Ucb6YBmlLLBYzAl/qfTmtr5 ebvpKjaxhXEjwZgGg/Z/G2ak6Bc+pSmkZxWrWvsaTlBdDWdZRPmt7+wSCYCDAz1BDxjjHXVJaAM uS8j0A1ZvXqoa0HTl9vSfWiLxco9wjfeg1VOMLna9MRl+8/MWQ501Kq9QLnvI9sQFrY/6qH1nd+ Wad8ztNn1GLE132bus+/3cw1mNpawUwn+We8QYtEqWwsdnpXMfSpwZYuCPw4tsj7KNIK5ftPGxU t X-Received: by 2002:a25:d493:: with SMTP id m141-v6mr26051723ybf.224.1534867451820; Tue, 21 Aug 2018 09:04:11 -0700 (PDT) X-Received: by 2002:a25:d493:: with SMTP id m141-v6mr26051660ybf.224.1534867450948; Tue, 21 Aug 2018 09:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534867450; cv=none; d=google.com; s=arc-20160816; b=Jg6QBFJxCY9R34hdDBngYE5nadPX80l3vr99r5nA7gj3N0e66EupkfhVnUT9RuonB8 mWcX2ZQQv/FHAz+TP2amptB2bqm75H0S42Dtj4ebEJCZmahT1nnk5u2wnBLCNpsSUZpc VuvHYkc/cg8ThrI+p1/2ACbwjf+/O/2VrFoJOpJUUU4m8MXgFx4/00/lOfZ9Ze7YVdsY Y6MeUDNfAnj61O29yIT3qY2i6TEymHA/YTgBlas8XB6D1xUziuY90CMpEoo5H3Ib1wji YCga0yCL3zuEsd2SGW+R9vPQqfIfG7cLmLhvfRw2w7fcAaP+kc/v4x/YLKdJEShe85O3 7mkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=HQveg+wwOvTMgdq8w8V2TDKUdmzAZcRDjRhbO3q1zV8=; b=UDtPDpfQx1tR2uUvKwtCc1SmAubnOG6a57grLqwOGHn/PZkVXlVfVD6cXsIRuo10tG +hYylMRlVwI0l3Uz31f3fclMlRyPEBfhwbDd29AY3zRsJ45AL/9uk5l/dVz7YKtsI4Wn 5jlLR4MQLOyqRHtHpyegKSndTQoQfVckHPATqk65oNnsMycSUVyFqRJb5z9UBIHU6aXn EHn9sP7+ucFIBwIqm5eNAAqvr8EqvUaCVHpBEWP8ZcoMpMNzVCgp6ew27rIRNzfUVuwv XkN6mR68gS7iIH6DWHvxDxgAsHi/q9xbRJARMrgrZQRHv2P2an1YjfNPdcxgkOmKGCvb 6dKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="0l/jvN1Y"; spf=pass (google.com: domain of hannes@cmpxchg.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a81-v6sor3617174yba.146.2018.08.21.09.04.08 for (Google Transport Security); Tue, 21 Aug 2018 09:04:08 -0700 (PDT) Received-SPF: pass (google.com: domain of hannes@cmpxchg.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="0l/jvN1Y"; spf=pass (google.com: domain of hannes@cmpxchg.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=HQveg+wwOvTMgdq8w8V2TDKUdmzAZcRDjRhbO3q1zV8=; b=0l/jvN1YJk7d1P79vzNblx2RXEFZ05NKLc8X7lXMrwjyeWL8pCT5aqWoohrk+lsppp Zkh1FJTP/GVyTfoCHUBwZvt/vRq1Grva0fuG/+ocLK9jR4mX4BHCLGNpLytptrmD/HUo ekuSezfHj9CEUVzoMrFbKK8QXyhtddhDsjDicxzwwF7Ejnzp8rtwwI3+5OfABBap5ObG 0B+PTiAICHD470ZOQf1QtlXk0atuMOw4JzYy/SjzEfLoJoaiNb39csjsaBPktqZitd6b 6DW3ceomGLxsrWsHBBiOfcmgq0vbAnHIUKZTUiBGBaNcSwDQ/XWKB24bDd8C/FRwDzoM Djpw== X-Google-Smtp-Source: AA+uWPzz2SYm4t38tYNRDX2IVM27FnQJipEbSpZGjMl67ghF+9S6xDAjYUfvmJKQlug9khxlvRqyAg== X-Received: by 2002:a25:bc92:: with SMTP id e18-v6mr5831218ybk.182.1534867448241; Tue, 21 Aug 2018 09:04:08 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::3:17a0]) by smtp.gmail.com with ESMTPSA id r3-v6sm7043691ywr.80.2018.08.21.09.04.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Aug 2018 09:04:07 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Michal Hocko , Dmitry Vyukov , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: memcontrol: print proper OOM header when no eligible victim left Date: Tue, 21 Aug 2018 12:04:06 -0400 Message-Id: <20180821160406.22578-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.18.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When the memcg OOM killer runs out of killable tasks, it currently prints a WARN with no further OOM context. This has caused some user confusion. Warnings indicate a kernel problem. In a reported case, however, the situation was triggered by a non-sensical memcg configuration (hard limit set to 0). But without any VM context this wasn't obvious from the report, and it took some back and forth on the mailing list to identify what is actually a trivial issue. Handle this OOM condition like we handle it in the global OOM killer: dump the full OOM context and tell the user we ran out of tasks. This way the user can identify misconfigurations easily by themselves and rectify the problem - without having to go through the hassle of running into an obscure but unsettling warning, finding the appropriate kernel mailing list and waiting for a kernel developer to remote-analyze that the memcg configuration caused this. If users cannot make sense of why the OOM killer was triggered or why it failed, they will still report it to the mailing list, we know that from experience. So in case there is an actual kernel bug causing this, kernel developers will very likely hear about it. Signed-off-by: Johannes Weiner Acked-by: Michal Hocko Signed-off-by: Tetsuo Handa --- mm/memcontrol.c | 2 -- mm/oom_kill.c | 13 ++++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4e3c1315b1de..29d9d1a69b36 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1701,8 +1701,6 @@ static enum oom_status mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int if (mem_cgroup_out_of_memory(memcg, mask, order)) return OOM_SUCCESS; - WARN(1,"Memory cgroup charge failed because of no reclaimable memory! " - "This looks like a misconfiguration or a kernel bug."); return OOM_FAILED; } diff --git a/mm/oom_kill.c b/mm/oom_kill.c index b5b25e4dcbbb..95fbbc46f68f 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -1103,10 +1103,17 @@ bool out_of_memory(struct oom_control *oc) } select_bad_process(oc); - /* Found nothing?!?! Either we hang forever, or we panic. */ - if (!oc->chosen && !is_sysrq_oom(oc) && !is_memcg_oom(oc)) { + /* Found nothing?!?! */ + if (!oc->chosen) { dump_header(oc, NULL); - panic("Out of memory and no killable processes...\n"); + pr_warn("Out of memory and no killable processes...\n"); + /* + * If we got here due to an actual allocation at the + * system level, we cannot survive this and will enter + * an endless loop in the allocator. Bail out now. + */ + if (!is_sysrq_oom(oc) && !is_memcg_oom(oc)) + panic("System is deadlocked on memory\n"); } if (oc->chosen && oc->chosen != (void *)-1UL) oom_kill_process(oc, !is_memcg_oom(oc) ? "Out of memory" :