Received: by 10.213.65.68 with SMTP id h4csp565687imn; Fri, 6 Apr 2018 05:24:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+BJdvH3Kbwh34hPvetvoIczNe7Gc45UYxqSNzTqcHOZQ54Cd5fFtkCBdpqmqHVStJlc9jc X-Received: by 2002:a17:902:1c1:: with SMTP id b59-v6mr27041404plb.325.1523017451911; Fri, 06 Apr 2018 05:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523017451; cv=none; d=google.com; s=arc-20160816; b=gP8DVBElonIhz7JkQzufsiyomK2nT9eSoFwNKffF7QreUqr7ieSEup96KK6lLTB55v oTwYioRLMWWuZ4xWmTcjkAlvmNkt7ZkYyERAzk+SK4jjujp2q7MjXU+8vWOwJPDDgigo lp0FVtqT50fwYs7aF0mW/Z355libwB/f0/sMd5vQeR95bQfuQ1i390I8RN5JHEz5I28h TMLyNm79A1N5XJkukibE+Vgbn6XXSTa0C1z8HYyU0xdn234FOic2rBbv3hPNps0FQkSH khopvL32yht2Xlrd+q4WgSqJ94NiOEheK0YhgM8WLZxivFiYA/oxO2HnwoQ/HTLuuIui rIDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature:arc-authentication-results; bh=pPtDANZSiHG9yF4YVpKebRQ2IKfNPZmH1lePnuLIOFM=; b=YFtucSXpCfAIVG6o87uLPit6VFtnuto4+DgwAWQRoXb/e636D6HgRQtq8RosfvDLfJ VuoSuTAxZ97rYFWp4h6ZbggK7vpLY9B48QD0nWj+xmMb4+u9Xn5FfR+oxJxACDb/9PAu VlpLRibBd4JvGByhsqyw0dRq7lMoRlUM1qo9S4REVPImXvuEKEJwKMO4hzh4o6mxxdpW H6/EsYO9NZ+te5+go/XODizl6NqEDm4jsq0RjaE48I4ASGJcYfYNt9S6Z0HsOHNMK+tK hrePscpUWy0gWPnGxkRzzI6QJLcDcokrFRFrnprYeRGaqRw7IBQvpyjDXBX9M0TnavhH wwbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=k17xki9I; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=ecgm9sWe; 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=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si7213188pgt.61.2018.04.06.05.23.57; Fri, 06 Apr 2018 05:24:11 -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=@fb.com header.s=facebook header.b=k17xki9I; dkim=fail header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=ecgm9sWe; 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=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752334AbeDFMWS (ORCPT + 99 others); Fri, 6 Apr 2018 08:22:18 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:60744 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752114AbeDFMWP (ORCPT ); Fri, 6 Apr 2018 08:22:15 -0400 Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w36CF9jj022887; Fri, 6 Apr 2018 05:22:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=facebook; bh=pPtDANZSiHG9yF4YVpKebRQ2IKfNPZmH1lePnuLIOFM=; b=k17xki9I+MTEYp/m+m7OXvFeAfQEiieRRsleo99AMpEYLnaKzVMXIcJeHFfOfxViyzky zsVqidMUrgAi0j7A4epsyvGpUogDXOa2H6L8nQNYTR+zLGCExCm+3Sn7AB4t+TD6Y6tQ WB8rl3E3j47hhmp83w2COvwVs3WGOmvCi04= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2h68nyg0tp-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 06 Apr 2018 05:22:05 -0700 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.23) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 6 Apr 2018 05:22:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=pPtDANZSiHG9yF4YVpKebRQ2IKfNPZmH1lePnuLIOFM=; b=ecgm9sWem44V2LoWzj65dA+KBreiubR00GB3COmKjYnlWZozYoHElaRPeoJBiGbCGKhrSedXbj9jaYKEZx2PBHIFzAXUOZ5KenlNwZopnUaBQlIVTGoBJ7rnAVvIqtqy33vG4vkrTibHSTRrXBrYnaxVyhcKTPkd/oEAbGhX360= Received: from castle (2620:10d:c092:180::1:20dc) by BL2PR15MB1074.namprd15.prod.outlook.com (2603:10b6:201:17::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.653.12; Fri, 6 Apr 2018 12:21:58 +0000 Date: Fri, 6 Apr 2018 13:21:38 +0100 From: Roman Gushchin To: Johannes Weiner CC: , Andrew Morton , Michal Hocko , Vladimir Davydov , Tejun Heo , , , Subject: Re: [PATCH v3 3/4] mm: treat memory.low value inclusive Message-ID: <20180406122132.GA7185@castle> References: <20180405185921.4942-1-guro@fb.com> <20180405185921.4942-3-guro@fb.com> <20180405194526.GC27918@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180405194526.GC27918@cmpxchg.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-Originating-IP: [2620:10d:c092:180::1:20dc] X-ClientProxiedBy: HE1PR05CA0301.eurprd05.prod.outlook.com (2603:10a6:7:93::32) To BL2PR15MB1074.namprd15.prod.outlook.com (2603:10b6:201:17::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db1430ca-3355-4cb3-2035-08d59bb8ff4f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:BL2PR15MB1074; X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB1074;3:aJtDxSaZ7P3Z5DFyyCaL0J/v0vQinKK66j2RyYLOS2mZEnWgnBiZVrPac4hSUcuw/WWD/NcHUPqz1k/j6J1UiWePl4sGH8MwI5ATsON3yYshQTyGGsYXvKuRk2ZlBp/4sCHSNrlnVu5SC4O1J5dhxX+Bsq262WotM3Z8biNFbKTi/8hENU3b5sGhv7xHJZCzq49THWPx42gRgmMSMrvx1eIe56wMizOX3rZrpwigy5YmdLa243mQ6GhJxpAsIWhO;25:Kr1Ibe8gi0/Qde6ro5lElqVQAn/UylcN5tjqZ0JgUle6i2m+82QV3nEsa9m2q9X8v/Kh64hdigLxm1JLyRDbRFYQB58UYZxiXkmQVL1dbDKRKWtmF8t0uS1NfDaC7WH40yjvHPz/QvthgCzYd2yhvwl48kZ5MM7jIJa7jJTI3ukBDGRqCB3cpLMVhylfPu42PYLh67SowdwPdS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GjN4iDttgW42LSa82d7E+KgBUd2auKKw8HFGyZnECvXojSt89980xEEhw/WKCSFboOPyVPibvDVFe+NmoxOUdRyYPBVR+KUGcbxuphYOWvmGa0+XDyNhIMhVdpthoriY6sQIyzinbYUE+xZ6YNHx+KBiNyabICWXX9HJLVy7e6EPOk5YPm6YcqZKQS6245mKXg3EfdPCxZfB4mn+O5eFecZLYE3mOUdtB6KX55vMOfPv972zhiKQxCtQIwhv22mCKDOK2mQ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(85827821059158)(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231221)(11241501184)(944501327)(52105095)(10201501046)(93006095)(93001095)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:BL2PR15MB1074;BCL:0;PCL:0;RULEID:;SRVR:BL2PR15MB1074; X-Forefront-PRVS: 0634F37BFF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39860400002)(346002)(376002)(396003)(39380400002)(366004)(199004)(189003)(11346002)(81156014)(2906002)(39060400002)(8676002)(476003)(106356001)(5660300001)(229853002)(6246003)(9686003)(8936002)(81166006)(33896004)(59450400001)(25786009)(386003)(105586002)(6916009)(52116002)(446003)(4326008)(68736007)(6666003)(55016002)(97736004)(76176011)(478600001)(33716001)(50466002)(16526019)(46003)(23726003)(86362001)(33656002)(7736002)(316002)(53936002)(52396003)(54906003)(16586007)(186003)(6116002)(58126008)(53546011)(305945005)(6496006)(1076002)(486006)(47776003)(18370500001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR15MB1074;H:castle;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =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aUEGE7ICC1cSb/ytA30TGLYhXWAt?= =?us-ascii?Q?e7mmk/fNZNh+BnVubUNAe3Rit0XMOS7RsGr+4ZxfxtiqUIr+NvX88TX0z6a5?= =?us-ascii?Q?28FeCkhRw75r+6b55u+i5M9BUwKI3KEu5LWE0bNzLe6FEugQ2VKkMJulq87k?= =?us-ascii?Q?BNkxy+NN1PL7eZmYMB40uevVXeAXg+NzsRlS7m/zUJ1YWYCx/FzHmy4Ydpq6?= =?us-ascii?Q?gdnK8Kzg+fecQRp3e8dPbGJoKvPiEEir0tSKl+h953QMbBMdZe94xJRp7VhB?= =?us-ascii?Q?Bch8r420j23HFSwk19I11IjU5xJxmOMwS0QYIT8yQaK87OZOqA6/tnBCUfq5?= =?us-ascii?Q?a7qKmZCT6zeFLgSBKHEmY9kvmAHMZv0jwCM7UuYIdzRw7ovFv+vC1/0Zk9gx?= =?us-ascii?Q?RetBnpXtjtjG1CyWZj95V7CLVqcCODbfQM3GumZML4F/krsxmAQPa9ZMX09D?= =?us-ascii?Q?E5eIjUxFhWVixoWxZDWCQynLVyQwXFIMSfRmpJhlUEoXuv8+j4XU5gxazGIk?= =?us-ascii?Q?vUu6g=3D=3D?= X-Microsoft-Antispam-Message-Info: 3jqSy3XWRduaw1D5tQQM0yHLtkp7Yjo3JbPR6yGY9NO6yedeqBYhGdoylM2yoRL4B7kkkQJPAOkKgAuZQkBLw++FgymdpiC+nxZjO6P7FUWD/SBP064SuXA70blhbnmMP7VXrtrFdHOYZqUCX3vFVqjx7F1eauHNDDaeD7HeusNeKwdz/oSlPLCUAaMhimD0 X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB1074;6:jcVVEbIkJm16kICiPqN2LMZIUpslspqp7jAujIXLdNSIfBhT//ry76L2zFgwqV59nRbW31VgbXSQj8oadgK0AoevUnXFVGOVQoO72ztdovZbZML+iH1sfwcFjF+7scpZ4abCGG/ooEy2FCnOSTqjxTjYm2ejxxfr5Z9ifgaxCx6/rUMEvzppwWX6u0Xs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= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2018 12:21:58.0547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db1430ca-3355-4cb3-2035-08d59bb8ff4f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR15MB1074 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-04-06_06:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 05, 2018 at 03:45:26PM -0400, Johannes Weiner wrote: > On Thu, Apr 05, 2018 at 07:59:20PM +0100, Roman Gushchin wrote: > > If memcg's usage is equal to the memory.low value, avoid reclaiming > > from this cgroup while there is a surplus of reclaimable memory. > > > > This sounds more logical and also matches memory.high and memory.max > > behavior: both are inclusive. > > I was trying to figure out why we did it this way in the first place > and found this patch: > > commit 4e54dede38b45052a941bcf709f7d29f2e18174d > Author: Michal Hocko > Date: Fri Feb 27 15:51:46 2015 -0800 > > memcg: fix low limit calculation > > A memcg is considered low limited even when the current usage is equal to > the low limit. This leads to interesting side effects e.g. > groups/hierarchies with no memory accounted are considered protected and > so the reclaim will emit MEMCG_LOW event when encountering them. > > Another and much bigger issue was reported by Joonsoo Kim. He has hit a > NULL ptr dereference with the legacy cgroup API which even doesn't have > low limit exposed. The limit is 0 by default but the initial check fails > for memcg with 0 consumption and parent_mem_cgroup() would return NULL if > use_hierarchy is 0 and so page_counter_read would try to dereference NULL. > > I suppose that the current implementation is just an overlook because the > documentation in Documentation/cgroups/unified-hierarchy.txt says: > > "The memory.low boundary on the other hand is a top-down allocated > reserve. A cgroup enjoys reclaim protection when it and all its > ancestors are below their low boundaries" > > Fix the usage and the low limit comparision in mem_cgroup_low accordingly. > > > @@ -5709,7 +5709,7 @@ bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg) > > elow = min(elow, parent_elow * low_usage / siblings_low_usage); > > exit: > > memcg->memory.elow = elow; > > - return usage < elow; > > + return usage <= elow; > > So I think this needs to be usage && usage <= elow to not emit > MEMCG_LOW events in case usage == elow == 0. Perfect catch! Thanks, Johannes! Updated version below. -- From 466c35c36cae392cfee5e54a2884792972e789ee Mon Sep 17 00:00:00 2001 From: Roman Gushchin Date: Thu, 5 Apr 2018 19:31:35 +0100 Subject: [PATCH v4 3/4] mm: treat memory.low value inclusive If memcg's usage is equal to the memory.low value, avoid reclaiming from this cgroup while there is a surplus of reclaimable memory. This sounds more logical and also matches memory.high and memory.max behavior: both are inclusive. Empty cgroups are not considered protected, so MEMCG_LOW events are not emitted for empty cgroups, if there is no more reclaimable memory in the system. Signed-off-by: Roman Gushchin Cc: Andrew Morton Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Tejun Heo Cc: kernel-team@fb.com Cc: linux-mm@kvack.org Cc: cgroups@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- mm/memcontrol.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 78cf21f2a943..3d039fa1a8f5 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5608,14 +5608,14 @@ struct cgroup_subsys memory_cgrp_subsys = { }; /** - * mem_cgroup_low - check if memory consumption is below the normal range + * mem_cgroup_low - check if memory consumption is in the normal range * @root: the top ancestor of the sub-tree being checked * @memcg: the memory cgroup to check * * WARNING: This function is not stateless! It can only be used as part * of a top-down tree iteration, not for isolated queries. * - * Returns %true if memory consumption of @memcg is below the normal range. + * Returns %true if memory consumption of @memcg is in the normal range. * * @root is exclusive; it is never low when looked at directly * @@ -5709,7 +5709,7 @@ bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg) elow = min(elow, parent_elow * low_usage / siblings_low_usage); exit: memcg->memory.elow = elow; - return usage < elow; + return usage && usage <= elow; } /** -- 2.14.3