From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2BB8C2D0DC for ; Fri, 27 Dec 2019 01:12:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 579FB20740 for ; Fri, 27 Dec 2019 01:12:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vD2Hd6zW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 579FB20740 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 ED02B8E0006; Thu, 26 Dec 2019 20:12:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E7FA88E0001; Thu, 26 Dec 2019 20:12:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBDE18E0006; Thu, 26 Dec 2019 20:12:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id C62E48E0001 for ; Thu, 26 Dec 2019 20:12:01 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 93F418249980 for ; Fri, 27 Dec 2019 01:12:01 +0000 (UTC) X-FDA: 76309144842.10.woman24_11a37c5af8153 X-HE-Tag: woman24_11a37c5af8153 X-Filterd-Recvd-Size: 5771 Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Dec 2019 01:12:01 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id v18so24583875iol.2 for ; Thu, 26 Dec 2019 17:12:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2yY3FjVteeoVVTl55LcBKOn6wVKD6QJ7uHyRGPTrzgQ=; b=vD2Hd6zWOvuHyJvyDaDjfl3WLQf1/qcvTFLz5ogFx96fXyJMYV+2sD4q9VBjqzABBX Crq/P9bpJpzCz9NFU9NOCLc/RLZ7EkYG396dK/ibBZ97x37fX6upIUPC08v8ToC46jPx 2Oy6aWunbJ0ynSD1NRrGZKJpLGf6VmHo31hISDhznVznbRxdfmDFnD630p4Ue3PhXvsQ t/at7gqV+fIcpVmH1TjCCnqlQm26sPFkcgku3pRj6HPAltyvw0mQ8gcKBq7zhZwc/QMp LuzXmk7dxbDykR3a5bX1zLhIJAAU9/4GMM0MnWp3pFU37UZ1jHsnJuWM120vJcCfmvmM TRrA== 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=2yY3FjVteeoVVTl55LcBKOn6wVKD6QJ7uHyRGPTrzgQ=; b=RFXoh9/EvOpMdg/+45vdTjA6DmKEuILjyLVLi0ET2q3dQEXIK6h13pbk6LdHC/Y+lA uFfvuugSbXR1QWVNOoPr/iFUJm740F8+LOwYYzXj8hJGHQ35tfUqIOwM5qgBfnPGLJy4 NyPaXcasr2THiPG7y5gy0PeNSqljF4gznj0KNDrOzFOUUwYM5hzd/+Z2smiEaYv6DJYU TMtpQZr1CLKL0ekJ/yZAMaESl595BrxeqZQlooPM8mBc/UNNqVas4s4GQXoId2NVvcZC g2yDuz3bdBD3rA2MULVgywBTppL+MpqFihzU1Jt5cfqpAFfqJR2Ll7Z4Z8tvrS5SGo9W 1V6A== X-Gm-Message-State: APjAAAUOVBk2o6l9y811AT49Le7exgO0FW5/EgH6W1sRYQ2QzBFVJFEQ 6O6e3bf/9vyuKkRjg7DaPeUEkhiCX64Qywk1MMs= X-Google-Smtp-Source: APXvYqy49XK//UQ4rOBQozBYu7EAzrh1qYFqJ52S6XJAjtFutn8sx3rREpV2ya+MWOMSkxvxlbIMaan3xGauP35kbhA= X-Received: by 2002:a6b:5503:: with SMTP id j3mr32572357iob.142.1577409120458; Thu, 26 Dec 2019 17:12:00 -0800 (PST) MIME-Version: 1.0 References: <1577174006-13025-1-git-send-email-laoar.shao@gmail.com> <1577174006-13025-4-git-send-email-laoar.shao@gmail.com> <20191226214539.GC22734@tower.dhcp.thefacebook.com> In-Reply-To: <20191226214539.GC22734@tower.dhcp.thefacebook.com> From: Yafang Shao Date: Fri, 27 Dec 2019 09:11:24 +0800 Message-ID: Subject: Re: [PATCH v2 3/5] mm, memcg: reset memcg's memory.{min, low} for reclaiming itself To: Roman Gushchin Cc: "hannes@cmpxchg.org" , "david@fromorbit.com" , "mhocko@kernel.org" , "vdavydov.dev@gmail.com" , "akpm@linux-foundation.org" , "viro@zeniv.linux.org.uk" , "linux-mm@kvack.org" , "linux-fsdevel@vger.kernel.org" , Chris Down Content-Type: text/plain; charset="UTF-8" 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: On Fri, Dec 27, 2019 at 5:46 AM Roman Gushchin wrote: > > On Tue, Dec 24, 2019 at 02:53:24AM -0500, Yafang Shao wrote: > > memory.{emin, elow} are set in mem_cgroup_protected(), and the values of > > them won't be changed until next recalculation in this function. After > > either or both of them are set, the next reclaimer to relcaim this memcg > > may be a different reclaimer, e.g. this memcg is also the root memcg of > > the new reclaimer, and then in mem_cgroup_protection() in get_scan_count() > > the old values of them will be used to calculate scan count, that is not > > proper. We should reset them to zero in this case. > > > > Here's an example of this issue. > > > > root_mem_cgroup > > / > > A memory.max=1024M memory.min=512M memory.current=800M > > > > Once kswapd is waked up, it will try to scan all MEMCGs, including > > this A, and it will assign memory.emin of A with 512M. > > After that, A may reach its hard limit(memory.max), and then it will > > do memcg reclaim. Because A is the root of this reclaimer, so it will > > not calculate its memory.emin. So the memory.emin is the old value > > 512M, and then this old value will be used in > > mem_cgroup_protection() in get_scan_count() to get the scan count. > > That is not proper. > > Good catch! > > But it seems to be a bug introduced with the implementation of the proportional > reclaim. So I'd remove it from the patchset, add the "Fixes" tag and cc stable@. > Then it will have chances to be backported to stable trees. > Sure, will do it. Thanks! > > > > > Cc: Chris Down > > Signed-off-by: Yafang Shao > > --- > > mm/memcontrol.c | 11 ++++++++++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > index f35fcca..2e78931 100644 > > --- a/mm/memcontrol.c > > +++ b/mm/memcontrol.c > > @@ -6287,8 +6287,17 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root, > > > > if (!root) > > root = root_mem_cgroup; > > - if (memcg == root) > > + if (memcg == root) { > > + /* > > + * Reset memory.(emin, elow) for reclaiming the memcg > > + * itself. > > + */ > > + if (memcg != root_mem_cgroup) { > > + memcg->memory.emin = 0; > > + memcg->memory.elow = 0; > > + } > > return MEMCG_PROT_NONE; > > + } > > > > usage = page_counter_read(&memcg->memory); > > if (!usage) > > -- > > 1.8.3.1 > > > >