Received: by 10.192.165.148 with SMTP id m20csp471869imm; Fri, 20 Apr 2018 09:40:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx49zVm1tdLVSUH1BmY/UYhYVyx870rZGygFYIUJ+fQoDLu/YJDg4PMYe980LIMoNoYaJNt27 X-Received: by 10.101.101.196 with SMTP id y4mr9123645pgv.129.1524242418052; Fri, 20 Apr 2018 09:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524242418; cv=none; d=google.com; s=arc-20160816; b=Kl3LjxqSKQ2ufEshcWiL3kLC9yKUL868OwrYJIysZQyZqimpHt8yU+SUHyZx9S6m0K RSzwSVRRZj7f4uLV2Ki2MKd19XAIJ6eFImMEVgoYg+GBJnnXfUwP2tlfuIutIWfD4QiP OYy3DVzeoQHWNgs8ovKfmp/HER/BAhJcA8u8QC9anEWYc7Y8P8CjVvEwn7CpEJg1ZYiA DCqcPCbSKPy3rKTnMuTtgl7EB0YtKA3VGNzHBOu1uI49aDLE7Pn4nDoMfk/zUjePkXX4 TUPIM9mM/bgOINTscwXXdRZaafz1Jb++oVf5/3Ng73Dlmke5R8u9ZM5qcnFzIzX8xnlP DM1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :arc-authentication-results; bh=nRKI63q3qHuSU9iZPYpZc8KH8rwFS21zfetGIo2WYqU=; b=Ql/sShQzPM8dw97mjxBEsT6VRIBj/HKhc2spWxhBOKH+xuz6xEj87Gmn+WrKeKxWM5 mUlBDuhzxJ9/mwoeinVfrNrB89ELirAR7fK3veoZuTHNSlgCqEtJI1ZjlKgeAzmeOuXb ZE70cZvdVIqBqcv+plrVnR0VoYwmNHTh/bXVf4TPoPAvbvBLCFTu/73mtNg6qv/9WpW/ pMAOfuQxQuOwaYoOEihWmy9Ss9h6Zd1/tnGMu0+RWdDIEv1AY64iRdyDB3gdl4936gbn SudeKyL2Nay3xFlYo8VtxSIsyWt5aqwCajgNnO0+VrdABJQ14+yd/DYTiBPuAVSn7co7 cmNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=lr6aqkui; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=DN/2Ce3J; 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 94-v6si5996252ple.56.2018.04.20.09.40.03; Fri, 20 Apr 2018 09:40:18 -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=lr6aqkui; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=DN/2Ce3J; 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 S1752801AbeDTQhk (ORCPT + 99 others); Fri, 20 Apr 2018 12:37:40 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:56044 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbeDTQhS (ORCPT ); Fri, 20 Apr 2018 12:37:18 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3KGUQEn012452; Fri, 20 Apr 2018 09:37:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=nRKI63q3qHuSU9iZPYpZc8KH8rwFS21zfetGIo2WYqU=; b=lr6aqkuiUBgcnNIfYG7F6DEU7pGNPIcdT+vnJyWDQEt3bEJ0OYoDCbPzmc+1uNDN2rzA rmocUHbRIxYjbd3xntVcmhx9GZnuOzuI1XPmCqS6SWrBSA97u00scFRg004I++XJCMVH 886dCpO8MhRJngq4q07hZdxEaSPXOEjUxPA= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2hfhgfgcx0-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 20 Apr 2018 09:37:06 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.26) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 20 Apr 2018 12:37:03 -0400 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=nRKI63q3qHuSU9iZPYpZc8KH8rwFS21zfetGIo2WYqU=; b=DN/2Ce3J6AasSNiAtiSMRSqKDD4dBdHDxXGq4rsOBt6DhoY55CxWtnIP4idsV5UjTDKY2SjexSuWmAIVvA1ZQiR+1gbo+OPuFQX9L9Cx/SaQaFhy2/nAhst21w0f29WPTDGTejSxY8YLVuztWXyhKqnAfaZXk2GSOxqc9uVUOX0= Received: from castle.thefacebook.com (2620:10d:c092:200::1:b8e3) by CO1PR15MB1078.namprd15.prod.outlook.com (2a01:111:e400:7b66::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Fri, 20 Apr 2018 16:36:55 +0000 From: Roman Gushchin To: CC: , , , Roman Gushchin , Johannes Weiner , Michal Hocko , Vladimir Davydov , Tejun Heo Subject: [PATCH 2/2] mm: move the high field from struct mem_cgroup to page_counter Date: Fri, 20 Apr 2018 17:36:32 +0100 Message-ID: <20180420163632.3978-2-guro@fb.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180420163632.3978-1-guro@fb.com> References: <20180420163632.3978-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:200::1:b8e3] X-ClientProxiedBy: CWLP265CA0178.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:4d::22) To CO1PR15MB1078.namprd15.prod.outlook.com (2a01:111:e400:7b66::8) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:CO1PR15MB1078; X-Microsoft-Exchange-Diagnostics: 1;CO1PR15MB1078;3:WF7lcZqD7+sY+Pkiw60SvyBNUR2t3w73g14aIZzg40CY26u1CLFDD7YAKM39FdZvOMSsHWPWr1m2t6d9B6ifUZKZSf+rkmqmAEfLEPD80QCOR1EEUHgj5a9o2WugeDYmNJJSvmLD8jE1Y0BeS1m0ZbB5/3q9MtIDTE4966JqEKSV+ffdbaRIqOm7Ngsb1lNG5cHRBfCRwhsnghjO2fDu+mU6cI6THfc0OfRZK7iLpE3Ik1SO7NxyhNb0mbEsdz1R;25:IgaK3eI7AHCtWAhp65SyCJG77UVT5VhnSI9ixDRB2Llm4HnXwOl4b+PiGbLJeBZeHL5XtnmfvDKDHqLiH3FklfAi0x/jNYHuQ67/IC9dGaUCE00Xmm1pAoLaO/Esfe6q+WtzdAzxwAIZ2XmkLZVv4IwgSydlxXg+jJxH/wqSiCKJjn47awV2oGZ/Xv0PRUGxe35fB1ARnwa7gUUtzjr29THlUMvpr/OUq0LIEwtS95eV9AXnBpw1oREk0Ip5x46njF+WwG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HKvt5tKS9DAaRz6/D41RECTxnAxVTsaTOHIiwjwj4O3vGk3xfbThcfsVpEO718/akqKVTwLdlOJPL9jfdl8u2oQm0w+gtRKp085EG0DhcdfL94o8LVClldS+qCQ9A3zPHkXEPp68m+UfmYwEQFES7DQ/vLKYqzQIs0sW99FGWibeEHJHt8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231232)(11241501184)(944501396)(52105095)(3002001)(93006095)(93001095)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011);SRVR:CO1PR15MB1078;BCL:0;PCL:0;RULEID:;SRVR:CO1PR15MB1078; X-Forefront-PRVS: 0648FCFFA8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39380400002)(39860400002)(376002)(346002)(366004)(2351001)(2361001)(53936002)(47776003)(25786009)(8936002)(36756003)(476003)(446003)(81166006)(11346002)(2616005)(6916009)(478600001)(52396003)(53416004)(46003)(8676002)(6506007)(386003)(76176011)(51416003)(1076002)(52116002)(59450400001)(6486002)(305945005)(7736002)(6116002)(16586007)(39060400002)(54906003)(50226002)(4326008)(316002)(48376002)(6512007)(86362001)(50466002)(16526019)(186003)(6666003)(2906002)(5660300001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:CO1PR15MB1078;H:castle.thefacebook.com;FPR:;SPF:None;LANG:en;MLV:ovrnspm;PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO1PR15MB1078;23:nWjvjAluk28v+gHJ3XYxDnmbvjbczCOKUsS1vrioj?= =?us-ascii?Q?+1V1iYyfDKfj45oJcmt5m8JsftihBicTcL2kz3P7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UMyu9YUsMYNoFdfFRPH6lxrqB3GEdiXg4nGFQyabrJQFK58jkD5VKuxIPtKv80G/ciR/gHOlJNct6tDwMJEF9YPm7OcqcCMPo=;24:Wzzhot8IRTPnAUPxyrPMS5bpIP0opELG6ZUG0frVWSluGtEtC9ze+FsXd3IvulmJDC3cxuK/fh+sTi294v9m7ZVAFg+xKPxz89lXn2zoYJU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CO1PR15MB1078;7:yYpeqRJ55FrX/NHo7tyx/sK5rPqTkw4qzp0Mh81BJCxT8gTbTSGw1LP+YmvZCFmQ9rgZoxECnv0cx1wrR6qm/+RYI//+8aCnvTUZV1ba/8wqE16TsYVrLZ7fyllnh1lWZvRoYrpVwW8UzsLD8N+fSpGAHxcwCeg3+1ddApYFb404YVxhhXuVVVXddaNSUKrDGJymYDKSgKPODf3EnLcAwjxIIXEJrEuLFPzJbFqiqADtPl7IZ2yq/R3UevI9zrp5;20:CloUuxbYCmfPW1B1BsH1NHOO0AuG3xINGuOe/sl37vjNDnCiA9kdq48MbiiUNOErQ2+mkks0OCP4/ovBZYZJ5z8CnD5JYQ8JP0YSxax4ro8O6bJeevnrKRhnODWMi2K7lxUt3ZYGEKVMiVOypWLw+Dlf6zIPtw6la9lnEZ+io/4= X-MS-Office365-Filtering-Correlation-Id: 1f925e82-d29e-4458-a37e-08d5a6dceecc X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2018 16:36:55.4384 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f925e82-d29e-4458-a37e-08d5a6dceecc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR15MB1078 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-20_07:,, 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 We do store memory.min, memory.low and memory.max actual values in struct page_counter fields, while memory.high value is located in the struct mem_cgroup directly, which is not very consistent. This patch moves the high field from struct mem_cgroup to struct page_counter to simplify the code and make handling of all limits/boundaries clearer. Signed-off-by: Roman Gushchin Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Tejun Heo --- include/linux/memcontrol.h | 3 --- include/linux/page_counter.h | 3 +++ mm/memcontrol.c | 18 +++++++++--------- mm/page_counter.c | 12 ++++++++++++ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 6ee19532f567..b89e060d0283 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -182,9 +182,6 @@ struct mem_cgroup { struct page_counter kmem; struct page_counter tcpmem; - /* Upper bound of normal memory consumption range */ - unsigned long high; - /* Range enforcement for interrupt charges */ struct work_struct high_work; diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h index bab7e57f659b..83999441a43e 100644 --- a/include/linux/page_counter.h +++ b/include/linux/page_counter.h @@ -10,6 +10,7 @@ struct page_counter { atomic_long_t usage; unsigned long min; unsigned long low; + unsigned long high; unsigned long max; struct page_counter *parent; @@ -38,6 +39,7 @@ static inline void page_counter_init(struct page_counter *counter, struct page_counter *parent) { atomic_long_set(&counter->usage, 0); + counter->high = PAGE_COUNTER_MAX; counter->max = PAGE_COUNTER_MAX; counter->parent = parent; } @@ -55,6 +57,7 @@ bool page_counter_try_charge(struct page_counter *counter, void page_counter_uncharge(struct page_counter *counter, unsigned long nr_pages); void page_counter_set_min(struct page_counter *counter, unsigned long nr_pages); void page_counter_set_low(struct page_counter *counter, unsigned long nr_pages); +void page_counter_set_high(struct page_counter *counter, unsigned long nr_pages); int page_counter_set_max(struct page_counter *counter, unsigned long nr_pages); int page_counter_memparse(const char *buf, const char *max, unsigned long *nr_pages); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9c65de7937d0..f9724dea017c 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1869,7 +1869,7 @@ static void reclaim_high(struct mem_cgroup *memcg, gfp_t gfp_mask) { do { - if (page_counter_read(&memcg->memory) <= memcg->high) + if (page_counter_read(&memcg->memory) <= memcg->memory.high) continue; memcg_memory_event(memcg, MEMCG_HIGH); try_to_free_mem_cgroup_pages(memcg, nr_pages, gfp_mask, true); @@ -2040,7 +2040,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, * reclaim, the cost of mismatch is negligible. */ do { - if (page_counter_read(&memcg->memory) > memcg->high) { + if (page_counter_read(&memcg->memory) > memcg->memory.high) { /* Don't bother a random interrupted task */ if (in_interrupt()) { schedule_work(&memcg->high_work); @@ -3857,7 +3857,8 @@ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages, *pheadroom = PAGE_COUNTER_MAX; while ((parent = parent_mem_cgroup(memcg))) { - unsigned long ceiling = min(memcg->memory.max, memcg->high); + unsigned long ceiling = min(memcg->memory.max, + memcg->memory.high); unsigned long used = page_counter_read(&memcg->memory); *pheadroom = min(*pheadroom, ceiling - min(ceiling, used)); @@ -4433,7 +4434,6 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css) if (!memcg) return ERR_PTR(error); - memcg->high = PAGE_COUNTER_MAX; memcg->soft_limit = PAGE_COUNTER_MAX; if (parent) { memcg->swappiness = mem_cgroup_swappiness(parent); @@ -4558,14 +4558,14 @@ static void mem_cgroup_css_reset(struct cgroup_subsys_state *css) { struct mem_cgroup *memcg = mem_cgroup_from_css(css); + page_counter_set_min(&memcg->memory, 0); + page_counter_set_low(&memcg->memory, 0); + page_counter_set_high(&memcg->memory, PAGE_COUNTER_MAX); page_counter_set_max(&memcg->memory, PAGE_COUNTER_MAX); page_counter_set_max(&memcg->swap, PAGE_COUNTER_MAX); page_counter_set_max(&memcg->memsw, PAGE_COUNTER_MAX); page_counter_set_max(&memcg->kmem, PAGE_COUNTER_MAX); page_counter_set_max(&memcg->tcpmem, PAGE_COUNTER_MAX); - page_counter_set_min(&memcg->memory, 0); - page_counter_set_low(&memcg->memory, 0); - memcg->high = PAGE_COUNTER_MAX; memcg->soft_limit = PAGE_COUNTER_MAX; memcg_wb_domain_size_changed(memcg); } @@ -5364,7 +5364,7 @@ static ssize_t memory_low_write(struct kernfs_open_file *of, static int memory_high_show(struct seq_file *m, void *v) { struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); - unsigned long high = READ_ONCE(memcg->high); + unsigned long high = READ_ONCE(memcg->memory.high); if (high == PAGE_COUNTER_MAX) seq_puts(m, "max\n"); @@ -5387,7 +5387,7 @@ static ssize_t memory_high_write(struct kernfs_open_file *of, if (err) return err; - memcg->high = high; + page_counter_set_high(&memcg->memory, high); nr_pages = page_counter_read(&memcg->memory); if (nr_pages > high) diff --git a/mm/page_counter.c b/mm/page_counter.c index de31470655f6..7f0013304afd 100644 --- a/mm/page_counter.c +++ b/mm/page_counter.c @@ -202,6 +202,18 @@ int page_counter_set_max(struct page_counter *counter, unsigned long nr_pages) } } +/** + * page_counter_set_high - set the upper soft boundary of pages allowed + * @counter: counter + * @nr_pages: limit to set + * + * The caller must serialize invocations on the same counter. + */ +void page_counter_set_high(struct page_counter *counter, unsigned long nr_pages) +{ + counter->high = nr_pages; +} + /** * page_counter_set_min - set the amount of protected memory * @counter: counter -- 2.14.3