Received: by 10.192.165.148 with SMTP id m20csp498703imm; Fri, 4 May 2018 13:56:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrKLMgJLhu98jQEGrnldv5pxN7tx2J0MAb2qOVloyOREMF/wfX/cwWRrjDH8XMDcpF0muX2 X-Received: by 2002:a63:6fc9:: with SMTP id k192-v6mr23707337pgc.143.1525467394520; Fri, 04 May 2018 13:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525467394; cv=none; d=google.com; s=arc-20160816; b=JijYCzirgTseH3xWoVjLAcNG35evDOUqraY+ZAzGK9mjiKnrQETkH8UYccJpdjJmR+ lBDLI2PA3xGyHUlOTqvSmIFYP8Va8+xyhopVc5JlqyLOmNe4B/HupT1DJuMq9DmP2HBf jx0Ilziz3edSug6jCfZNGiXXYL9NKBDpNFxlzqfYapuIMv3L96PizEaNTJarJepyYhrw s/q+muFv2R/R6SPhd9GKLK8s0Nl9dcT4vUzn3zbzTu9smr5ceF5Wt3suS23T9Aqbvyx3 +c39uCcrNKpYxAgAY0X3uakOirmF0n2LcdMwKKjEYSbV12iRT6zbwL6nBJOThlHFc42X QVDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=DnUXLEaCkkCVH3E829dGRxAOA8xyVQ0lOvRMY9hJGEI=; b=jJURZR2COa/R+rx+OkcmmuIQbbaGDz3U60YGEaICUJAAIAeTU2hiOYykiw4QcRMi7q hYiCNqRAsHSSwyGvbDeRL3xa19yT20np7i9FlcGUsBy4hFbGGCG1GFtRLVtVNRiifAZy 05ucVgSd5C8IHeCcjiC6YwU0BVfXVpmnUkd84ekCeJLphPjI0omWIP/AA6VU+lGJGnwl NJCKIiDWUr4BrNl0s40gkcxyZsLJTTfQe+Y7sUNdqCHbLVGuj2Owf/hbh0dmNMRqTX5n lW+2BzNqBmjHXx07GhMl+VhHChO1UZmaCjLlLticohevSxQkE+7WITQF8wpQN06GtGam d+LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TURGtkQm; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y23-v6si10535507pgc.515.2018.05.04.13.56.20; Fri, 04 May 2018 13:56:34 -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=pass header.i=@google.com header.s=20161025 header.b=TURGtkQm; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751936AbeEDU4A (ORCPT + 99 others); Fri, 4 May 2018 16:56:00 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:40564 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751923AbeEDUz5 (ORCPT ); Fri, 4 May 2018 16:55:57 -0400 Received: by mail-pg0-f65.google.com with SMTP id l2-v6so16199460pgc.7 for ; Fri, 04 May 2018 13:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=DnUXLEaCkkCVH3E829dGRxAOA8xyVQ0lOvRMY9hJGEI=; b=TURGtkQmk7rkrMeduUJd+hla+ZISuA1kz8znMwFvV0ZOR/uKnCBHtW+ZPl3g/Xn308 R2I2KARF7NS44t0mwlpDcbZhSu3RdQpBAp7G4TlqmKGbxlQjXv+hnjB5HrWjJNgrCEi3 xbIatTsSkoWNx935dwxn7kXYCsnBU2bUSxe5xoARvUYfXCVOuBSoEtB/obshbeAdQGaZ xc/0FUaWnLzogT1W+lSNtgQPOTZhnXtS2W91kdnnibLyS8H8HJThtYau9AKdJQQyjsi8 I03/90qQ3mE8LCnTRPJILi9FMnIPJolIQf19DHOEhXdk0nClgPVELATOq8UVezrVTZK2 OvXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DnUXLEaCkkCVH3E829dGRxAOA8xyVQ0lOvRMY9hJGEI=; b=be3EGoPCQA1yk8snvJ7jT0GZ4cduNO9EQC3998xbGibTWd8Ls6luq26SI47Ug2LnW5 cHGabJ4kviwveHvGptJFaIWJgO/JxIeFYHeESvdmGW1a+E3whpDy12h+mSAoie75dy6d fJM/5mWt00na31KCtYbwNt2V6EktHuMgFP/3qbAHDk4JBLAh30Brr5PtymOgtIRv7hQC Ahqw+9IWZlB/JgTdmOY9IL8coGI9GYrK1UASj62K6RmLP0HCRhGGl0H/cKOtdE5qQwZl mKXeFovGAWr7dLu5pEfMo3k65zIL0DEss9liTrAGVcELpLkO6kGyrkm8KFfHLtPhNz4K daJQ== X-Gm-Message-State: ALQs6tBFeMk0qiirM36iSqdcZ2QSO54YUC+6zsyyTTRhLkX0TP8uyzFt A+MUg9e4/WbHbrHQGxBBs19GLQ== X-Received: by 2002:a65:4189:: with SMTP id a9-v6mr23293066pgq.118.1525467356779; Fri, 04 May 2018 13:55:56 -0700 (PDT) Received: from shakeelb.mtv.corp.google.com ([2620:15c:2cb:201:3a5f:3a4f:fa44:6b63]) by smtp.gmail.com with ESMTPSA id a28sm36752171pfl.86.2018.05.04.13.55.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 May 2018 13:55:55 -0700 (PDT) From: Shakeel Butt To: Michal Hocko , Andrew Morton , Greg Thelen , Johannes Weiner , Vladimir Davydov Cc: Linux MM , Cgroups , LKML , Shakeel Butt Subject: [PATCH] mm: memcontrol: drain stocks on resize limit Date: Fri, 4 May 2018 13:55:48 -0700 Message-Id: <20180504205548.110696-1-shakeelb@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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