From patchwork Tue Jul 3 15:09:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10504311 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 0838F601D3 for ; Tue, 3 Jul 2018 15:09:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7BEC28AAF for ; Tue, 3 Jul 2018 15:09:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBA1928B30; Tue, 3 Jul 2018 15:09:38 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 1AB6028AAF for ; Tue, 3 Jul 2018 15:09:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7BAE6B027B; Tue, 3 Jul 2018 11:09:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B2BBF6B027D; Tue, 3 Jul 2018 11:09:36 -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 A00486B027B; Tue, 3 Jul 2018 11:09:36 -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 52C336B027B for ; Tue, 3 Jul 2018 11:09:36 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id a20-v6so1210660pfi.1 for ; Tue, 03 Jul 2018 08:09:36 -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:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding:spamdiagnosticoutput :spamdiagnosticmetadata; bh=lGwDrx1nn6aZhN7pKlGi7jUOUb4d2BKvdbnM2cvitkk=; b=hUWVqgsJPhOXJnpSyzMaYghv0w0ash2WCzcyOyZqw2kec1QkotfmxilvzD/6S/krT0 i/JchAh7oIVVXcf3B+jCrsBcFQxp4lSa59dEASmCJjoxgOoi2HXoHys/uCcISPyIQAjy LYh8URvjiZ3yBn3rpmyGHCy86C2ZnWBSEMDbPK7FlwlxpTZMgCM33RtP1u8WFCkWYrsg UYD7bA+c/OpZI3QIFc2P69J3q4vuXipmISO/bqJqpgR1DCuC8MntJP5IQJoc5o7rPKmE eG5+Jd0pgOFRZC2EVV0lZEPymMHKLrGhATOMkzNsXavShQVrFrx58oxcyBtoY0wogJKu du3g== X-Gm-Message-State: APt69E0Amt+bsD6+N84Bt1n1lTlWu+zfTHW1nuqP5iAnwpiFO+b5abig 3CRvUK3bIiWLhjJirLSVfgve9LtSHBTfYC1CZCChYiRWx4gY6gVyd9Ia2WmhJUBdKqaiN7+Z0WQ joYiHraJEPiVyK7P+2gK6SqsUl1HqUUDH/JV3BfGwG/zHBUDZA9WDfOFV0gh77DMs3Q== X-Received: by 2002:a63:6e07:: with SMTP id j7-v6mr26464699pgc.251.1530630575977; Tue, 03 Jul 2018 08:09:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKYrFWuAOucaM3IDWzyOk1ygLar5GVXoxTyUq0B/4JkcZy7ejha/MLvUlXjYShesUHlMfwe X-Received: by 2002:a63:6e07:: with SMTP id j7-v6mr26464591pgc.251.1530630574219; Tue, 03 Jul 2018 08:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530630574; cv=none; d=google.com; s=arc-20160816; b=M4hvxJK4SoCFJQR9GcB0HT5k7txymvhh+cWw8z//Ue4BQDXImeKv6v0hcIbcfXLfOT VchKHDzEhumVGal/tUa49Yy64jqjo7ASg2pDDLT0/+jOBVilsbjTmJGEZbzlw9YVYAvQ yPwcp6ljj4HOXRcPQu2e9LKeWXvfnGpNFf67JQy7RPV9U5/ZNi9Luuyrun8e1Ab82+Do bZUV7/h9Nchm2TnBn8U/ZA4bRl9Z78OP76zhd+D3YAxbpoZ2rPzjI++cK04soFu7oP54 qhh35yGwqJ1YdiyfKLgxVWlrceDqvnV8ZsDymRLlp0S8BH4oJ42Fbd+4gQI+SCVmmlor iGzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=spamdiagnosticmetadata:spamdiagnosticoutput :content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:to:from:subject:dkim-signature :arc-authentication-results; bh=lGwDrx1nn6aZhN7pKlGi7jUOUb4d2BKvdbnM2cvitkk=; b=d55sBqB1MsvTQ4U6wxwOBDQanIoCwvJOajhX3ZcvfDd2lMX0+v2KMF2yVe2RZtk1fG 8RAlm8Zf/XQv5PidEiIPj63mImv6bI6z9Zx0fovnUw97nJIOIrmlharGcOgXlyZFF49F U/PqwPVW+4r15iJGrwWDw8WCKpprXkD4WrzZ//l8F1HpseyQ3pYdArujPPQuUXx8JtNM 6BT3NrCVy0XxUzBGc30wHpqNo6nNMqGwt3XETxfiuL53Gv/4BUHhYmteSJyp4hoe+fnw kMFnp+cLuGqKD/c5hcgCGHoFhjhFcaB1D+M6NjzVnb/boulCSx9OWJYG+bEbtN7MPu1B 8f8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=WtTkU8kl; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.2.117 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0117.outbound.protection.outlook.com. [104.47.2.117]) by mx.google.com with ESMTPS id t70-v6si1195497pgc.481.2018.07.03.08.09.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Jul 2018 08:09:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.2.117 as permitted sender) client-ip=104.47.2.117; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=WtTkU8kl; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.2.117 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lGwDrx1nn6aZhN7pKlGi7jUOUb4d2BKvdbnM2cvitkk=; b=WtTkU8kljaeNHqg7B5shFa00tWkGTIzcluaVmeeFs0XDGTNLxEblbR1v8MVU+xTEHC+kXhNYELJz+Kyzw/1KcUTmtUbBofm9GzqIMNtEOb6GRGWl0NeQfOOMkQUV1MxsA49waQ4zMvxeW4YmXa6dWFSSLSiq/wmLmQznid2YCB0= Received: from localhost.localdomain (185.231.240.5) by DB6PR0801MB1334.eurprd08.prod.outlook.com (2603:10a6:4:a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.18; Tue, 3 Jul 2018 15:09:29 +0000 Subject: [PATCH v8 05/17] mm: Assign memcg-aware shrinkers bitmap to memcg From: Kirill Tkhai To: vdavydov.dev@gmail.com, shakeelb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, tglx@linutronix.de, pombredanne@nexb.com, stummala@codeaurora.org, gregkh@linuxfoundation.org, sfr@canb.auug.org.au, guro@fb.com, mka@chromium.org, penguin-kernel@I-love.SAKURA.ne.jp, chris@chris-wilson.co.uk, longman@redhat.com, minchan@kernel.org, ying.huang@intel.com, mgorman@techsingularity.net, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, lirongqing@baidu.com, aryabinin@virtuozzo.com, akpm@linux-foundation.org, ktkhai@virtuozzo.com Date: Tue, 03 Jul 2018 18:09:26 +0300 Message-ID: <153063056619.1818.12550500883688681076.stgit@localhost.localdomain> In-Reply-To: <153063036670.1818.16010062622751502.stgit@localhost.localdomain> References: <153063036670.1818.16010062622751502.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: DB6P193CA0011.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::21) To DB6PR0801MB1334.eurprd08.prod.outlook.com (2603:10a6:4:a::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cfac2bf8-4bbf-435e-07b0-08d5e0f6fa94 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:DB6PR0801MB1334; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1334; 3:/qxvYNCrkQwkaMiujbzFCMb/QadDRlrkB/zpTif7N4gj2U3pXQfN0+P70aOP6BbXEq2pmMUBiy5qkdzIku37h8UPGfJWEYKvS1rdiYNIuZMk61D+h2IqWpS9Gk64q4R4B53gtk2R7uUPZbMZF7oZ1oaKHP7MatfSnUsj3drVMpn7KYx634myqjdrJU7PLQEorqfmwgCm2mH+4wdSxVQ36mBJlCiV4LmkHAn1obM//7UXUxQ/D9DbvzWTdW7oFFsx; 25:gk19Uhpx5/zmlQsogppaTuP5ieIayiDdjWvEVvJ6vg+JSFBG6WaXhh1zzgQEpdGIseuPnHRzWgfBub0bgccXsVQETFC2Iqcb8XspyCeK27Z2pDBkEhJJW5smroi42Wusxv3QBjoYRgLIp3BJ8ipmO/VbfM2ByqjKS3fpj2U1+gmUj+ovBMOwm3udqU5DUGIeMYSPZ7IqJi/ICciEXhzykL0SUCj4nYdL2+StF4K73oYrhz4x8FvLvco6eqg49RIX/23fkt4xZ6u1InBL0zdaxJXfam+g8UlvOrqn/4B+SMC3vjKMDOYuhKeAaWxCTQxKB/v9DKCHLwzMXMRYEGQAqA==; 31:G/gQvE9H/cSuDHaeKS8HGhvzrFnINY9KsojJOJ/puWZ5QOzw4oP5HDosZkteNfarPwM1eDZLZTsAZcN33DKocpatyUdtWsk/mixmDCLL4l74Kq+SVomPyzCSwVdwCUE4SS4i3EcCwuMye2g8S4E0JiVorMpqlpQHSz6biMQwJFVp5C/PJNHDguGE1DuGgWcwHK0wZh5f6xs5Dj3kEkEeGmxYs4WlZMi+Uk7Ans2FcYY= X-MS-TrafficTypeDiagnostic: DB6PR0801MB1334: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1334; 20:YA779x2g1IPjjOvgb+VUTZI2XnaoPC85NMXiwbAyHMOIVuuNo4JV5nxl5t/FJDd5Ywp98U4Tg39pqZBKCUIgI0eHguyYCx96GtQRnvCDSwlPgpGZnbsZ55WPBs/qZ+u2H3bBSD5+WfqESg2YFhlpL/xZnXOQJ17wVGFkQIdSd8G5TrgwztohNAAFICw1NShvrPtCVGzkkuiyQG1q0Gmq3jGKiGSbdyzN/35YF7T5afFieH0eNuSXgCkEe8J20a/947+eCBxiN2dza7O8sNyH3YmOEJxhqkF8Yb6ZwqTGgoGfJW5Q3LZ4BGFxZSYWgqiYcRNrS65fXIBrSyzMuTSRXdfLBkAYYNMRJdfL7Aomu+C4guvi6t2K0o6o2SngKqmGxC5aPEH6z+co48Z4JxZmkh1D+OuXt2HZ2TxWaWrrimG5vvh7pOX/A0gEu9w3Zj/TEWO1F34/+RmoqQseWZHGhljHyQY1irX/dcC8w39a+N2vsakoh7hDRXgjP7C7YUE6 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(209352067349851)(131327999870524)(85827821059158)(211936372134217)(153496737603132); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231280)(944501410)(52105095)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:DB6PR0801MB1334; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB1334; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1334; 4:NvZ7bQ4+/pBUOI9oYjno7WqrXWCOFcnVh6S9mu3OjW9xv52GatfWPeHW6T7EtFzgprDO60o3vMXeZy59ydekBfJom54qFln+r5n8DrWJzESFryD7vbvsnTJjfuaSGHzZLtXM/0iXR7MHw0BKUkE0E3S1/6UqDZ95KggIgmplbWI993Ed+lQQlC6lu09ErHoEQHn/+U2IIqThOYXIgdIGC+xoS08xWdpKco4WlWcJX6xZYh0K7DaNCR5xX+T3gf6NAERnA7OdUlRZPJQ9r1M8xPrReQ1KLQUdZqR9stZMynaRWQBN8NUu98wvWOK4t1Mb0Siv+B2HK1KGWuiCTBDYCQmMspKuVWOppTpgNOlcQJedKRxxXAJLTZOfAMpPfKS+VF0Jc/hcOQBrNXbFsUYHZSeZcp+U6nfOyiZtqVQxdWVZNVRuYEgy4yw7OBlgqueASvi4bSF18mCiTJKcR5ZQmg== X-Forefront-PRVS: 0722981D2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(136003)(376002)(366004)(396003)(39850400004)(346002)(189003)(199004)(53936002)(5660300001)(39060400002)(6116002)(3846002)(106356001)(23676004)(316002)(2486003)(86362001)(478600001)(33896004)(7696005)(105586002)(52116002)(76176011)(6666003)(7736002)(50466002)(8936002)(305945005)(7416002)(81156014)(81166006)(230700001)(386003)(25786009)(2906002)(6506007)(8676002)(66066001)(103116003)(68736007)(97736004)(14444005)(486006)(26005)(186003)(956004)(58126008)(16526019)(9686003)(61506002)(47776003)(55016002)(446003)(476003)(11346002)(921003)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0801MB1334; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjZQUjA4MDFNQjEzMzQ7MjM6cjZudU1MOVZrVVVFVTVrSVc3TFhSZGdW?= =?utf-8?B?ZFp2Y2NUN1k0dU5rcDdXVktGbW04RE56d3dUWkRGeWNIZjlva0tCL09YVmFw?= =?utf-8?B?eUNvVXJ1RCtkVncwQmZIYmlpS1BwcVBXN3VxNlNWbnVkbUpjRFdBZUVzZ0pm?= =?utf-8?B?bDNPUUh0bHVLSTdHQkJ3d0ZHWTh4UjZvUmc2NGthbkF6TEMvZUVkQ3pLMWkr?= =?utf-8?B?VmpwOFhDUnpBTU5DK2hia3huYVQ2WkZYTFVoNWRxa3hlU21VVHVqSHVTbnJT?= =?utf-8?B?dlJlbkIxajFRM2VaUithbCtxUkcxTEdRWW1vVXhVelVYam5yWUM2a3B3bHFZ?= =?utf-8?B?R3lZdWljTVEwdk9RKzN1dzlxajcvNHF4QkNLRWtxYW40c0pmWUp2TFZ3WUhF?= =?utf-8?B?ekkyZ1NtUGRBMUJTOG1mODBPZStSQ2tiVWNNaUsvWj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CiHB1TEqTAGeRfz4ck3IFIJ1f93kWPiGIlf/TUkgDPclcU0v4X8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2018 15:09:29.4509 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cfac2bf8-4bbf-435e-07b0-08d5e0f6fa94 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1334 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 Imagine a big node with many cpus, memory cgroups and containers. Let we have 200 containers, every container has 10 mounts, and 10 cgroups. All container tasks don't touch foreign containers mounts. If there is intensive pages write, and global reclaim happens, a writing task has to iterate over all memcgs to shrink slab, before it's able to go to shrink_page_list(). Iteration over all the memcg slabs is very expensive: the task has to visit 200 * 10 = 2000 shrinkers for every memcg, and since there are 2000 memcgs, the total calls are 2000 * 2000 = 4000000. So, the shrinker makes 4 million do_shrink_slab() calls just to try to isolate SWAP_CLUSTER_MAX pages in one of the actively writing memcg via shrink_page_list(). I've observed a node spending almost 100% in kernel, making useless iteration over already shrinked slab. This patch adds bitmap of memcg-aware shrinkers to memcg. The size of the bitmap depends on bitmap_nr_ids, and during memcg life it's maintained to be enough to fit bitmap_nr_ids shrinkers. Every bit in the map is related to corresponding shrinker id. Next patches will maintain set bit only for really charged memcg. This will allow shrink_slab() to increase its performance in significant way. See the last patch for the numbers. Signed-off-by: Kirill Tkhai Acked-by: Vladimir Davydov Tested-by: Shakeel Butt --- include/linux/memcontrol.h | 14 +++++ mm/memcontrol.c | 120 ++++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 5 ++ 3 files changed, 139 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 62309f180ee6..d8c38eafa251 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -113,6 +113,15 @@ struct lruvec_stat { long count[NR_VM_NODE_STAT_ITEMS]; }; +/* + * Bitmap of shrinker::id corresponding to memcg-aware shrinkers, + * which have elements charged to this memcg. + */ +struct memcg_shrinker_map { + struct rcu_head rcu; + unsigned long map[0]; +}; + /* * per-zone information in memory controller. */ @@ -126,6 +135,9 @@ struct mem_cgroup_per_node { struct mem_cgroup_reclaim_iter iter[DEF_PRIORITY + 1]; +#ifdef CONFIG_MEMCG_KMEM + struct memcg_shrinker_map __rcu *shrinker_map; +#endif struct rb_node tree_node; /* RB tree node */ unsigned long usage_in_excess;/* Set to the value by which */ /* the soft limit is exceeded*/ @@ -1284,6 +1296,8 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg) return memcg ? memcg->kmemcg_id : -1; } +extern int memcg_expand_shrinker_maps(int new_id); + #else #define for_each_memcg_cache_index(_idx) \ for (; NULL; ) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 74247a580cdd..f81581e26667 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -320,6 +320,120 @@ EXPORT_SYMBOL(memcg_kmem_enabled_key); struct workqueue_struct *memcg_kmem_cache_wq; +static int memcg_shrinker_map_size; +static DEFINE_MUTEX(memcg_shrinker_map_mutex); + +static void memcg_free_shrinker_map_rcu(struct rcu_head *head) +{ + kvfree(container_of(head, struct memcg_shrinker_map, rcu)); +} + +static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg, + int size, int old_size) +{ + struct memcg_shrinker_map *new, *old; + int nid; + + lockdep_assert_held(&memcg_shrinker_map_mutex); + + for_each_node(nid) { + old = rcu_dereference_protected( + mem_cgroup_nodeinfo(memcg, nid)->shrinker_map, true); + /* Not yet online memcg */ + if (!old) + return 0; + + new = kvmalloc(sizeof(*new) + size, GFP_KERNEL); + if (!new) + return -ENOMEM; + + /* Set all old bits, clear all new bits */ + memset(new->map, (int)0xff, old_size); + memset((void *)new->map + old_size, 0, size - old_size); + + rcu_assign_pointer(memcg->nodeinfo[nid]->shrinker_map, new); + if (old) + call_rcu(&old->rcu, memcg_free_shrinker_map_rcu); + } + + return 0; +} + +static void memcg_free_shrinker_maps(struct mem_cgroup *memcg) +{ + struct mem_cgroup_per_node *pn; + struct memcg_shrinker_map *map; + int nid; + + if (mem_cgroup_is_root(memcg)) + return; + + for_each_node(nid) { + pn = mem_cgroup_nodeinfo(memcg, nid); + map = rcu_dereference_protected(pn->shrinker_map, true); + if (map) + kvfree(map); + rcu_assign_pointer(pn->shrinker_map, NULL); + } +} + +static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg) +{ + struct memcg_shrinker_map *map; + int nid, size, ret = 0; + + if (mem_cgroup_is_root(memcg)) + return 0; + + mutex_lock(&memcg_shrinker_map_mutex); + size = memcg_shrinker_map_size; + for_each_node(nid) { + map = kvzalloc(sizeof(*map) + size, GFP_KERNEL); + if (!map) { + memcg_free_shrinker_maps(memcg); + ret = -ENOMEM; + break; + } + rcu_assign_pointer(memcg->nodeinfo[nid]->shrinker_map, map); + } + mutex_unlock(&memcg_shrinker_map_mutex); + + return ret; +} + +int memcg_expand_shrinker_maps(int new_id) +{ + int size, old_size, ret = 0; + struct mem_cgroup *memcg; + + size = DIV_ROUND_UP(new_id + 1, BITS_PER_BYTE); + old_size = memcg_shrinker_map_size; + if (size <= old_size) + return 0; + + mutex_lock(&memcg_shrinker_map_mutex); + if (!root_mem_cgroup) + goto unlock; + + for_each_mem_cgroup(memcg) { + if (mem_cgroup_is_root(memcg)) + continue; + ret = memcg_expand_one_shrinker_map(memcg, size, old_size); + if (ret) + goto unlock; + } +unlock: + if (!ret) + memcg_shrinker_map_size = size; + mutex_unlock(&memcg_shrinker_map_mutex); + return ret; +} +#else /* CONFIG_MEMCG_KMEM */ +static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg) +{ + return 0; +} +static void memcg_free_shrinker_maps(struct mem_cgroup *memcg) { } #endif /* CONFIG_MEMCG_KMEM */ /** @@ -4541,6 +4655,11 @@ static int mem_cgroup_css_online(struct cgroup_subsys_state *css) { struct mem_cgroup *memcg = mem_cgroup_from_css(css); + if (memcg_alloc_shrinker_maps(memcg)) { + mem_cgroup_id_remove(memcg); + return -ENOMEM; + } + /* Online state pins memcg ID, memcg ID pins CSS */ atomic_set(&memcg->id.ref, 1); css_get(css); @@ -4593,6 +4712,7 @@ static void mem_cgroup_css_free(struct cgroup_subsys_state *css) vmpressure_cleanup(&memcg->vmpressure); cancel_work_sync(&memcg->high_work); mem_cgroup_remove_from_trees(memcg); + memcg_free_shrinker_maps(memcg); memcg_free_kmem(memcg); mem_cgroup_free(memcg); } diff --git a/mm/vmscan.c b/mm/vmscan.c index f9ca6b57d72f..d8b1958c751d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -182,6 +182,11 @@ static int prealloc_memcg_shrinker(struct shrinker *shrinker) if (id < 0) goto unlock; + if (memcg_expand_shrinker_maps(id)) { + idr_remove(&shrinker_idr, id); + goto unlock; + } + if (id >= shrinker_nr_max) shrinker_nr_max = id + 1; shrinker->id = id;