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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 1CBFAC35254 for ; Mon, 17 Feb 2020 09:25:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB3382064C for ; Mon, 17 Feb 2020 09:25:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB3382064C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 74F956B0005; Mon, 17 Feb 2020 04:25:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 700006B0006; Mon, 17 Feb 2020 04:25:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6154D6B0007; Mon, 17 Feb 2020 04:25:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0254.hostedemail.com [216.40.44.254]) by kanga.kvack.org (Postfix) with ESMTP id 46F876B0005 for ; Mon, 17 Feb 2020 04:25:03 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EBB7D68A1 for ; Mon, 17 Feb 2020 09:25:02 +0000 (UTC) X-FDA: 76499084844.10.hall51_491eb690e4c41 X-HE-Tag: hall51_491eb690e4c41 X-Filterd-Recvd-Size: 4795 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Mon, 17 Feb 2020 09:25:02 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id c84so17595437wme.4 for ; Mon, 17 Feb 2020 01:25:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Sviw8dRFEvqwbGMvB0nhSjFBP5YFChvKzAllALvrn/8=; b=chx6bxcL/5XAHZB4twozbKHgKNaqZ7RJWR76GXjO0PaU7yzRF23gsurg79Ulxa+WRG ttGpEgewTaUTEaAh48nO9laKH8aEH9fVN1hnNWY1v/DHYc6NuVXCmV7vgM/SgtIjW0Y8 /WqFTv9b9NzczLw4yH7pY2zj+v+ksjHXuGA0SP9umZLF3fj2Akag78bY3HFWsirxuPgr 6AKPOAExu00KlErM2avi+JG6Fo63LsOhPn0w5QQPHee6cadP6Ka+mCSBgiP4Edu79XqS rYtI2lDMPQr1y/d7zTPi7vBygxBqcDfw03V837D1xOyRFKvCmMGn7uM0XzyjNBDGfHXq BygQ== X-Gm-Message-State: APjAAAUXuntgKG5XaiGmyC+6lrowJF2QrWI23jl0F3f4tAbtfUUFoJlD fgLjVT9aWiLlSfs7JBzfTQw= X-Google-Smtp-Source: APXvYqwdIa0b6Lx/2uaoX0r0LQh1uykC6Fe/2uKI4y1KtvHUfM0fbT67AoSxKEsrQEiaqMoif0nHfQ== X-Received: by 2002:a7b:c652:: with SMTP id q18mr20789818wmk.123.1581931501174; Mon, 17 Feb 2020 01:25:01 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id f127sm19503365wma.4.2020.02.17.01.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 01:25:00 -0800 (PST) Date: Mon, 17 Feb 2020 10:24:59 +0100 From: Michal Hocko To: Yafang Shao Cc: guro@fb.com, hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, chris@chrisdown.name, linux-mm@kvack.org, stable@vger.kernel.org Subject: Re: [PATCH resend] mm, memcg: reset memcg's memory.{min, low} for reclaiming itself Message-ID: <20200217092459.GG31531@dhcp22.suse.cz> References: <20200216145249.6900-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200216145249.6900-1-laoar.shao@gmail.com> 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 Sun 16-02-20 09:52:49, 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. Please document user visible effects of this patch. What does it mean that this is not proper behavior? What happens if we have concurrent reclaimers at different levels of the hierarchy how that would affect the resulting protection? > Fixes: 9783aa9917f8 ("mm, memcg: proportional memory.{low,min} reclaim") > Signed-off-by: Yafang Shao > Acked-by: Roman Gushchin > Cc: Chris Down > Cc: stable@vger.kernel.org > --- > mm/memcontrol.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 6f6dc8712e39..df7fedbfc211 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -6250,8 +6250,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) > -- > 2.14.1 -- Michal Hocko SUSE Labs