Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp760538ybt; Wed, 17 Jun 2020 13:16:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6M3O8f9C/4EVN3j0SuFeS+s5o+MaOSMvEJIB7mpOHRdefY7JbiiPxe5eHz9Zyu5jvX2qC X-Received: by 2002:a17:906:c2c6:: with SMTP id ch6mr862065ejb.36.1592424994481; Wed, 17 Jun 2020 13:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592424994; cv=none; d=google.com; s=arc-20160816; b=1LuZXK0vLI+zfKAI4Hq/WXZQNrTR2rQ4izkx1r0tWvaOnRPNp6ZlWWL/VakwWhLV8y kcwNiE1VUnJum2h24OOs5Z40aWPcQ1pyYzPdAbe50wChxkMFWF09qU23ViPrZBS+BbT3 LBm/oCbALLZjHvd4fC/Mm4Ljh5cXALoBSHBGkHT/AnwznbSYDlXh0r629re6tnQRWqL2 CBa8I//6Y1gFGsbhD5dODBNuu+5kzINcS8IYOsriEpNHAwMJmRLe2kCLkW4xKB+b/CE0 Cb8WrnsTLJ4zG5tcg6kjtnkroBIZyZNoHYgF3uoc9lsKCsc6NVGgnJuHCA6WSes3kJI6 Fd5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=K/gPu7TMycBU2OMmKICnzUSp+xjDAAHE5ZCXBHSedrA=; b=090sXkqs8Kc2vaeRSfrWSje/+0FpGcr2NmL7zrBoJbcmTh4zYugKUCWZZ1nRBdypTz tAzs2yI0luTKvwz/vLhn4uuPuDP2VC3HQhp3p+eUanzlHDMDOje1ostIOjCntQqSbk3C YtCZEN7KrWI8afUGaOwc/PI2cUP3BVusFASy7jyvxEYd4i872gEASbC6u7yCcxEd9ZPT /ua+MtP36NETVr+lQZ6eWWegUZ75/tbWVuqLBbZj6dcX6x3NSHbU2oFUtSq2ctzf5wFc sW9lspMO3bY5FqASd5rB0Tr3rKUHqkzIvNp9X0M5AltlSiBrVBWBeOE5sGb4Btfds8KP /7IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Hgg/nMoO"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si588062edt.140.2020.06.17.13.16.05; Wed, 17 Jun 2020 13:16:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Hgg/nMoO"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbgFQUOL (ORCPT + 99 others); Wed, 17 Jun 2020 16:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726890AbgFQUOI (ORCPT ); Wed, 17 Jun 2020 16:14:08 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0835C0613EF for ; Wed, 17 Jun 2020 13:14:07 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id a9so4478314ljn.6 for ; Wed, 17 Jun 2020 13:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=K/gPu7TMycBU2OMmKICnzUSp+xjDAAHE5ZCXBHSedrA=; b=Hgg/nMoOfC6xMGf+J0M+j/XoZSAzvWUNAJO5oRrnxxQZz6Jmm0bdH9VjaHmTQ4XPAi n/s9J0wSZAWbIYX//BzBFy8dbEnTocLEWX0efF+Wc/Hi97+M0oDVNjosY09MY8AutLO8 qpGLDMUievYu4q8rJPW79V9RO2lnQiRDoKZYOwvNwTOtAoz3Y1Yf4CYHpoxy71/O111x XyKu9yBw7Y6GEAQ6DbuX1G6elk8UAN33ZXvp/hMJY42Wbp16m3kGTmL6w9UxFO2mTphj NMM0Gh4+agGODtkiA7pegz8sjaNYzBN5MFM1gmXwuuNuXozNRhBVA/6Ak0mguCvAdC5y uIiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=K/gPu7TMycBU2OMmKICnzUSp+xjDAAHE5ZCXBHSedrA=; b=beaQshq0ldhXyUwYkn59oKRoWLaA38kjLM7lnXF5fRaghCUvMyT1qDpeqRxHK5fpas ztbU6jUS1SIvusGeuqXn1me1BtIqCUEnV057BUrJvc6EpVFzh/JlrGBjlM990SjrBvM7 8Uht4NFVFfV5aC6hQrugigchtb57BesL/vLbvPIR1+3MeH/N0+qLex5KhzoDvt6uPP5U eo+T1si8K1j8vOCyM3OvU44oSJ69A4t5Az6xrngD/5PZz18OEsrSgotfxOVQ8q/wh2ev Xg8r52IXubCfduqfD/ZOfxoJGM/VWCmE69o2CUpU0RLkLv2rGznpPLd0GkNpG2LEe3WQ zwyg== X-Gm-Message-State: AOAM530PpSo71kabNOCUEM9deMBA2nmTl7UEFWufRm7uZNI1UqrCzZSM uo1cIrrobIMbe1IGA+yetprhTFPsdn/JRxlYLyA/gA== X-Received: by 2002:a2e:974e:: with SMTP id f14mr480197ljj.102.1592424845650; Wed, 17 Jun 2020 13:14:05 -0700 (PDT) MIME-Version: 1.0 References: <20200519084535.GG32497@dhcp22.suse.cz> <20200520190906.GA558281@chrisdown.name> <20200521095515.GK6462@dhcp22.suse.cz> <20200521163450.GV6462@dhcp22.suse.cz> <20200617135758.GA548179@chrisdown.name> <20200617141155.GQ9499@dhcp22.suse.cz> <20200617160624.GS9499@dhcp22.suse.cz> In-Reply-To: <20200617160624.GS9499@dhcp22.suse.cz> From: Naresh Kamboju Date: Thu, 18 Jun 2020 01:43:53 +0530 Message-ID: Subject: Re: mm: mkfs.ext4 invoked oom-killer on i386 - pagecache_get_page To: Michal Hocko , Chris Down Cc: Yafang Shao , Anders Roxell , "Linux F2FS DEV, Mailing List" , linux-ext4 , linux-block , Andrew Morton , open list , Linux-Next Mailing List , linux-mm , Arnd Bergmann , Andreas Dilger , Jaegeuk Kim , "Theodore Ts'o" , Chao Yu , Hugh Dickins , Andrea Arcangeli , Matthew Wilcox , Chao Yu , lkft-triage@lists.linaro.org, Johannes Weiner , Roman Gushchin , Cgroups Content-Type: text/plain; charset="UTF-8" Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, 17 Jun 2020 at 21:36, Michal Hocko wrote: > > On Wed 17-06-20 21:23:05, Naresh Kamboju wrote: > > On Wed, 17 Jun 2020 at 19:41, Michal Hocko wrote: > > > > > > [Our emails have crossed] > > > > > > On Wed 17-06-20 14:57:58, Chris Down wrote: > > > > Naresh Kamboju writes: > > > > > mkfs -t ext4 /dev/disk/by-id/ata-TOSHIBA_MG04ACA100N_Y8RQK14KF6XF > > > > > mke2fs 1.43.8 (1-Jan-2018) > > > > > Creating filesystem with 244190646 4k blocks and 61054976 inodes > > > > > Filesystem UUID: 7c380766-0ed8-41ba-a0de-3c08e78f1891 > > > > > Superblock backups stored on blocks: > > > > > 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, > > > > > 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, > > > > > 102400000, 214990848 > > > > > Allocating group tables: 0/7453 done > > > > > Writing inode tables: 0/7453 done > > > > > Creating journal (262144 blocks): [ 51.544525] under min:0 emin:0 > > > > > [ 51.845304] under min:0 emin:0 > > > > > [ 51.848738] under min:0 emin:0 > > > > > [ 51.858147] under min:0 emin:0 > > > > > [ 51.861333] under min:0 emin:0 > > > > > [ 51.862034] under min:0 emin:0 > > > > > [ 51.862442] under min:0 emin:0 > > > > > [ 51.862763] under min:0 emin:0 > > > > > > > > Thanks, this helps a lot. Somehow we're entering mem_cgroup_below_min even > > > > when min/emin is 0 (which should indeed be the case if you haven't set them > > > > in the hierarchy). > > > > > > > > My guess is that page_counter_read(&memcg->memory) is 0, which means > > > > mem_cgroup_below_min will return 1. > > > > > > Yes this is the case because this is likely the root memcg which skips > > > all charges. > > > > > > > However, I don't know for sure why that should then result in the OOM killer > > > > coming along. My guess is that since this memcg has 0 pages to scan anyway, > > > > we enter premature OOM under some conditions. I don't know why we wouldn't > > > > have hit that with the old version of mem_cgroup_protected that returned > > > > MEMCG_PROT_* members, though. > > > > > > Not really. There is likely no other memcg to reclaim from and assuming > > > min limit protection will result in no reclaimable memory and thus the > > > OOM killer. > > > > > > > Can you please try the patch with the `>=` checks in mem_cgroup_below_min > > > > and mem_cgroup_below_low changed to `>`? If that fixes it, then that gives a > > > > strong hint about what's going on here. > > > > > > This would work but I believe an explicit check for the root memcg would > > > be easier to spot the reasoning. > > > > May I request you to send debugging or proposed fix patches here. > > I am happy to do more testing. > > Sure, here is the diff to test. > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index c74a8f2323f1..6b5a31672fbe 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -392,6 +392,13 @@ static inline bool mem_cgroup_below_low(struct mem_cgroup *memcg) > if (mem_cgroup_disabled()) > return false; > > + /* > + * Root memcg doesn't account charges and doesn't support > + * protection > + */ > + if (mem_cgroup_is_root(memcg)) > + return false; > + > return READ_ONCE(memcg->memory.elow) >= > page_counter_read(&memcg->memory); > } > @@ -401,6 +408,13 @@ static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) > if (mem_cgroup_disabled()) > return false; > > + /* > + * Root memcg doesn't account charges and doesn't support > + * protection > + */ > + if (mem_cgroup_is_root(memcg)) > + return false; > + > return READ_ONCE(memcg->memory.emin) >= > page_counter_read(&memcg->memory); > } After this patch applied the reported issue got fixed. test log link, https://lkft.validation.linaro.org/scheduler/job/1505417#L1429 - Naresh