From patchwork Fri May 4 20:55:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 10381683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AB90D60159 for ; Fri, 4 May 2018 20:56:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 993092956B for ; Fri, 4 May 2018 20:56:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D0BA29570; Fri, 4 May 2018 20:56:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B03F2956B for ; Fri, 4 May 2018 20:55:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14F816B0269; Fri, 4 May 2018 16:55:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0D7406B026A; Fri, 4 May 2018 16:55:59 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBAB06B026B; Fri, 4 May 2018 16:55:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id A957D6B0269 for ; Fri, 4 May 2018 16:55:58 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id m68so18147022pfm.20 for ; Fri, 04 May 2018 13:55:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=DnUXLEaCkkCVH3E829dGRxAOA8xyVQ0lOvRMY9hJGEI=; b=YOHQUch9FojJN1+1Tu7ANvqZnbnIwolLvxk+toEeyqJkpZOf/NM2wnE0nCCu6FmBRX zhk5wD8CVK4M+/tSs8gNDYyeYkxVaKxOxLDEdOv8IRqiFWsnxrLVXysLG6568MMYFNb8 cZWFFF/QA9537q0JoFh17Sw9+0x5Djf+tzGwJGMb1O9PGqn982ScscEhrwFam1TJWZYX 2AQyiuSRYsxSzLC9AknS4mFzZLq5IsT1969IvLD1qyH0gfzNY9J4szZa0Sq6355lNAE2 Lc19E9x4Fmjd7HhcCBxQyEtllk4lVZs6IuoORV1G+9YNNqVqA24qQNAKBWdacDX4tYXI sJVw== X-Gm-Message-State: ALQs6tDJYsAFZjY5dpGfy9J7khKYISKw52S4ZJqk9NSe12pXBE3Kr5iF 0iClxM28hWH7BegVyTLSGaLXLKkAG8a1J9DBeY++fQCRCtB1sKF1K08RzSfnCOs2RaHhx285q+1 BD7AM1atCTRluQ9YkvnMjAGLUMvDcUg7mVBEXCbwswvWKQ/zZfjw3o3Ho2t4ev3oZCDd83HrDiE PUUM7lO1PkLb3NZkT9Sz4Mio/ALkl6fbihCC2itwboH3gkjgsVhDRmXL1Z3s/zTHwU7n9qwcJh1 /mJaK8n5QBpzSf/9DJs7X3i25tcyxGbDdW4hgTLG7psuARKW9COZSIVYB8e0LXiiKqbUjtWytt7 SCU/81CfwJ3JH8AY67i/JCBE6Rez+obTerfMwc09Nj+s5we5QRpd7GrtLSwM62KW06/BzwxpS0U q X-Received: by 2002:a65:5c88:: with SMTP id a8-v6mr22998246pgt.373.1525467358374; Fri, 04 May 2018 13:55:58 -0700 (PDT) X-Received: by 2002:a65:5c88:: with SMTP id a8-v6mr22998232pgt.373.1525467357691; Fri, 04 May 2018 13:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525467357; cv=none; d=google.com; s=arc-20160816; b=OR+Zrq/S/LnQHG2pgqT1PVBA6fEQTDS86U+B2xJBnH6ofkdCAjOlWgFWrVlcl/o0Y7 nHl4wIDm7lMiKIBz/WoReiQzjKx4prw2OhUWa7d1m6SFL+sWSd5sK+M99GR+DOQs92lc yCrjBtGq9DQ1qTlSrYXkRr0GEzpkyestqCwl5yuEOnjsXWzb2hsWIh1nYYjZendWsJFn jX00g1hxJon5Rzrtfn7NLuAUsL0Vj1UUNDzO9mcBO1l2o5YhXhUmjFW9cfZBYQkgwgaR C6vddJFwzm0elTuUIzCa/FWyI/shs6VGPzqXKxkTMehHJVD2PWhdgorXC35/6Gap5fs+ /eug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=DnUXLEaCkkCVH3E829dGRxAOA8xyVQ0lOvRMY9hJGEI=; b=j2gv2Wzs9P9mTCelg5COSKVK8Npk1foX/jXjBvgZa9cPKvaPZksHFuh5vKugLGToNr 46cNv/67rVJ9y3BklsSH6jpM0my5x5DmoIDNOpKM5a90Y6vTKhOkaHC9URRq3e3cWMMh vM2msin5B5p+1teEhJW/qN3lwQjZ08/tTOnllpjvytV1Yni+IZujSwSt+7aLuDFNsAF1 UelH7jS2Xx08eo6tvUmMv2SxLpGL3rMkx1gZsf45CA0KnpE9dgNRwz7BfYwVxXQ5zPDD rpCS/fv7fJuRzH/DVYKCOJw0QGU1KF2ILMO1BD6GXb1Sis6SG62nVPjTCet2poxBswuD R2Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TURGtkQm; spf=pass (google.com: domain of shakeelb@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=shakeelb@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id f9-v6sor3306127pge.41.2018.05.04.13.55.57 for (Google Transport Security); Fri, 04 May 2018 13:55:57 -0700 (PDT) Received-SPF: pass (google.com: domain of shakeelb@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TURGtkQm; spf=pass (google.com: domain of shakeelb@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=shakeelb@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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-Smtp-Source: AB8JxZoXxJNVzYFki5ZZZr+HfCbfiQCah8P34Z4JnA2ifq+V9kX6SCZA7HbxFLAPI9oO3522Lgb7yg== 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 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: X-Virus-Scanned: ClamAV using ClamSMTP 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: Johannes Weiner 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;