Received: by 10.192.165.148 with SMTP id m20csp924644imm; Thu, 10 May 2018 02:55:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoQBoCks6jGPDuOl3WCVLen5OCp5pbohHg30Tq47QPyNhWR3RzGNqytBWI8J7R2l8o9v4DH X-Received: by 2002:a17:902:7844:: with SMTP id e4-v6mr723406pln.296.1525946157434; Thu, 10 May 2018 02:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525946157; cv=none; d=google.com; s=arc-20160816; b=F80/Ut+52dpNHfWLngHKoDqywvZOiklDqUkMVprdrybLzIrYs0025JzVYXY3gPxm12 xD+J6elWb4redCW39D+Q+q9MhsZUGTLl6b2DUsVde6XjjVik2uzY1M2UmwsHZlpHsn4u 6fcmojEY3yLXAARx1JPvvMcHTfKrcNeibWBHKYsyXzhhO+fTbrs45aGp4a6RWyuwt5rZ 1JGa+1lBqK4asqe/IG0TvkXsWao3ZJF0tpWQxF1ACCs/CmJHyo1nMbn7tQ0k5NVwG0wB ZlB+wkuVBLhwnCkJiMSaa04ivCWN6GQcdLlAS6PfXSIwhh/Dgu+w0t/H7qGVRTl0Fjt6 0glA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender: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=Ujn1h/KseB3zgJx/e57Tug8mCXoI+0upRyN5+30U2uQ=; b=us88VaeFn+UBZAaBcKRmTGgojX7ZcxcXgQ/njTFJ2paH/l4M3Vrf9HRurFlHD7idvs zMR/I2f3nf0SNHAQ2iwRHGTSoa2NTo0DXAlZzp+bBfYGbiBNhXIyZ/yJ03xMw1hRgx2Z Hlt20PMayCKTfNcmxmL11+6aw4tb97bCbXSVgFMpbeKIlXKWZ25U0GLJ01lzlMGUiWUX rv3KKPgQcTysnta2hd1mNJ6HYBbzSmoXiUePbko8SBYqngO+OwR5EqI1BnHLEhSczm2e A8T50vo0GMcNkHzxkd5zqy1qNqOV44cBcZz/rr9JSE7WGsm2XbHyUbqnWZafb7/R3/VM tTfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=OyKtzM3l; 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=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12-v6si338508pgs.557.2018.05.10.02.55.42; Thu, 10 May 2018 02:55:57 -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=@virtuozzo.com header.s=selector1 header.b=OyKtzM3l; 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=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935211AbeEJJx5 (ORCPT + 99 others); Thu, 10 May 2018 05:53:57 -0400 Received: from mail-eopbgr20100.outbound.protection.outlook.com ([40.107.2.100]:38242 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934661AbeEJJxy (ORCPT ); Thu, 10 May 2018 05:53:54 -0400 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; bh=Ujn1h/KseB3zgJx/e57Tug8mCXoI+0upRyN5+30U2uQ=; b=OyKtzM3lTvHdWJDX2zr8XWi3XoHLwppLOeXtrye/JNz78ZeK4J/V8rxI0voeNJHkU/rdMhmBs1k+BY+Ba6MfgsYoSh/jJAOBbvpTJMbnedCk/CbS0v654MjndCKE9BVJzDVS6LfRnUCV4M0BJ9+6cbJ/AMLDmVGxkscjwyNKd1g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (195.214.232.6) by VI1PR0801MB1342.eurprd08.prod.outlook.com (2603:10a6:800:3a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.735.17; Thu, 10 May 2018 09:53:48 +0000 Subject: [PATCH v5 10/13] mm: Set bit in memcg shrinker bitmap on first list_lru item apearance From: Kirill Tkhai To: akpm@linux-foundation.org, vdavydov.dev@gmail.com, shakeelb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, ktkhai@virtuozzo.com, 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: Thu, 10 May 2018 12:53:45 +0300 Message-ID: <152594602582.22949.2526776640167844592.stgit@localhost.localdomain> In-Reply-To: <152594582808.22949.8353313986092337675.stgit@localhost.localdomain> References: <152594582808.22949.8353313986092337675.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: AM0PR06CA0052.eurprd06.prod.outlook.com (2603:10a6:208:aa::29) To VI1PR0801MB1342.eurprd08.prod.outlook.com (2603:10a6:800:3a::28) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(2017052603328)(7153060)(7193020);SRVR:VI1PR0801MB1342; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1342;3:Hpz5c2YXGdt+dmsk2GlXpQ9g3qjHa2xKa2IKa+VeF10S5brxny0iYZYMld+bunD+S2OH2GxQHrE0FLt3HGrulwIeFqklU1CqFKhWEX+pF59takvFGLbBU2jrds9mujCCqCvtyjtb8KQuvkjpDsnV10AUyQbmPC+q87k1vyZPPjBfZB/sgeyMLt9nh5Eobgtbzk3qfhYnOWxIweis9D6lxNgHx4AXoOC8wWo9X5EJuQbW/LSNhiUi4OmbG7rllU1R;25:00ikVQsRZ1zJF43YBw4+LTmtiaMjMAFr/dUOEbGoQgEz2A431f+GtjzzadOFaNigS/08fvCT+Mo4HrlIrH8KoXspd/zYLPsot9PwJdajwXP65ScD7sQdmh5AP3CtbdfNZsUH/pJOXVcwFPjJl2OFNA+KoAjZK6N4fxSIEQXSZUhxl9PvsfuVCapIWXoB9ZGvOVtRKxEyvTjfSUvOz5c4ec9FO0g+qjD4WYBZELnWzNNMkyWlvs9ARyNdRnzeJOJT7EYTo8ts/MZZ7jtpQImiJnepFebZGswnoVHwcjBaQN9d4ERBggohH5K1IdOhPoP75bUP3jcw9Kg4Hq5iwsy8LA==;31:r8BP0y7ZiSzMQUPzSjTFNK+cYgHt1ff7kaQgJfVorZ8QjE45+D/A09Of3JjqAvmn9Au6GGF7XKMBH2v0JemyIgEATuqgYIVLppjIydDOKOuuTcTgO8pA3pdMwvI5Eo0YMjAT6jh3/GnU6Rikhe/GW+aQ05dZZ9t8bJIbQqM4pBivovBLOOPEGD+6kkbUvxwkUZimJimpiL/+0U1BAEIe1iJC2sAbOGb9oDOWBJNtU4E= X-MS-TrafficTypeDiagnostic: VI1PR0801MB1342: X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB1342;20:52wafILNvyNafy2ZY2oMpPCrW90dfDxQ0XaOuzKcgAuo8URXbNVH17mXYCToopfaTb3me36DK1So9U8hYNoOf4L5tDzm7njlA/WuKapRD766JQYj/bTt+xcvOJeSXmEw0zoccntDOAJRtKQbdxxxxvtg7LpRmy2/NmIAO9HIVl2gBq0IkzvEbxXNwvg3quhx3IN8F+Ky8VOquPRw7VycxhFc35Ro12pA39wm5yBKCULUP8eSb8ocG12hteKIFOQmK/2Ib0a4/tWT+xeZ+6fQi37xxYatZCif3U4CzmcZaApGPH4Gni6G3+XVadCKdfzfaa83v3cmYe9UKRgAL72v5jLv98qoc8pvGS5CFWLIVeMJ/5l0E3OjoGT4T4vYG0TwsGZxP+WDKL961wvMRHlKfQjmkK0z6maJWmFLEAQJ7Icee7m+w38972c5QGuD3+LL+Gx+NaoCz3drj4L9A94lvcV+ciFv9gz5DqGwymGLUejZn9RtJK3gvgvLKMZXhV7X;4:QrywgOJauQ+VYqLQuYzbLZrA5KIu4jSh2KqXksRPrcdzJokmdr6xAI9omapdeYdWFr1xrQytRcP/hLg+z+knendV3syfa9Th53j6h5+fVoZqqEyVZKUHBe7tY0qJyyEnMYrSACpq2Wv1MraU1ZyA2pvQo+7Qlo8D9lr1EsXq8r3iAXnv9gzsAZUxfPN7UkgyNrj1CpDkk6utnLrMiiFxiLqyTprhRdzparps4NqX2H4uQPo45WoAH2A4JiQQ0xfYzTw1v0t+lvyFfUgtjmefpQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:VI1PR0801MB1342;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0801MB1342; X-Forefront-PRVS: 066898046A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(346002)(396003)(39850400004)(376002)(366004)(39380400002)(199004)(189003)(52116002)(23676004)(26005)(68736007)(186003)(2486003)(6116002)(97736004)(61506002)(86362001)(3846002)(105586002)(575784001)(106356001)(16526019)(55016002)(66066001)(11346002)(446003)(25786009)(486006)(7416002)(76176011)(8936002)(305945005)(956004)(478600001)(7696005)(5660300001)(230700001)(47776003)(386003)(316002)(59450400001)(39060400002)(476003)(2906002)(55236004)(7736002)(6506007)(6666003)(6636002)(58126008)(53936002)(81166006)(9686003)(8676002)(33896004)(81156014)(50466002)(103116003)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0801MB1342;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtWSTFQUjA4MDFNQjEzNDI7MjM6WmI2eUUxZG0rUlZKbERpWUJQS0dsZll1?= =?utf-8?B?SmNnNG5jQWNVVTdXMTJqOWIvd2JUMDBhakt4WWF3ZEExVm54Sy8zVlpjZE1Q?= =?utf-8?B?ZVI0bHJhMGdlZVd3Y1lva2hVTEptZ01JSks1VWp3K0NXKy91OXRjTkU3UjJx?= =?utf-8?B?MzVERGhQVUtURjdZcVRGc2Z3U1VpYmtLQVV5MEk4dlY5NFU5SkQ2MmkwQUJI?= =?utf-8?B?UlhiN0JqcFVEZUwxZEluTVRVb1RybHNReHZmRWhpeDdUTDRQazVkV284cElM?= =?utf-8?B?RXVvS3Z6SEZzNVZYUUltYnRDMkFrSUFwM0RNRW9NZGVhYkJTZVk3UUthazBU?= =?utf-8?B?aDBPcGIrWkZyR1Z0cXFadUp1VTd5Tk5sQ3VJbDJHQTlOWlBwajJ1Qj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zFki7UBedz80zR8AJ4qfj6k8aopum55okgUJZ+GFBlrpuKwLJptrstkEL6sncXKFBUieBKNWla4= X-MS-Office365-Filtering-Correlation-Id: e49ef276-4248-4167-b73d-08d5b65bee6d X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2018 09:53:48.1239 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e49ef276-4248-4167-b73d-08d5b65bee6d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1342 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce set_shrinker_bit() function to set shrinker-related bit in memcg shrinker bitmap, and set the bit after the first item is added and in case of reparenting destroyed memcg's items. This will allow next patch to make shrinkers be called only, in case of they have charged objects at the moment, and to improve shrink_slab() performance. Signed-off-by: Kirill Tkhai --- include/linux/memcontrol.h | 15 +++++++++++++++ mm/list_lru.c | 22 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index e5e7e0fc7158..82f892e77637 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1274,6 +1274,21 @@ static inline void memcg_put_cache_ids(void) extern int memcg_shrinker_nr_max; extern int memcg_expand_shrinker_maps(int old_id, int id); + +static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg, int nid, int nr) +{ + if (nr >= 0 && memcg && memcg != root_mem_cgroup) { + struct memcg_shrinker_map *map; + + rcu_read_lock(); + map = MEMCG_SHRINKER_MAP(memcg, nid); + set_bit(nr, map->map); + rcu_read_unlock(); + } +} +#else +static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg, + int node, int id) { } #endif /* CONFIG_MEMCG_SHRINKER */ #endif /* _LINUX_MEMCONTROL_H */ diff --git a/mm/list_lru.c b/mm/list_lru.c index 7f6cb27aa2f5..6ce52f80f12c 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -30,6 +30,11 @@ static void list_lru_unregister(struct list_lru *lru) list_del(&lru->list); mutex_unlock(&list_lrus_mutex); } + +static int lru_shrinker_id(struct list_lru *lru) +{ + return lru->shrinker_id; +} #else static void list_lru_register(struct list_lru *lru) { @@ -38,6 +43,11 @@ static void list_lru_register(struct list_lru *lru) static void list_lru_unregister(struct list_lru *lru) { } + +static int lru_shrinker_id(struct list_lru *lru) +{ + return -1; +} #endif /* CONFIG_MEMCG && !CONFIG_SLOB */ #if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) @@ -121,13 +131,17 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item) { int nid = page_to_nid(virt_to_page(item)); struct list_lru_node *nlru = &lru->node[nid]; + struct mem_cgroup *memcg; struct list_lru_one *l; spin_lock(&nlru->lock); if (list_empty(item)) { - l = list_lru_from_kmem(nlru, item, NULL); + l = list_lru_from_kmem(nlru, item, &memcg); list_add_tail(item, &l->list); - l->nr_items++; + /* Set shrinker bit if the first element was added */ + if (!l->nr_items++) + memcg_set_shrinker_bit(memcg, nid, + lru_shrinker_id(lru)); nlru->nr_items++; spin_unlock(&nlru->lock); return true; @@ -522,6 +536,7 @@ static void memcg_drain_list_lru_node(struct list_lru *lru, int nid, struct list_lru_node *nlru = &lru->node[nid]; int dst_idx = dst_memcg->kmemcg_id; struct list_lru_one *src, *dst; + bool set; /* * Since list_lru_{add,del} may be called under an IRQ-safe lock, @@ -533,7 +548,10 @@ static void memcg_drain_list_lru_node(struct list_lru *lru, int nid, dst = list_lru_from_memcg_idx(nlru, dst_idx); list_splice_init(&src->list, &dst->list); + set = (!dst->nr_items && src->nr_items); dst->nr_items += src->nr_items; + if (set) + memcg_set_shrinker_bit(dst_memcg, nid, lru_shrinker_id(lru)); src->nr_items = 0; spin_unlock_irq(&nlru->lock);