Received: by 10.192.165.148 with SMTP id m20csp2715394imm; Sun, 22 Apr 2018 13:28:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx48mzbuzxTSp10AkxFYavjBnjSInO0YaIi0i8G3lDtsWQB2qa8Ep1azur9JVSR+9XF0uXEwL X-Received: by 10.98.73.22 with SMTP id w22mr17422805pfa.96.1524428921573; Sun, 22 Apr 2018 13:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524428921; cv=none; d=google.com; s=arc-20160816; b=qViR5Ngga1S7JV0QuVhseZGyYQgCEkdKEJV1+waHNo4o8pNs5idqq4VKolE/RCFJ7v uasGfH7nmX7lORNcdPd8FLbQx/3FcMFJwzaYJf3jCIMPeBZ0Nh++aFyfAAuZeocm77+r 4xUwbj8GJfNApcU4dYpAYehr5sGkBmllTllJs6Cdxx7/x21F8RH/xWBosqMSkR+C+vi9 5uTujSD4By7ywPmpR3Jt0WKvgbjg1ywcR6thQkm1ZN0xp+9a+2CsN9I4iiW2L+mvEPZM hF9AczXBYvbrTVTUyvRcXpDo7jZtoLtZz29y60VftsaLhGqLGibLv5+qqy2xHbjRb3a1 2i8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=XaQD4HxtDl+oY38Yst87FddHUnKE2OHe89TRs+klFa8=; b=ybPdXi8sXmkI76y+kfx2eC1CgwjFHW0howVAp9nq9m6zCLdeNu25j8JdZ0Q0jwkHwP tUDRz5m7JAKe3gbKjIKKAfoChiYpPpqoAxc2zj7wSyQEga1v5ovwiJj6WpLI1/0aYRSU dloAkJ/DKoUObdIUMc4Gxj0AsLV50RttHuyN2Wd+pIWuKFumOGErYDv4UYwtE/1QL1kA b/rSvezPqBAG4AJzI44li+8MmZQz5LPra080hWLIFDromUulUWqu1sjiXxfb7+Zxdgb/ u8zRmA98BRMkBSDnNE3aXmRiB9k9c7xvThfHxIglQdJHanK+VJr7s7w009GHPB5mVLLt u9MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=I2KYKKrD; 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 v8-v6si10221764plg.68.2018.04.22.13.28.27; Sun, 22 Apr 2018 13:28:41 -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=I2KYKKrD; 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 S1753790AbeDVU0v (ORCPT + 99 others); Sun, 22 Apr 2018 16:26:51 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35661 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753586AbeDVU0t (ORCPT ); Sun, 22 Apr 2018 16:26:49 -0400 Received: by mail-pg0-f65.google.com with SMTP id j11so6902418pgf.2 for ; Sun, 22 Apr 2018 13:26:49 -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:in-reply-to:references; bh=XaQD4HxtDl+oY38Yst87FddHUnKE2OHe89TRs+klFa8=; b=I2KYKKrDcbc1YhVpVGIJUEpfLUfE2mZR7vpTAPzAYJL07QFb/CcPMMyVfqbPGylTS3 cD345qbMiGW0b6yICSk2NPsbLYmD13V1SgcXhBKCQgPLh8VGt3IrxUSHxGQVa7WuLD1S bnhUE0ABDEzssf49U/G6AZvD9ii7hVRpp5DC9Q6aUCUmNgKUIFxXObhPPbnCfwC0mbtb 8OF5oXJuRM+4Bq95dhGgR0YURFU4kyipDpIW+nNYyKIUS0zucbEb5BNI1LT13IkbCDyZ YEMjEXc6Vnfi0/8uoHuSvLJN9F1/QnkH/6ys0LgfSoxU0+akqkRODNgfGI81FwYE1c4z YOsA== 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:in-reply-to :references; bh=XaQD4HxtDl+oY38Yst87FddHUnKE2OHe89TRs+klFa8=; b=gPXydeJBQyBI4dy0DE+pWj9CDsVDoh1JRvE0NQQbi7U/xpMwDN7Lrqt8jlmeqeUjX2 Vsl+P16cKqxrZuw3QOjPcqM/pM85Ak/z9tq09NdJdLmPRzjkDWNaK4MSGHw1Et5fA0bB yQpiCMP96JkyHdZsXxXXA0xFxQJ9/TZ6WckiF1S9QV1cjmGJUN/+DfYZKpa0rNdY3+D/ 6JZq5lxWHCMdSVMrLLODFQw/pF6xlAnIg+A5v41IDWpseSWbFdAiKj349YISkcgpLGRt mSTJQ7W/25KCGQhIx07riseKP1jTCIh4osRTXbZi/4kyGx9G10uy/XHjG23jU6HgM2f1 gYjg== X-Gm-Message-State: ALQs6tAuG67CyeM9WuWX65g+r54h2yH9m12rzDDOOtAIpXSMBjt7VBIF gpoFwR+Q63iWeznYzFKoikIAcA== X-Received: by 10.98.161.10 with SMTP id b10mr17514490pff.214.1524428808581; Sun, 22 Apr 2018 13:26:48 -0700 (PDT) Received: from gthelen.svl.corp.google.com ([2620:15c:2cb:201:7fd0:97b4:747b:9bf1]) by smtp.gmail.com with ESMTPSA id p1sm20512726pfp.48.2018.04.22.13.26.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Apr 2018 13:26:47 -0700 (PDT) From: Greg Thelen To: guro@fb.com, Johannes Weiner , Andrew Morton , Michal Hocko Cc: Vladimir Davydov , Tejun Heo , Cgroups , kernel-team@fb.com, Linux MM , LKML , Greg Thelen Subject: [RFC PATCH 1/2] memcg: fix memory.low Date: Sun, 22 Apr 2018 13:26:11 -0700 Message-Id: <20180422202612.127760-2-gthelen@google.com> X-Mailer: git-send-email 2.17.0.484.g0c8726318c-goog In-Reply-To: <20180422202612.127760-1-gthelen@google.com> References: <20180320223353.5673-1-guro@fb.com> <20180422202612.127760-1-gthelen@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When targeting reclaim to a memcg, protect that memcg from reclaim is memory consumption of any level is below respective memory.low. Signed-off-by: Greg Thelen --- mm/memcontrol.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 670e99b68aa6..9668f620203a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5341,8 +5341,8 @@ struct cgroup_subsys memory_cgrp_subsys = { * @root: the top ancestor of the sub-tree being checked * @memcg: the memory cgroup to check * - * Returns %true if memory consumption of @memcg, and that of all - * ancestors up to (but not including) @root, is below the normal range. + * Returns %true if memory consumption of @memcg, or any of its ancestors + * up to (but not including) @root, is below the normal range. * * @root is exclusive; it is never low when looked at directly and isn't * checked when traversing the hierarchy. @@ -5379,12 +5379,12 @@ bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg) if (memcg == root) return false; + /* If any level is under, then protect @memcg from reclaim */ for (; memcg != root; memcg = parent_mem_cgroup(memcg)) { - if (page_counter_read(&memcg->memory) >= memcg->low) - return false; + if (page_counter_read(&memcg->memory) <= memcg->low) + return true; /* protect from reclaim */ } - - return true; + return false; /* not protected from reclaim */ } /** -- 2.17.0.484.g0c8726318c-goog