From patchwork Tue Aug 7 15:37:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 10558799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6723814E5 for ; Tue, 7 Aug 2018 15:38:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 543902A426 for ; Tue, 7 Aug 2018 15:38:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 480E12A429; Tue, 7 Aug 2018 15:38:01 +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 9A0D22A426 for ; Tue, 7 Aug 2018 15:38:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 903D66B000E; Tue, 7 Aug 2018 11:37:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8DA576B0010; Tue, 7 Aug 2018 11:37:59 -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 7C80F6B0274; Tue, 7 Aug 2018 11:37:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f197.google.com (mail-qk0-f197.google.com [209.85.220.197]) by kanga.kvack.org (Postfix) with ESMTP id 498066B000E for ; Tue, 7 Aug 2018 11:37:59 -0400 (EDT) Received: by mail-qk0-f197.google.com with SMTP id q3-v6so17103678qki.4 for ; Tue, 07 Aug 2018 08:37:59 -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=IOgHna0IjgNaMkcfTG3lH2LiLelmPRrnFUp70X32rg8=; b=I5BTcandgSyPbUuzkpe+r+dQUpG1GoN5sf0c8U9HIrYH0MIC55mSZSESwU8/1F87oQ VGGVoV6GGA8RQIattAGXEV39lupX0N6CQmSbwUFu2rVac79R7f5QVf0UoCUjnKg1wf2R UYJ7l381TNwLPFjd4ULXIvd0LF4QP9WCEgKNX8bm6oHSyBaSCjZykHZ6HhqpvLuj1mRz Grmqt6ADqle75MDhalJ4vpLM0tvy02CFFry/iiIC9+XYvnSTSf+3vEaEcXvbmifGCDBG MU+TbGClaUBVHX0/yle/FB9QVgX8yqA6rh2rw0qS58n9cQpKV3qXvTNuz+XNOe/6e0kv aJfQ== X-Gm-Message-State: AOUpUlG+hChWHR2Nr8MK9G7UIKnAQ96m8BzxdvEmOElrgmHaKOIAEgfW 7w8DCGDcQZgYTIdZ4RYRnW+6o//DiVPTeNpd4on48N7NRiLOD/nccxqIC8vqIAjBkSxj6VLoqNr xPkLXI278gSwJqBrJYRZ6EGOVrd6lChIMZYPKxjM3k8Bxw6E+xIpifhaPMMACJTZSsQ== X-Received: by 2002:a0c:f747:: with SMTP id e7-v6mr17226793qvo.96.1533656278913; Tue, 07 Aug 2018 08:37:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfoJArIQWSoeIUoaH31ZBP2DpoOOm0EfxKFFpJ2S43z3AjSAL1eGhhuKjqsDkE/FB4iINOl X-Received: by 2002:a0c:f747:: with SMTP id e7-v6mr17226737qvo.96.1533656278079; Tue, 07 Aug 2018 08:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533656278; cv=none; d=google.com; s=arc-20160816; b=oifWI5tXPWEf4G5mmiq3gn6LITDSXHC0fuzIt+OixaGvYE9/PwYexsceeB+BEd91gj eoM/9yYuJr26Sfim3evAtJ+phj6XJrzZ8jkuog5LqLlWuHH2Wjqko9AaXmBF5cs1GgVp sWdKOMI48iWBCYHpvkPhi9+diVB+Dmg+bOmRXYlAc6QsE1rA5D35vbgm4+WNOghmyvsM 08imIFi+dyhQR6Fma/PGHbFx2EKKv4n5dsDrUadA0GH3J5X0xLjDRXsQ1kBxvQA6YYFs /X1HiQkFAq+1gwQxz5bJ7JE9oUhNb38F3giEs2kq4VR+1wHok3QPUQB7/CSRN5RBMz1C qr8A== 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=IOgHna0IjgNaMkcfTG3lH2LiLelmPRrnFUp70X32rg8=; b=o1yr16E130pdXt6EmQCZWnfVYDtvN8el32GpSltYR+zFN2I7R+DEIUua5/kiYhffpX 0dff+d54WEeWCNKrKj2ysYUJkJHa2qHvSuB8eB9vTajPlSX7jYqvv7OCxUKXMLfktDLW wQk4eARdEIewff3UiESno+tfSISobIs3tGyKc6h1lLHnWhxxfU4I7w91UA5JLem6kYXY YWN0607Q6b5GBfls2r1qlicsj+a4Muim94YcOSy7lo+Z0ODZ4PfHE4OtOH2ozyO2e7Ab qYXwBZygapw84DdRYCHJAGELtfoZeG+aBiU3hUZ5nk/1Zc+ctQe7JRNgddAcbxZL7UUz Jyxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=FXqBnciJ; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.1.127 as permitted sender) smtp.mailfrom=ktkhai@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0127.outbound.protection.outlook.com. [104.47.1.127]) by mx.google.com with ESMTPS id m81-v6si1480353qke.299.2018.08.07.08.37.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Aug 2018 08:37:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.1.127 as permitted sender) client-ip=104.47.1.127; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=FXqBnciJ; spf=pass (google.com: domain of ktkhai@virtuozzo.com designates 104.47.1.127 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=IOgHna0IjgNaMkcfTG3lH2LiLelmPRrnFUp70X32rg8=; b=FXqBnciJoI192137vBDlbX128rGMK68+IF9JW+o8GdPomPVZmQiUbXOkEvJAyoJrF2CfUMxrcdGiHA5r0u+R8WCNiOzr8rOwfNwDbjEYbXwa4h0G4HljOIBO5iNdMUzOctjgnGpQj+PedxzeR2xcuPwMb/rvrE+NhEqer9iTAKc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (185.231.240.5) by HE1PR0801MB2026.eurprd08.prod.outlook.com (2603:10a6:3:50::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Tue, 7 Aug 2018 15:37:50 +0000 Subject: [PATCH RFC 02/10] mm: Make shrink_slab() lockless From: Kirill Tkhai To: akpm@linux-foundation.org, gregkh@linuxfoundation.org, rafael@kernel.org, viro@zeniv.linux.org.uk, darrick.wong@oracle.com, paulmck@linux.vnet.ibm.com, josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, hughd@google.com, shuah@kernel.org, robh@kernel.org, ulf.hansson@linaro.org, aspriel@gmail.com, vivek.gautam@codeaurora.org, robin.murphy@arm.com, joe@perches.com, heikki.krogerus@linux.intel.com, ktkhai@virtuozzo.com, sfr@canb.auug.org.au, vdavydov.dev@gmail.com, mhocko@suse.com, chris@chris-wilson.co.uk, penguin-kernel@I-love.SAKURA.ne.jp, aryabinin@virtuozzo.com, willy@infradead.org, ying.huang@intel.com, shakeelb@google.com, jbacik@fb.com, mingo@kernel.org, mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Date: Tue, 07 Aug 2018 18:37:46 +0300 Message-ID: <153365626605.19074.16202958374930777592.stgit@localhost.localdomain> In-Reply-To: <153365347929.19074.12509495712735843805.stgit@localhost.localdomain> References: <153365347929.19074.12509495712735843805.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: LO2P265CA0164.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::32) To HE1PR0801MB2026.eurprd08.prod.outlook.com (2603:10a6:3:50::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 679832a7-3215-43b5-fe22-08d5fc7bbeaa X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:HE1PR0801MB2026; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB2026;3:SGApD3x/zPMVBpLYc2HjeYF1T9qt1J58SZ83TLV2FOa8bED4wE9QuUuwL6ZY3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VOucaupJdAwt2SFYu/I3M0kIVi7nhj2X/00ONZCaxF72xvRFcr1T2w/zaox3wOjuMyOOoVbVLgMkUkucZHCesy2uC6bzCyAksPIZOBqU88OXBN2ni2XcAMaAtz4mos62DxWfU/Tdp85ld88axaj/SCvUnEscc99HT5KjzcXUeOoCH62QQL9nNKqkBJ6/mCpAYp2qOasbOmRI9Ftkp+KKLhF+TdpC1pm2HSKeJ21ogKZ9o1QfEZ/kWPEgw2N/IhlNOzl9SoaoM5JtVZ/NLK5OKipCphc8a/+b9u;4:m8yV8XhbFiyl9ZCqI66IDfQriCkHTYRJjx5roZ6L53Wg/EG3TxnTgZYH5pljYlD+7c6SIRhleBdo6ckMAdJbW8shaKkxMS/wf+i3hvKOIxuGNwsQFD7s7ltK8JbDrzRxsmLDLiIT8v0x6sBf3uzHRTtx+/VyuOFZXo9tBQDJLitSZRpi6BCOlWrmFXhzL4caX0L+xHhsxzIJsMez/A8jAmX2i0FbmVNmfGZnQ3qtOupbGAelAAz3bYRzsDiTNGiefcO7B/wiMZQadEWKuSdaJA== 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)(3002001)(93006095)(93001095)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(6072148)(201708071742011)(7699016);SRVR:HE1PR0801MB2026;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB2026; X-Forefront-PRVS: 0757EEBDCA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(39850400004)(396003)(376002)(346002)(366004)(136003)(199004)(189003)(55016002)(105586002)(7696005)(97736004)(3846002)(6116002)(23676004)(2486003)(230700001)(25786009)(106356001)(47776003)(14444005)(66066001)(52116002)(81156014)(9686003)(8936002)(103116003)(8676002)(217873002)(81166006)(76176011)(6666003)(61506002)(316002)(53936002)(305945005)(5660300001)(68736007)(476003)(2906002)(386003)(6506007)(39060400002)(478600001)(26005)(58126008)(50466002)(33896004)(11346002)(486006)(86362001)(446003)(956004)(186003)(7736002)(7416002)(16526019)(7406005)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB2026;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?q?1=3BHE1PR0801MB2026=3B23=3ANt2OV?= =?utf-8?q?gvfoUetPD4f8OLMoxW5NZ1bntV69T3elaQq2Wmq9eoBQaaBL7c6vuimeN9+Q6t3wV?= =?utf-8?q?e24UZBMNK+/6Ka5basiIZgxlDdRine99OL4Lj+yZAfvrxVQIBZalQQdS9Wzul1lz4?= =?utf-8?q?0q7+Ydsb3XujrSNj+YTbA4BtVwrTV5SGaIPA7LMyhBqQfBMNXxWlc1b0msKq+/njh?= =?utf-8?q?edgwMfphK1Jk346XbSpjfIDALqH9SYcpe5tu9QG87bSp84p6paoEeVGLvQRdD5ylP?= =?utf-8?q?RTxW+fTKwKnuRHsMiNXP5wsjPq0SRYM7Yn6VywME85KtO+UHiNN22QUcELHj/cR5b?= =?utf-8?q?MapxcbLk9eAHvsIZn6RxynivXtJDN0ytQ1kw2Fws/HrDuks1y89+1j7KTYtymH+ds?= =?utf-8?q?JZgdxOQOrzdzZi53hYmaJSoYxzRcqu6tEOHXTngCIgYMmo/88QUE0r2FOHZqyhQwA?= =?utf-8?q?Y2PESMEs1lMdtQYRM0qQuiTgBwOCiEj9qjmLl720Dsu81o8NkbQY8N9DoH5xw1GoA?= =?utf-8?q?JER/u7FOABtnPULqZApGCg5ASx2XCbyIjNffezz+1I6XgtimKh2BpxV89CLsJDPMg?= =?utf-8?q?QfDz50GAbuN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9SnO3lu5/zLGtw7DbUfM8D8M03QoHM4 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB2026;20:LrQHlzuO4ScRNp+WX0KrOLhI3m17GrFfUcUmpJgpeH2Umo2/L1+eSWmRGeDp3BcbId7L32gt3I7inGyOavULUXGFiihsz6xzGcx5H91AE1fsk1zPqNreXeAlll6Q0hncBrYQeCiQ5tSXtIZid8nAqapkk0X9wmiNl7O2YV3F/iI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2018 15:37:50.5971 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 679832a7-3215-43b5-fe22-08d5fc7bbeaa X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2026 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 The patch makes shrinker list and shrinker_idr SRCU-safe for readers. This requires synchronize_srcu() on finalize stage unregistering stage, which waits till all parallel shrink_slab() are finished Note, that patch removes rwsem_is_contended() checks from the code, and this does not result in delays during registration, since there is no waiting at all. Unregistration case may be optimized by splitting unregister_shrinker() in tho stages, and this is made in next patches. Also, keep in mind, that in case of SRCU is not allowed to make unconditional (which is done in previous patch), it is possible to use percpu_rw_semaphore instead of it. percpu_down_read() will be used in shrink_slab_memcg() and in shrink_slab(), and consecutive calls percpu_down_write(percpu_rwsem); percpu_up_write(percpu_rwsem); will be used instead of synchronize_srcu(). Signed-off-by: Kirill Tkhai Signed-off-by: Kirill Tkhai --- mm/vmscan.c | 42 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index da135e1acd94..9dda903a1406 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -168,6 +168,7 @@ unsigned long vm_total_pages; static LIST_HEAD(shrinker_list); static DECLARE_RWSEM(shrinker_rwsem); +DEFINE_STATIC_SRCU(srcu); #ifdef CONFIG_MEMCG_KMEM @@ -192,7 +193,6 @@ static int prealloc_memcg_shrinker(struct shrinker *shrinker) int id, ret = -ENOMEM; down_write(&shrinker_rwsem); - /* This may call shrinker, so it must use down_read_trylock() */ id = idr_alloc(&shrinker_idr, SHRINKER_REGISTERING, 0, 0, GFP_KERNEL); if (id < 0) goto unlock; @@ -406,7 +406,7 @@ void free_prealloced_shrinker(struct shrinker *shrinker) void register_shrinker_prepared(struct shrinker *shrinker) { down_write(&shrinker_rwsem); - list_add_tail(&shrinker->list, &shrinker_list); + list_add_tail_rcu(&shrinker->list, &shrinker_list); idr_replace(&shrinker_idr, shrinker, shrinker->id); up_write(&shrinker_rwsem); } @@ -432,8 +432,11 @@ void unregister_shrinker(struct shrinker *shrinker) if (shrinker->flags & SHRINKER_MEMCG_AWARE) unregister_memcg_shrinker(shrinker); down_write(&shrinker_rwsem); - list_del(&shrinker->list); + list_del_rcu(&shrinker->list); up_write(&shrinker_rwsem); + + synchronize_srcu(&srcu); + kfree(shrinker->nr_deferred); shrinker->nr_deferred = NULL; } @@ -567,14 +570,12 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, { struct memcg_shrinker_map *map; unsigned long freed = 0; - int ret, i; + int ret, i, srcu_id; if (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)) return 0; - if (!down_read_trylock(&shrinker_rwsem)) - return 0; - + srcu_id = srcu_read_lock(&srcu); map = rcu_dereference_protected(memcg->nodeinfo[nid]->shrinker_map, true); if (unlikely(!map)) @@ -621,14 +622,9 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, memcg_set_shrinker_bit(memcg, nid, i); } freed += ret; - - if (rwsem_is_contended(&shrinker_rwsem)) { - freed = freed ? : 1; - break; - } } unlock: - up_read(&shrinker_rwsem); + srcu_read_unlock(&srcu, srcu_id); return freed; } #else /* CONFIG_MEMCG_KMEM */ @@ -665,15 +661,13 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, { struct shrinker *shrinker; unsigned long freed = 0; - int ret; + int srcu_id, ret; if (!mem_cgroup_is_root(memcg)) return shrink_slab_memcg(gfp_mask, nid, memcg, priority); - if (!down_read_trylock(&shrinker_rwsem)) - goto out; - - list_for_each_entry(shrinker, &shrinker_list, list) { + srcu_id = srcu_read_lock(&srcu); + list_for_each_entry_rcu(shrinker, &shrinker_list, list) { struct shrink_control sc = { .gfp_mask = gfp_mask, .nid = nid, @@ -684,19 +678,9 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, if (ret == SHRINK_EMPTY) ret = 0; freed += ret; - /* - * Bail out if someone want to register a new shrinker to - * prevent the regsitration from being stalled for long periods - * by parallel ongoing shrinking. - */ - if (rwsem_is_contended(&shrinker_rwsem)) { - freed = freed ? : 1; - break; - } } + srcu_read_unlock(&srcu, srcu_id); - up_read(&shrinker_rwsem); -out: cond_resched(); return freed; }