Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5508786imm; Tue, 12 Jun 2018 08:52:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ3rnlVRrCQAOKQVIeRsZ1IOef0w8ODHZjRcZjz5K4F3ohYl3cKxhw1jG6P6mkWZVDfkn4s X-Received: by 2002:a62:dc98:: with SMTP id c24-v6mr946540pfl.183.1528818756782; Tue, 12 Jun 2018 08:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528818756; cv=none; d=google.com; s=arc-20160816; b=Kp6WsOb9kXS4DErvFt7VZlQOEEgy74q3uzDMrLYS6EulSVti78RSvx/2vw8mpsQdS9 Bf/w5HrEY8GbrJj6mVqS0PcH24plgVOhVmM74heWxqBHmet5HOZQHKNNhhdgEFM6O4SA J3yqqu6x2+yCzQxmA5Y8ifz3pkQ1JnjbsRvjwgGZ3RlxiexR6tb2UeuUaBUa77lgW3f5 CIDYfo3pFC1V7l8iMHum91NMekRaVb1G3d0yEqN+8D23i9lhPyD7/6a5n68Gv0ReEbQR 1He5Z4ntH7iE4Jw0H0d6W1IpKIlD6JDEvdksD390mypQ1o3JGCWcF4zCy4fdrV8JKhBL RoNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=XGFA4u88S9/eagEXpICkjHR3Y7OszNKgAfVQPcDRimI=; b=tdzTHNYvuscZ1d94v+6hsewqaFzwOmJiKW0XISqDSorflxxAPxTqiIYZw3ui4vdbpI oCFTtUl3KsktQJuAPwxcxrHj/JYSKUpYXxdOe7Hqr+0hM/B6TgqOKAzsB3ucDMuzjOb+ XNWoeeYBk/FJQoQQuRrYLUr3jDi7kXc0FqBJinkmmLnjgc+2ZGtTLvOZ6LCI/Ec/5cu4 8hFUcjtW0KaK+2twttrJNUJ7jd5a9Y2+GXSDD+dbA3aq/b6eafQ5QRdCiqFllhg4ykJs YXYrbwS7sX/6v35FR4klgiTWx591ecdHYwAYrirfgkKuMdaJ/WGnAGyhpqCRBTBOfOUu gK+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cmpxchg.org header.s=x header.b="vwyJL/yy"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g25-v6si319708pgn.613.2018.06.12.08.51.52; Tue, 12 Jun 2018 08:52:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@cmpxchg.org header.s=x header.b="vwyJL/yy"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934366AbeFLPub (ORCPT + 99 others); Tue, 12 Jun 2018 11:50:31 -0400 Received: from gum.cmpxchg.org ([85.214.110.215]:54262 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933137AbeFLPua (ORCPT ); Tue, 12 Jun 2018 11:50:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cmpxchg.org ; s=x; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject: Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XGFA4u88S9/eagEXpICkjHR3Y7OszNKgAfVQPcDRimI=; b=vwyJL/yys8tmDpsj2y19G8tCfJ i5h6DJ0T5bzrcqOJjdeZo4Uu22WJmAYarx+aBfDg5pmCyfnXYC8yZGhjvH+HhLJ8gqsKgN6F4T76M Th4naIZS6A+bwSrX083lezUZICWXGn4vR0L1hWDgupfpN8soLHsAs3hZfFOYQ/+LJ9x8=; Date: Tue, 12 Jun 2018 11:52:42 -0400 From: Johannes Weiner To: Roman Gushchin Cc: Andrew Morton , Michal Hocko , Tejun Heo , linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org, Vladimir Davydov , Greg Thelen , Shuah Khan , Andrew Morton Subject: Re: [PATCH v2 2/3] mm, memcg: propagate memory effective protection on setting memory.min/low Message-ID: <20180612155242.GA6300@cmpxchg.org> References: <20180611175418.7007-1-guro@fb.com> <20180611175418.7007-3-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180611175418.7007-3-guro@fb.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 11, 2018 at 10:54:17AM -0700, Roman Gushchin wrote: > Explicitly propagate effective memory min/low values down by the tree. > > If there is the global memory pressure, it's not really necessary. > Effective memory guarantees will be propagated automatically as we > traverse memory cgroup tree in the reclaim path. > > But if there is no global memory pressure, effective memory protection > still matters for local (memcg-scoped) memory pressure. So, we have to > update effective limits in the subtree, if a user changes memory.min and > memory.low values. > > Link: http://lkml.kernel.org/r/20180522132528.23769-1-guro@fb.com > Signed-off-by: Roman Gushchin > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Vladimir Davydov > Cc: Greg Thelen > Cc: Tejun Heo > Cc: Shuah Khan > Signed-off-by: Andrew Morton > --- > mm/memcontrol.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 5a3873e9d657..485df6f63d26 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -5084,7 +5084,7 @@ static int memory_min_show(struct seq_file *m, void *v) > static ssize_t memory_min_write(struct kernfs_open_file *of, > char *buf, size_t nbytes, loff_t off) > { > - struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); > + struct mem_cgroup *iter, *memcg = mem_cgroup_from_css(of_css(of)); > unsigned long min; > int err; > > @@ -5095,6 +5095,11 @@ static ssize_t memory_min_write(struct kernfs_open_file *of, > > page_counter_set_min(&memcg->memory, min); > > + rcu_read_lock(); > + for_each_mem_cgroup_tree(iter, memcg) > + mem_cgroup_protected(NULL, iter); > + rcu_read_unlock(); I'm not quite following. mem_cgroup_protected() is a just-in-time query that depends on the groups' usage. How does it make sense to run this at the time the limit is set? Also, why is target reclaim different from global reclaim here? We have all the information we need, even if we don't start at the root_mem_cgroup. If we enter target reclaim against a specific cgroup, yes, we don't know the elow it receives from its parents. What we *do* know, though, is that it hit its own hard limit. What is happening higher up that group doesn't matter for the purpose of protection. I.e. it seems to me that instead of this patch we should be treating the reclaim root and its first-level children the same way we treat root_mem_cgroup and top-level cgroups: no protection for the root, first children use their low setting as the elow, all descendants get the proportional low-usage distribution.