From patchwork Wed Nov 20 08:53:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11253375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5DA11390 for ; Wed, 20 Nov 2019 08:53:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2786223BD for ; Wed, 20 Nov 2019 08:53:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KI7efw+n" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2786223BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D4E4E6B0007; Wed, 20 Nov 2019 03:53:31 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CFEC76B0008; Wed, 20 Nov 2019 03:53:31 -0500 (EST) 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 C15E46B000A; Wed, 20 Nov 2019 03:53:31 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id AD0C36B0007 for ; Wed, 20 Nov 2019 03:53:31 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 6B2FB82499A8 for ; Wed, 20 Nov 2019 08:53:31 +0000 (UTC) X-FDA: 76176042222.05.story38_198e3b89a42a X-Spam-Summary: 2,0,0,b33df2a69abc39f3,d41d8cd98f00b204,laoar.shao@gmail.com,:mhocko@kernel.org:hannes@cmpxchg.org:vdavydov.dev@gmail.com:akpm@linux-foundation.org::laoar.shao@gmail.com,RULES_HIT:41:334:355:368:369:379:541:800:960:973:988:989:1260:1345:1437:1535:1542:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:2892:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:4250:4321:4605:5007:6119:6261:6653:7208:7514:8784:9113:9413:10004:11026:11658:11914:12043:12048:12294:12296:12297:12438:12517:12519:12555:12895:12986:13161:13229:14181:14394:14687:14721:21080:21212:21324:21433:21444:21451:21627:21666:30054:30056:30075:30089:30090,0,RBL:209.85.210.196:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: story38_198e3b89a42a X-Filterd-Recvd-Size: 5610 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 Nov 2019 08:53:30 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id 3so13874514pfb.10 for ; Wed, 20 Nov 2019 00:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=aqhwi381gvNmWi32mFlPgE+AgrymPii+EbqwKu86y0I=; b=KI7efw+n8q4NtWOB5RMVeq/mNlESGAEeUyLggfoh6LhuNWfwcERpkzHPPcEfkaBhmK +RBaAsp5BYYfmcYCEEpiWMi1CupdqgUb+feoR/sEQXAr7DZPqgw0/B8jZndT/YkarlCK saq/0wXZ774pKmDjGqQhsuXwfMvHXQnuthkwQ+AJ1i9Qz9Yi+hFTU/Kzs+tdecN8RfkY NpEHtcEMgyF1L9GAvqucM6kN51Qb94Q+3lYrFfD3qWG4MVwN8fbrhggh2Ma98v4SH6rY TkJNVAyRn98F4GOacf4iIaiLAqzbylSmo4Jsn5TJsITxB++vh/nAfBtDh63uXHaEZOg7 gHDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aqhwi381gvNmWi32mFlPgE+AgrymPii+EbqwKu86y0I=; b=d7Qa2epz4lYtQXr2bv94lun+e/vHBLl+CMMyufIDsdjRjNBK5VRSrinKgCrJ6UaMoI u/D2YEQN0O9TQris0/Zv1ZznO4E2EOcmTHq3/wUTwlCcvidV86d8n+tGPRQQP9QWrE5e zn17iqRpje9QfRlnGeEqDPepuuGjPoPlSzo/qI42n3rPaRRzMDat642owLEcuTJubh7m DijXoGMdzIyRBdOlNdwbXivfmljhwb7+M3a06oXiMZqiRoJvtXryZ3HKlY6Dm+h3iXrk nY5zfU8q+FhUJRxBgm8HNAdRILcOOUpNCuu8yMBwVQwaS58RcFlVL4SLHuayYvcQ7RCl x4Qg== X-Gm-Message-State: APjAAAWL6rU+z5wEj8dV7NsFhtVPOALeURuz3FHH88PLfprS3Wv8zR4N VFZNQZAgcDXlhSpEMc86Q10= X-Google-Smtp-Source: APXvYqyLYGsI+yt3IB2KJPdaaj2THVE72e3bEx/spEIL2tgkQ+vFcEDzIZutR1xuA7JHT/7Ihju7SA== X-Received: by 2002:a62:82c1:: with SMTP id w184mr2631733pfd.134.1574240009800; Wed, 20 Nov 2019 00:53:29 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id f26sm25277328pgf.22.2019.11.20.00.53.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Nov 2019 00:53:28 -0800 (PST) From: Yafang Shao To: mhocko@kernel.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Yafang Shao Subject: [PATCH] mm, memcg: show memcg min setting in oom messages Date: Wed, 20 Nov 2019 03:53:05 -0500 Message-Id: <1574239985-1916-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 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: A task running in a memcg may OOM because of the memory.min settings of his slibing and parent. If this happens, the current oom messages can't show why file page cache can't be reclaimed. So it is better to show the memcg min settings. Let's take an example. bar bar/memory.max = 1200M memory.min=800M / \ barA barB barA/memory.min = 800M memory.current=1G (file page cache) barB/memory.min = 0 (process in this memcg is allocating page) The process will do memcg reclaim if the bar/memory.max is reached. Once the barA/memory.min is reached it will stop reclaiming file page caches in barA, and if there is no reclaimable pages in bar and bar/barB it will enter memcg OOM then. After this pacch, bellow messages will be show then (only includeing the relevant messages here). The lines begin with '#' are newly added info (the '#' symbol is not in the original messages). memory: usage 1228800kB, limit 1228800kB, failcnt 18337 ... # Memory cgroup min setting: # /bar: min 819200KB emin 0KB # /bar/barA: min 819200KB emin 819200KB # /bar/barB: min 0KB emin 0KB ... Memory cgroup stats for /bar: anon 418328576 file 835756032 ... unevictable 0 ... oom-kill:constraint=CONSTRAINT_MEMCG..oom_memcg=/bar,task_memcg=/bar/barB With the new added information, we can find the memory.min in bar/barA is reached and the processes in bar/barB can't reclaim file page cache from bar/barA any more. While without this new added information we don't know why the file page cache in bar can't be reclaimed. Signed-off-by: Yafang Shao --- mm/memcontrol.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1c4c08b..97fdd93 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1519,16 +1519,27 @@ void mem_cgroup_print_oom_context(struct mem_cgroup *memcg, struct task_struct * */ void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg) { + struct mem_cgroup *iter; char *buf; pr_info("memory: usage %llukB, limit %llukB, failcnt %lu\n", K((u64)page_counter_read(&memcg->memory)), K((u64)memcg->memory.max), memcg->memory.failcnt); - if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) + if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) { pr_info("swap: usage %llukB, limit %llukB, failcnt %lu\n", K((u64)page_counter_read(&memcg->swap)), K((u64)memcg->swap.max), memcg->swap.failcnt); - else { + + pr_info("Memory cgroup min setting:\n"); + for_each_mem_cgroup_tree(iter, memcg) { + pr_cont_cgroup_path(iter->css.cgroup); + pr_cont(":"); + + pr_cont(" min %lluKB emin %lluKB\n", + K((u64)iter->memory.min), + K((u64)iter->memory.emin)); + } + } else { pr_info("memory+swap: usage %llukB, limit %llukB, failcnt %lu\n", K((u64)page_counter_read(&memcg->memsw)), K((u64)memcg->memsw.max), memcg->memsw.failcnt);