Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932815AbdHVM3T (ORCPT ); Tue, 22 Aug 2017 08:29:19 -0400 Received: from mail-he1eur01on0120.outbound.protection.outlook.com ([104.47.0.120]:59968 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932757AbdHVM3Q (ORCPT ); Tue, 22 Aug 2017 08:29:16 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Subject: [PATCH 1/3] mm: Add rcu field to struct list_lru_memcg From: Kirill Tkhai To: apolyakov@beget.ru, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ktkhai@virtuozzo.com, vdavydov.dev@gmail.com, aryabinin@virtuozzo.com, akpm@linux-foundation.org Date: Tue, 22 Aug 2017 15:29:17 +0300 Message-ID: <150340495784.3845.8914468792862418341.stgit@localhost.localdomain> In-Reply-To: <150340381428.3845.6099251634440472539.stgit@localhost.localdomain> References: <150340381428.3845.6099251634440472539.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: AM5P194CA0022.EURP194.PROD.OUTLOOK.COM (2603:10a6:203:8f::32) To DB6PR0801MB1336.eurprd08.prod.outlook.com (2603:10a6:4:b::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b28af77c-9c6d-4a90-56a4-08d4e959652b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DB6PR0801MB1336; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB1336;3:/s5jBes1q24hwv5pD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0BxkO4PR2LIkZCyQTO4/hGsSJ9USSA5uHq/CaDiSIOrifMJ9eu7AHVFhwA9XUCmM5+cYz/lTB5p1z2ouRu/yjT1tSJwM+qMz7VAaPix1yBKXzXi3Tc+aGcVWQd85TsDIjxq8tUdyA7821cWez386bz2FSDbyPjS8pyUV+oMr5NAiBBiIATAq7YRrJRHMZya17DPY/y4vHdRJ6AMWbq+hCcPiIFXAA9oWU4QoGaB648XSM/I=;4:KqLT8INYpjDu79fjt77/d7QS/ayVuZ9c8n5b4/vt20GSIcgy/6B6SdPsbQEeLZnupVCY3ETqRNU6puZF32N0EhjHi0A8v9dTUVpLPU4wCLPGjEVQbdg79OJa4etEFkI8HvzI/QQVTt+7gYuwvEw5QFCoTQ6u7ui46t9GblqwyFE0H9p/4yrpNfWw9pWTBrJRAtfXrBonomEVxl9JePVVLzgzRYImkRYimqW1yjMBGSXcVtp7B+xaXLkokPqydhzS X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6041248)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DB6PR0801MB1336;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DB6PR0801MB1336; X-Forefront-PRVS: 04073E895A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6069001)(6009001)(189002)(199003)(4001350100001)(42186005)(105586002)(106356001)(68736007)(6116002)(305945005)(66066001)(86362001)(97736004)(33646002)(3846002)(47776003)(50466002)(25786009)(103116003)(230700001)(83506001)(23676002)(478600001)(110136004)(9686003)(53936002)(61506002)(81166006)(2950100002)(189998001)(55016002)(8676002)(81156014)(5660300001)(54356999)(76176999)(101416001)(50986999)(7350300001)(6506006)(2906002)(7736002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0801MB1336;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjZQUjA4MDFNQjEzMzY7MjM6ZjllZmUzamtnZWNmR3Q0RGdFTXZvOEpw?= =?utf-8?B?YW1jMkdiS3hUc2ljSGlyY1NQd0dOSnk4NDJIMWdVUFBlWWYrZE1MRG55Qmd6?= =?utf-8?B?cDBTLytUY1ZXOHpkQlFlV2taUEg1WE42VkhUUlZUdzI2ZlcyM0U5WCtzY25T?= =?utf-8?B?cWxoM1pCRVRkc1FCZk0wTmttV3dCYkQ0WkRkQytvc3dtRUgrakZaSGpWMGp3?= =?utf-8?B?aU51UktiQ0VWQi9hTHduWmtxK1NyT09zOFZvbnNOM2s5KzF1ajR6OXlDS3Qv?= =?utf-8?B?SDV6bXBRamg4dGFJdmdyQ3EwUVo0OGlxUWZlNmhxU3RjaHBvSkdXZStuektY?= =?utf-8?B?a2FTd3NuQ05peG4rTFEzeUtjTUMyL29ZL2EwZFRqM1E4Wmh0WTBkdERoVzM1?= =?utf-8?B?aWJ2bnNWSWhwR3NjVFg0VksyOHFsaUREYTZUSEFFQ3htbFJ0dzNyLzlLUlhK?= =?utf-8?B?SFBGTEFxSDB5bktVYmJSTFYyRDJjNHpGQytEMnBkTjM5bThIL1prTlFrb2Fj?= =?utf-8?B?SlA5N3hHWVhjSGxQd084czFLWmlBYXY0UHM2QnhJdjJsSVE3RStqbmJpVXls?= =?utf-8?B?WTFhMll0MVhxYWxoN0NoVW5aNVJjK1BGR3FPWE5IbjM2WDVZQ0w1RTNNMU90?= =?utf-8?B?dGNBRGRadC9RZF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6ZoAWGbzpBca4ZbX8mAeKc8dl9Zk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2017 12:29:11.8497 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1336 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1668 Lines: 53 This patch adds the new field and teaches kmalloc() to allocate memory for it. Signed-off-by: Kirill Tkhai --- include/linux/list_lru.h | 1 + mm/list_lru.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h index fa7fd03cb5f9..b65505b32a3d 100644 --- a/include/linux/list_lru.h +++ b/include/linux/list_lru.h @@ -31,6 +31,7 @@ struct list_lru_one { }; struct list_lru_memcg { + struct rcu_head rcu; /* array of per cgroup lists, indexed by memcg_cache_id */ struct list_lru_one *lru[0]; }; diff --git a/mm/list_lru.c b/mm/list_lru.c index 7a40fa2be858..a726e321bf3e 100644 --- a/mm/list_lru.c +++ b/mm/list_lru.c @@ -325,7 +325,8 @@ static int memcg_init_list_lru_node(struct list_lru_node *nlru) { int size = memcg_nr_cache_ids; - nlru->memcg_lrus = kmalloc(size * sizeof(void *), GFP_KERNEL); + nlru->memcg_lrus = kmalloc(sizeof(struct list_lru_memcg) + + size * sizeof(void *), GFP_KERNEL); if (!nlru->memcg_lrus) return -ENOMEM; @@ -351,7 +352,7 @@ static int memcg_update_list_lru_node(struct list_lru_node *nlru, BUG_ON(old_size > new_size); old = nlru->memcg_lrus; - new = kmalloc(new_size * sizeof(void *), GFP_KERNEL); + new = kmalloc(sizeof(*new) + new_size * sizeof(void *), GFP_KERNEL); if (!new) return -ENOMEM; @@ -360,7 +361,7 @@ static int memcg_update_list_lru_node(struct list_lru_node *nlru, return -ENOMEM; } - memcpy(new, old, old_size * sizeof(void *)); + memcpy(&new->lru, &old->lru, old_size * sizeof(void *)); /* * The lock guarantees that we won't race with a reader