From patchwork Mon Jun 18 09:45:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10470531 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 60418600CC for ; Mon, 18 Jun 2018 09:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EB1A28474 for ; Mon, 18 Jun 2018 09:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 403B22899F; Mon, 18 Jun 2018 09:45:49 +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 67BBF28474 for ; Mon, 18 Jun 2018 09:45:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B1126B0266; Mon, 18 Jun 2018 05:45:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 538096B0269; Mon, 18 Jun 2018 05:45:47 -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 3B2F56B0270; Mon, 18 Jun 2018 05:45:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id B96436B0266 for ; Mon, 18 Jun 2018 05:45:46 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id g73-v6so5188451wmc.5 for ; Mon, 18 Jun 2018 02:45:46 -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=4y5sfJ/QaL+x8vGX7W70MN1TQaB+eCXDtCFWbXxuV6w=; b=soaeOKLPXg4urn7sBHKk8GEE41jDKVuwOr399TYXjfOV2HFs57gXeBnim/udGCjAxA 5wKQ9fevACF59utZTDzrhzly6JVxGN6Gdvja3uBJ0aXDPcYwcvJ3MAw97SF5kdRkf56K FusymIBAduPMwbUlDtc8BdDvufXaHhf9q/ZlWntIdQvwKEWc/m5l+IyqzwmpufkkiscZ gW/Ph91GTsPF81zNkVjHU6EjZhZxy4+3AZuj+z6v84HEDbrSVQxV3NPEIs/wTpFgt/vf QD/Fxv5k5HSQyNUKNdWEWZAbxxPqz93bfspTdogoP7F6ja5mXNP/9u4G08YS4OLG7lUA OV6A== X-Gm-Message-State: APt69E0mC0R1GITGPrFFEycOd0TTh25BykerRT93acqvOl/WcrYb0yPH Ra/ia4/VA54iXy+cyp9ddVwUyI7O2lo++8XiGK28Uyhn9S5DE+5WCwdgh0/4FE3F8i+3ekNHwGi zPzWj6vP9OvaguObplSHpmGETfckntqUnAmZ6arXEy1S80lqA83X7kzzrOMshVnb0tQ== X-Received: by 2002:a50:ce03:: with SMTP id y3-v6mr10518544edi.300.1529315146274; Mon, 18 Jun 2018 02:45:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLo1PutGTLhM9uGnml2iQO6erWGNtwemdQvc6eB3v/2eJ5DBsSCm8DPgD/6FCNK8n1ULsrZ X-Received: by 2002:a50:ce03:: with SMTP id y3-v6mr10518487edi.300.1529315145162; Mon, 18 Jun 2018 02:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529315145; cv=none; d=google.com; s=arc-20160816; b=JV9qdnItClHTPYE+CavzZKZViOXJewhrZOrZbTPKIYMHkA8OkSF5K9eark8BIwxbeX Ur1XH6ioosE2XUqHoEgzylSBtWl6HY4DRkI8Rv9uwpsQh0OKAqQx7Zcqckc2p4OhTpka B6IldWGzDwiAUSxQeReBb4X7TcdKcXCiA8SOGQMGPrZnXWG2RFmDb32aCxwNk+/G/IY+ 1hiQAKVwgKRW3/P3TPULvNmZV4C0kDqXkKdWOO8jzO6TPq6rLPgLWT3T0L1MhFaRBUO4 Xldy+6dnCbHWQGEJ13NVTQeTr+cYtpANbOO7g74jSfIaZGzlUBJVteao9W9bwaYnN+2b EUow== 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=4y5sfJ/QaL+x8vGX7W70MN1TQaB+eCXDtCFWbXxuV6w=; b=AHfgYtQAvG28oEBQjilYIkUy4ZYmeaos1vM9SLg+AQnws9xMho7T3TYilkrsSv7+w5 43pPjqu2xfw6Zvzu4HW7ThOyudWqIqh4CCPkfOK0QsIJLDfHCOfDpOrK0FTzR95Q45Jy oWiaqSkJYGvRQYfuOQI1zE230OUub0P/fzktOyl2ESL2lfV4grONHo4sqzeCNKBI1vwP +sr5+6ZDFU/zua8t9YGYlsrZV5PcAjNXP5fR3t8tnWFCOvyy6hg9/OAny7K9DsOvWtLu 9SllEvo7SOFlnlmibgSeJzE6tJc/ATsFPCOEkGN+pkaa8Mh8Uoag446gMwxDr1nkgqTW 1rfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=b8lX+hGv; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.2.90 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-db5eur01on0090.outbound.protection.outlook.com. [104.47.2.90]) by mx.google.com with ESMTPS id c3-v6si7751928edm.25.2018.06.18.02.45.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Jun 2018 02:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.2.90 as permitted sender) client-ip=104.47.2.90; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=b8lX+hGv; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.2.90 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=4y5sfJ/QaL+x8vGX7W70MN1TQaB+eCXDtCFWbXxuV6w=; b=b8lX+hGvaM5FiGOjdAfKe3BuHGwo/fLHzAOtPNj09DSn/Luw2Ci5IaNu0wtHns4sLcGepnJBbcbJ0Fx/qreYSYE1jGzxjxeWXyH57ewNTcO3MsMlWfypxyEDTVE0EGfNi05wMCiOZGF+Mw50SXoOad/+C7dEDEae/gtQdRpGNVk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (195.214.232.6) by AM5PR0801MB1329.eurprd08.prod.outlook.com (2603:10a6:203:1f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.17; Mon, 18 Jun 2018 09:45:40 +0000 Subject: [PATCH v7 REBASED 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 Date: Mon, 18 Jun 2018 12:45:36 +0300 Message-ID: <152931513692.28457.6486869034912069546.stgit@localhost.localdomain> In-Reply-To: <152931506756.28457.5620076974981468927.stgit@localhost.localdomain> References: <152931506756.28457.5620076974981468927.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR08CA0050.eurprd08.prod.outlook.com (2603:10a6:7:2a::21) To AM5PR0801MB1329.eurprd08.prod.outlook.com (2603:10a6:203:1f::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a9efae2b-5278-4da2-1f6f-08d5d50041f2 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:AM5PR0801MB1329; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1329; 3:dH1suN64Q+TKoqjPlVBgy0m6yYJh7F/58070/faJYLkANtkZCYxIrjDXiQjoMMIHOLKGiCOsThiqUiUwJmtpF4UnVBwyZcYnrgMbOQ4YloatKuGK+lYq3wWAZC4EDS14ISbkfc/IwXisNtg8f7tvHmFk4xU1MOhnnnxWvUIP3Rv0ZAW2sFO6G/DcNd4+xReI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Pvvg1LFkG8cBXrH9VlyCVS5M5E9lY0dxUbFkwbmx6FJd3PqApY0lrVWwnJVPvBwPcobrhPpzKxAWNRXtZ0r+n6Jpj4aEDkUDIg48fOJIcaJdFs2pdTNk7YlKF00VqUaKgAnt0gWbkuxw2AGvr1LULhyap6LOUY4uzeiv 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)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:AM5PR0801MB1329; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1329; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1329; 4:pTDWdgH0s9PPtAHPUVZXqHRKzU8/1zUcc+0h/vSDJi6L5yW0l3/a3vz6GiCqsluFYM77j7R5QG4sAdWj4lHPICFVwduZzKpo9lwZoODkCOkuUEgaQHg+Y0xGAF2PLl5sKOg3P8/XdH5+ISLkb3YeDAvo/ity2RPMBjcA0/cmbvdStstLaCS+RIL4IY4qVxzg45xvo2uNYuVca0DqBpfl46zNfvsdene3ujjG7f1iKXJ+zOoeyhB7nPZUe0pHxG+wbbSnvtApvEORp47aq3CL6RbUZJdF/pN0YEWqqL80lEapboTQ/6Vq1dfHjjAE7MvVob4JkOMGoHB7uP9msmJ6Rqvabt0+mcc19S/9Fer+dpX6+SU/tpbUwzD2X1FnAUpC7rEHvR2/P3Q6Icair09YQz8d/8BFdN2YtfLZIGPR8KEiCYONrR/xiB8gkPi8TTEmaxjshsDBLqPwmn1+xicGZg== X-Forefront-PRVS: 0707248B64 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(39840400004)(396003)(346002)(39380400002)(376002)(366004)(189003)(199004)(6636002)(6666003)(61506002)(316002)(58126008)(68736007)(106356001)(105586002)(230700001)(47776003)(305945005)(2906002)(7736002)(7416002)(55236004)(66066001)(5660300001)(33896004)(11346002)(476003)(6506007)(956004)(386003)(103116003)(59450400001)(3846002)(6116002)(53936002)(97736004)(186003)(26005)(39060400002)(9686003)(52116002)(478600001)(446003)(8676002)(86362001)(81156014)(81166006)(8936002)(50466002)(25786009)(23676004)(7696005)(2486003)(76176011)(16526019)(486006)(55016002)(575784001)(921003)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0801MB1329; 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?MTtBTTVQUjA4MDFNQjEzMjk7MjM6RVpxOXEzTHlEU1E3Tlp1OWs4blRSZ0hC?= =?utf-8?B?dGhpbS9GK3dKdEVXUWZBMUoreDNvRWEvRFladm10NVJpdUNZdjFtR2hWVnlj?= =?utf-8?B?SytGUjlYM0liNXJmYUMvODFONC9CUHptQmoraUdUN2dGN25odXJGMXZMajFn?= =?utf-8?B?ejBYUXNScEhBTS9TT0MvZFMwZXo0ZklsQThGMmcydUtpM0s4eE4vdERoUGtB?= =?utf-8?B?WURtdHFSUy9FTVdKa1RLZ3d5ZnhCYU4rY2tneWRReVdKRTRYSUI4clZIeG1D?= =?utf-8?B?VTY5cng5aGtLWEIzYTBLNWQvS3ovYzVwWTVoVG5jalZrazNNVkI5SmxHUTZ5?= =?utf-8?B?MUxna1FxUXE4K1ZscXM5ei9HaUIvbTNQTWIwc2dCT1FwVjY4WU0vZE4zemt3?= =?utf-8?B?RTdGZ2Q2MTRjb2ZnQSt0WVUzWFh4MkViZjBOZVlqVURYOEVLWWkrY2pBcmdF?= =?utf-8?B?aEwxWC9Q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uc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2018 09:45:40.9833 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9efae2b-5278-4da2-1f6f-08d5d50041f2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1329 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 d9e38a7c0c05..40401a73000e 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -111,6 +111,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. */ @@ -124,6 +133,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*/ @@ -1225,6 +1237,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 b36229bc2df8..f80a2d1cd880 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 */ /** @@ -4253,6 +4367,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)) { + idr_remove(&mem_cgroup_idr, memcg->id.id); + return -ENOMEM; + } + /* Online state pins memcg ID, memcg ID pins CSS */ atomic_set(&memcg->id.ref, 1); css_get(css); @@ -4305,6 +4424,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 f9fe0915d71c..51c3d1a0fc91 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;