Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1933246imm; Thu, 9 Aug 2018 04:41:36 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwbwRvQ/loZsriSXvkGdfqw7ZumjFqBEeVfzjJVDVKszIe83/gGZ7YHYb6htqb3lCdeu6cw X-Received: by 2002:a63:d613:: with SMTP id q19-v6mr1803295pgg.327.1533814896262; Thu, 09 Aug 2018 04:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533814896; cv=none; d=google.com; s=arc-20160816; b=0BcLQfv0MeTnDNGB2V8BjkbEoQNEFRdI2phV0NkD+SqqnhEi2yRKgV9W3jTHXzdUtY PORHaweAEpmc20phUjGw8oe2JqMt+DFGjQlQWSpQ5fgq64WJIU6de3oaUrACwc0I++Lv CW7j0BruIwFbvNY8fVwXsXd4MpSabwtxuTHSfLZbwcsPdBLU69GcR59lAHCoZ7pEDJTu c4aiAnk71iwXbhm2mbBMNaHonLvqsAC8EaLyzLb9pIIugfUGesNVE/JoJ4Ok5QXuE2RP 0Tu6dL15Hmw+EuNcNHCZj/5ZaO1UErRXN38nAX3qhhLkJsU2kVjiOY2WIUve2vIA0y+8 SnBA== 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:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=UvUvp9NwGAkPWzMThcI1SN+/X9bJ1aAcEruDwW00XMM=; b=ECOm1XVNCJeJAFTjY3G4aJJIFA2UaRshQOnvkBM5XgRQw4FWgwjSfFSJYwHSq5l6H9 oLIf6fjjmf0EImY4pCJb24xmLg1BPcTgpG+Px4NXq3bzI6eRcM8x/6MmkNLa8cNNdd20 KGf2mCkMeSlshG1BqiRgZQbqjg7hjIi82g92paObUJu6ud0Vz5D2bOGTal5zgKapn3x+ Q4UP5CCsbVPkd8EhAk1ZxM7K2S8YpspWh8QtfWsDqFQ8jEsEFErPXAku1EXEhXEGpH+5 mmb6glX538DSRejOigJWPqCwmAZT0Ci8ZRWz1dkGMJU9LyId52eq8/+QPO98rLKhlpF9 FCmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=cINz1630; 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 c4-v6si7356537pfa.285.2018.08.09.04.41.21; Thu, 09 Aug 2018 04:41:36 -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=cINz1630; 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 S1731063AbeHIOE6 (ORCPT + 99 others); Thu, 9 Aug 2018 10:04:58 -0400 Received: from mail-eopbgr20102.outbound.protection.outlook.com ([40.107.2.102]:43520 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730803AbeHIOE6 (ORCPT ); Thu, 9 Aug 2018 10:04:58 -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:X-MS-Exchange-SenderADCheck; bh=UvUvp9NwGAkPWzMThcI1SN+/X9bJ1aAcEruDwW00XMM=; b=cINz1630qFkYKLm7E5VenlcGKeZynbtQosDs3cOwKxTyxu60gNSKTViz2Z1Eh5Ga+mNEkN9srdGh/tN0sqbzFHf171HjMS5WQaSGadQa+MSquBuIqAog3H78sdExQtoqB02iR7kfv7M3qZb5Fmz36G3SecMEe6YpAjfw7zDU29w= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from [172.16.25.169] (185.231.240.5) by DB6PR0801MB2023.eurprd08.prod.outlook.com (2603:10a6:4:76::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Thu, 9 Aug 2018 11:23:32 +0000 Subject: Re: [PATCH RFC v2 02/10] mm: Make shrink_slab() lockless To: Michal Hocko Cc: 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, sfr@canb.auug.org.au, vdavydov.dev@gmail.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 References: <153365347929.19074.12509495712735843805.stgit@localhost.localdomain> <153365626605.19074.16202958374930777592.stgit@localhost.localdomain> <591d2063-0511-103d-bef6-dd35f55afe32@virtuozzo.com> <4ceb948c-7ce7-0db3-17d8-82ef1e6e47cc@virtuozzo.com> <20180809071418.GA24884@dhcp22.suse.cz> From: Kirill Tkhai Message-ID: <964ee4fe-bbd1-0caa-4c5e-a73af99ee7bb@virtuozzo.com> Date: Thu, 9 Aug 2018 14:23:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180809071418.GA24884@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: VI1PR0202CA0026.eurprd02.prod.outlook.com (2603:10a6:803:14::39) To DB6PR0801MB2023.eurprd08.prod.outlook.com (2603:10a6:4:76::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4efb723-a0b5-41b7-1bfd-08d5fdea8c21 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:DB6PR0801MB2023; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2023;3:YfmT7w3LH7boKP1YcCazaCYDnGkpG5d9BveCL3JDVU3reO3vrgZ2mRX6tK5MbjxdKMmjtsm4ZZrXagTR+Osb5mQf6oP1CksMIewLzU/HN0Xyab5HZ5419QyPl8j1bBclOM54nuCDZMdgBbf+Og75pXu9vy5LiOi4+rP2NJcgQyuVmLZxDSyK2OY4uN9/W85Ej8jzmBSy7ZaU51dgTQDi5FUZrs7bly4z+/IzIgJfCoWPCJLRQUbjpUBy8Pqes9sB;25:qCZc6SK1y4/bbNQch01INsNH9Z3zH6+ZUozjRQ/WplKMF2d/5nCnX9XmQzbbLOl7pVmtQK3TZm1zGQF7NV8l0M4YTLpq4n/PziGHtRIsSxCrLBk7I5cv8ql72+VFWj8NxsIb+o2nYPP/kNGyiD7Z4+yt48ZimDQQYY5ac+nEU0p7y0YsOmsH+SjDCGn0aiZi31wRZppSwX9vm7MpHB0aKqesU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Qg7iZecgmHbXOLFuiC3n6JbBZkzueBiFHWEo62Rnur5KeGlwetf0AkU2fy6Xx1kvpS1QNBpR9mXaJoO8rSWKSFSL/rsMS2AeBivFv6jaXxH9mEWc2epVQ9na4mlOJP7YBgghLq9FMCnxduaUuuXkC+5I5vwjBVgw== 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)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:DB6PR0801MB2023;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0801MB2023; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(376002)(346002)(366004)(39850400004)(396003)(136003)(189003)(199004)(186003)(305945005)(7416002)(6916009)(7406005)(7736002)(93886005)(217873002)(2906002)(478600001)(6246003)(8936002)(77096007)(65826007)(6116002)(4326008)(39060400002)(23676004)(26005)(52116002)(52146003)(5660300001)(97736004)(2486003)(25786009)(76176011)(16526019)(3846002)(316002)(6486002)(58126008)(6666003)(16576012)(53546011)(31686004)(14444005)(386003)(47776003)(31696002)(86362001)(68736007)(64126003)(50466002)(229853002)(230700001)(66066001)(956004)(81156014)(2616005)(476003)(81166006)(106356001)(8676002)(11346002)(446003)(53936002)(65956001)(105586002)(36756003)(65806001)(486006);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0801MB2023;H:[172.16.25.169];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?MTtEQjZQUjA4MDFNQjI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wxnU3ZFxFeNjEd+LrHuq0d7YKJofw9n76IL0Zb52kKX7pbM+g53WJhLLGCpOlGKcQXoi+LuW0GW2y+mYfy2lAOBeT4cN0oKyRjQAmCxsMLFJfNCPGE2RYJRvD740fhgDa79oMosZRlXQgfzokA==;5:5LcdcmjMppRBZJBAaE6Kf0ecD2MogSulDJT5DXke44z3QP1mAI/JCCrhbcZa82s7/MrtkW+qfvxUaTqQWDr9WkfiQQR2uRuqb40DVUWLf4GbER8QvOVxuXlGu5ZUb9Gzrq1zS8IcLyjBnwKLr9CWY/KgIrFPbJbeKtncx1y5ibs=;7:kjsmbjMhpEOPv/C2aEZFYH3JEvb8AYA+tbJO7n5+fjfMkbJrGb2G/vMFAwobGhzfk22gd3bQSMR/gH0qpveWG/5oHFBBeg/NPUEzRlOYKLn3LofZqUMHEQjH+iQiAPL96GVtfUYCAaxvNrYrc0ZZ5dnKxUs/wZuWNERTvIm+WNqNHfpZxlXUcVf5uuW1u7sgh7tOKzEGuykdWUQL+YhvR+N1tKaWfLUDOOEv/FmbuVIwL0pJIIqWqkKVQNkonAv/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB2023;20:Kq7cmS0i/0vS7s3KvtB1jwpWjAoI4Ro/Vshbgm6P63Keb1ZU6n3HnQZ0K7PTqFJ5wQHatok9V3tzxJJsgZeo5V+J3vQx/eyYTwlo0vnW8PsZlJzJPnFiyHlFAH79W7j99z4rRh3WCrJw1jec5GpCTTpnpGstr9lBoRt7GaCzQ4o= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 11:23:32.4479 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4efb723-a0b5-41b7-1bfd-08d5fdea8c21 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2023 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09.08.2018 10:14, Michal Hocko wrote: > On Wed 08-08-18 16:20:54, Kirill Tkhai wrote: >> [Added two more places needed srcu_dereference(). All ->shrinker_map >> dereferences must be under SRCU, and this v2 adds missed in previous] >> >> 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(). > > An obvious question. Why didn't you go that way? What are pros/cons of > both approaches? percpu_rw_semaphore based variant looks something like: commit d581d4ad7ecf Author: Kirill Tkhai Date: Thu Aug 9 14:21:12 2018 +0300 diff --git a/mm/vmscan.c b/mm/vmscan.c index 0ff97e860759..fe8693775e33 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_PERCPU_RWSEM(shrinker_percpu_rwsem); #ifdef CONFIG_MEMCG_KMEM @@ -198,7 +199,10 @@ static int prealloc_memcg_shrinker(struct shrinker *shrinker) goto unlock; if (id >= shrinker_nr_max) { - if (memcg_expand_shrinker_maps(id)) { + percpu_down_write(&shrinker_percpu_rwsem); + ret = memcg_expand_shrinker_maps(id); + percpu_up_write(&shrinker_percpu_rwsem); + if (ret) { idr_remove(&shrinker_idr, id); goto unlock; } @@ -406,7 +410,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); #ifdef CONFIG_MEMCG_KMEM idr_replace(&shrinker_idr, shrinker, shrinker->id); #endif @@ -434,8 +438,14 @@ 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_rcu(); + + percpu_down_write(&shrinker_percpu_rwsem); + percpu_up_write(&shrinker_percpu_rwsem); + kfree(shrinker->nr_deferred); shrinker->nr_deferred = NULL; } @@ -574,11 +584,11 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, if (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)) return 0; - if (!down_read_trylock(&shrinker_rwsem)) + if (!percpu_down_read_trylock(&shrinker_percpu_rwsem)) return 0; map = rcu_dereference_protected(memcg->nodeinfo[nid]->shrinker_map, - true); + true /* shrinker_percpu_rwsem */); if (unlikely(!map)) goto unlock; @@ -590,7 +600,22 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, }; struct shrinker *shrinker; + /* + * See shutdown sequence in unregister_shrinker(). + * RCU allows us to iterate IDR locklessly (this + * is the way to synchronize with IDR changing by + * idr_alloc()). + * + * If we see shrinker pointer undex RCU, this means + * synchronize_rcu() in unregister_shrinker() has not + * finished yet. Then, we unlock RCU, and synchronize_rcu() + * can complete, but unregister_shrinker() can't proceed, + * before we unlock shrinker_percpu_rwsem. + */ + rcu_read_lock(); shrinker = idr_find(&shrinker_idr, i); + rcu_read_unlock(); + if (unlikely(!shrinker || shrinker == SHRINKER_REGISTERING)) { if (!shrinker) clear_bit(i, map->map); @@ -624,13 +649,13 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, } freed += ret; - if (rwsem_is_contended(&shrinker_rwsem)) { + if (!rcu_sync_is_idle(&shrinker_percpu_rwsem.rss)) { freed = freed ? : 1; break; } } unlock: - up_read(&shrinker_rwsem); + percpu_up_read(&shrinker_percpu_rwsem); return freed; } #else /* CONFIG_MEMCG_KMEM */ @@ -672,15 +697,17 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, if (!mem_cgroup_is_root(memcg)) return shrink_slab_memcg(gfp_mask, nid, memcg, priority); - if (!down_read_trylock(&shrinker_rwsem)) + if (!percpu_down_read_trylock(&shrinker_percpu_rwsem)) goto out; - list_for_each_entry(shrinker, &shrinker_list, list) { + rcu_read_lock(); + list_for_each_entry_rcu(shrinker, &shrinker_list, list) { struct shrink_control sc = { .gfp_mask = gfp_mask, .nid = nid, .memcg = memcg, }; + rcu_read_unlock(); ret = do_shrink_slab(&sc, shrinker, priority); if (ret == SHRINK_EMPTY) @@ -691,13 +718,16 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, * prevent the regsitration from being stalled for long periods * by parallel ongoing shrinking. */ - if (rwsem_is_contended(&shrinker_rwsem)) { + if (!rcu_sync_is_idle(&shrinker_percpu_rwsem.rss)) { freed = freed ? : 1; break; } + + rcu_read_lock(); } + rcu_read_unlock(); - up_read(&shrinker_rwsem); + percpu_up_read(&shrinker_percpu_rwsem); out: cond_resched(); return freed;