Received: by 10.192.165.148 with SMTP id m20csp5201712imm; Wed, 9 May 2018 00:45:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqX8VqxRBHw67tQDCMZ3vlMe1fI8X1FRP/k1RvuD7HyCXI6u7u0tLXUb3erisiUhANQI4sx X-Received: by 2002:a17:902:57d8:: with SMTP id g24-v6mr45316920plj.337.1525851944630; Wed, 09 May 2018 00:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525851944; cv=none; d=google.com; s=arc-20160816; b=faPNYWhC4k74Rlvgiams6nYODvNGRbhyg8GH9W2R8GZmEXYEuBP0sBqvNuCxHP9w4Y TeKmnC+gits/64zs62ovw3ZvmWZIo85R5jLIzw+OPap64iA/AM8e9KyheUYqAU0wdFjq LEpKhV5d6FynRzpTmEb2MtKPOC7Ew08iUOyChhRK921mkXnkyOXMjrnzjRlctwOAq3KA FpQ7YGshjOp8EAkMkNo4dm4HfJLOOV1p9PoZFarbi6jRvSws1Cx9ScAMtZyHkqY6bqST BaalmOdVPNtz01DPFqRF9yLxeOTRxtlAWsRhNJrm6jHXZuUfLXVe6KiOAsdFwtwbTq/c dT3g== 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:arc-authentication-results; bh=nzZjdfjpDg2Bi/0oo1xQGndfxzRzaQKbRIgYf+nuKOA=; b=RFe7ly4r+L/Z5gY/bS045b0hUOaVM9y6lY0O1OojKnJnFpAuXgPNTb3+KpXZPky6nf z4cC7qjXuFmHV2Ihflh+6cYoj18lLIt/t1YP6HsUV8mOf3KDzUkDKnNtmo47wjwyC87F stRjH6namiCIPQcW2Cgs7mYUHUgJCwoxefP56p2MAl3E8CSohG+XfOnkiVLXUtUcGFGu Fgh/wwMVt5TZF+49uRaAbenyx/uNj5u2GQW4LQxGxLMK6wYGP3qHvOL1PaE9CR+uJnT8 CRnAh2b+4Zejp9g3jF50+uGlOdoyo+71cIGOgZanLN3MCrngYVdkpJTlgoEBI/ByDQQg akeg== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si14376366pgc.265.2018.05.09.00.45.30; Wed, 09 May 2018 00:45:44 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933827AbeEIHpM (ORCPT + 99 others); Wed, 9 May 2018 03:45:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:57673 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933818AbeEIHpK (ORCPT ); Wed, 9 May 2018 03:45:10 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 66FF9ABE1; Wed, 9 May 2018 07:45:09 +0000 (UTC) Date: Wed, 9 May 2018 09:45:08 +0200 From: Michal Hocko To: Shakeel Butt Cc: Andrew Morton , Greg Thelen , Johannes Weiner , Vladimir Davydov , Linux MM , Cgroups , LKML Subject: Re: [PATCH] mm: memcontrol: drain stocks on resize limit Message-ID: <20180509074508.GC32366@dhcp22.suse.cz> References: <20180504205548.110696-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180504205548.110696-1-shakeelb@google.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 04-05-18 13:55:48, Shakeel Butt wrote: > Resizing the memcg limit for cgroup-v2 drains the stocks before > triggering the memcg reclaim. Do the same for cgroup-v1 to make the > behavior consistent. > > Signed-off-by: Shakeel Butt Acked-by: Michal Hocko > --- > mm/memcontrol.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 25b148c2d222..e2d33a37f971 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -2463,6 +2463,7 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg, > unsigned long max, bool memsw) > { > bool enlarge = false; > + bool drained = false; > int ret; > bool limits_invariant; > struct page_counter *counter = memsw ? &memcg->memsw : &memcg->memory; > @@ -2493,6 +2494,12 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg, > if (!ret) > break; > > + if (!drained) { > + drain_all_stock(memcg); > + drained = true; > + continue; > + } > + > if (!try_to_free_mem_cgroup_pages(memcg, 1, > GFP_KERNEL, !memsw)) { > ret = -EBUSY; > -- > 2.17.0.441.gb46fe60e1d-goog -- Michal Hocko SUSE Labs