From patchwork Fri Aug 9 15:02:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13758868 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA362C3DA4A for ; Fri, 9 Aug 2024 15:02:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6489C6B00A0; Fri, 9 Aug 2024 11:02:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F7EA6B00A2; Fri, 9 Aug 2024 11:02:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44B236B00A3; Fri, 9 Aug 2024 11:02:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 257BD6B00A0 for ; Fri, 9 Aug 2024 11:02:54 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CE1701C4BD7 for ; Fri, 9 Aug 2024 15:02:53 +0000 (UTC) X-FDA: 82433024226.16.7874259 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf03.hostedemail.com (Postfix) with ESMTP id 48D422002E for ; Fri, 9 Aug 2024 15:02:49 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=kady5WHm; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=trrxkWzm; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=q2Vn5zKZ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=JwW7fFYa; spf=pass (imf03.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723215704; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=m6ODK5n8Ww4+d1x9prn8X3lC5bnbKDRJfsW7yKouSrs=; b=JqgaA9WcKAa1ud78jSxhriFyIk6JNN0PNoAKOZ7YbO1bSOD6THUpqE8p2PD5hI9yETFZhz fN9Slehb69yeJICDtnPmrpqtXks9Zvev0nvG0DRnI9E0N+AXvTrnQdol5qMfB3LvqsIpiS FmnwkJwXpwWdh6J6z5lf7nYRfCNmMCU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723215704; a=rsa-sha256; cv=none; b=AjOTidctLhQmwxp2quwH5nSNckV3nFLySsmW5aiAlJKR5wBBD8nX/fO/Q6Aff1RQPz8t1t sGEqbs2NtmcofaBG4nLRkN9NZAmlQcEgCZZX853Ls7flftF6u/KxhAJkkletqZJY5VWUft aPr1LIVvAqKa2tc47HDdBqx5NTaoPsY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=kady5WHm; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=trrxkWzm; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=q2Vn5zKZ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=JwW7fFYa; spf=pass (imf03.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 87C1A1FF8F; Fri, 9 Aug 2024 15:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723215768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=m6ODK5n8Ww4+d1x9prn8X3lC5bnbKDRJfsW7yKouSrs=; b=kady5WHmwOZaRZT/UYfShHdxIuYNj7wSlnCtvh7t12iffakwexzmLi9qcz4k7/HWz14fGe +momoW4JcNFbhkTcv7feHike7c5X154Vz3NmK6vMqrYiFXb6gLNCrHFKwU3OJ+xEjjmUar oHVh+gkuJEdM+pGfJ8F9fCmSzRD6v14= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723215768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=m6ODK5n8Ww4+d1x9prn8X3lC5bnbKDRJfsW7yKouSrs=; b=trrxkWzm/wy/++Pvf5b3e6EpGBWPxGKge55iEyKhZXUw56yv4V42iLbacW5Rp/odpvviQp MpqTbsrD3DiEqbAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1723215767; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=m6ODK5n8Ww4+d1x9prn8X3lC5bnbKDRJfsW7yKouSrs=; b=q2Vn5zKZ6nLDVEhq4Hq01HPqcRPaXt8lnspZxGFumKBtp4iXUJYoUIyzyuSCeNTee2ffc6 gwgFijUq62nxK5sRW3/gSgTYZFF+1WvnRRBsgNPOU3hBQWVsGQqE9gD7JIOtxBFD4Wi8Ra mlcfeL6wa0iO9KGvvf4pyCVQ/IjxZzU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1723215767; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=m6ODK5n8Ww4+d1x9prn8X3lC5bnbKDRJfsW7yKouSrs=; b=JwW7fFYagAG1R2f8Bv3+ew7sBpSKdmazRtEjiwcrpdktc5AmFCH9qRnwj9yzuZBIvA8LTS oQfq+L16ow5UAUBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 74B311379A; Fri, 9 Aug 2024 15:02:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 1lL2GpUvtmZ9HQAAD6G6ig (envelope-from ); Fri, 09 Aug 2024 15:02:45 +0000 Message-ID: <54d62d5a-16e3-4ea9-83c6-8801ee99855e@suse.cz> Date: Fri, 9 Aug 2024 17:02:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [-next conflict imminent] Re: [PATCH v2 0/7] mm, slub: handle pending kfree_rcu() in kmem_cache_destroy() Content-Language: en-US To: "Paul E. McKenney" , Joel Fernandes , Josh Triplett , Boqun Feng , Christoph Lameter , David Rientjes , Stephen Rothwell Cc: Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Julia Lawall , Jakub Kicinski , "Jason A. Donenfeld" , "Uladzislau Rezki (Sony)" , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, Alexander Potapenko , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com, Jann Horn , Mateusz Guzik References: <20240807-b4-slab-kfree_rcu-destroy-v2-0-ea79102f428c@suse.cz> From: Vlastimil Babka Autocrypt: addr=vbabka@suse.cz; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOXFphWb2yq3nzrKe45oWoSgkxKb97MVsQ+q2SYjJRBBH4 8qKhphADYxkIP6yut/eaj9ImvRUZZRi0DTc8xfnvHGTjKbJzC2xpFcY0DQbZzuwsIZ8OPJCc LM4S7mT25NE5kUTG/TKQCk922vRdGVMoLA7dIQrgXnRXtyT61sg8PG4wcfOnuWf8577aXP1x 6mzw3/jh3F+oSBHb/GcLC7mvWreJifUL2gEdssGfXhGWBo6zLS3qhgtwjay0Jl+kza1lo+Cv BB2T79D4WGdDuVa4eOrQ02TxqGN7G0Biz5ZLRSFzQSQwLn8fbwARAQABzSBWbGFzdGltaWwg QmFia2EgPHZiYWJrYUBzdXNlLmN6PsLBlAQTAQoAPgIbAwULCQgHAwUVCgkICwUWAgMBAAIe AQIXgBYhBKlA1DSZLC6OmRA9UCJP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gsF2odzieNABEBAAHCwXwEGAEKACYCGwwWIQSpQNQ0mSwujpkQ PVAiT6fnzIKmZAUCZAUSmwUJDK5EZgAKCRAiT6fnzIKmZOJGEACOKABgo9wJXsbWhGWYO7mD 8R8mUyJHqbvaz+yTLnvRwfe/VwafFfDMx5GYVYzMY9TWpA8psFTKTUIIQmx2scYsRBUwm5VI EurRWKqENcDRjyo+ol59j0FViYysjQQeobXBDDE31t5SBg++veI6tXfpco/UiKEsDswL1WAr tEAZaruo7254TyH+gydURl2wJuzo/aZ7Y7PpqaODbYv727Dvm5eX64HCyyAH0s6sOCyGF5/p eIhrOn24oBf67KtdAN3H9JoFNUVTYJc1VJU3R1JtVdgwEdr+NEciEfYl0O19VpLE/PZxP4wX PWnhf5WjdoNI1Xec+RcJ5p/pSel0jnvBX8L2cmniYnmI883NhtGZsEWj++wyKiS4NranDFlA HdDM3b4lUth1pTtABKQ1YuTvehj7EfoWD3bv9kuGZGPrAeFNiHPdOT7DaXKeHpW9homgtBxj 8aX/UkSvEGJKUEbFL9cVa5tzyialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: <20240807-b4-slab-kfree_rcu-destroy-v2-0-ea79102f428c@suse.cz> X-Stat-Signature: 9jo17onqfpe4iogo8azzobt41axaxpoc X-Rspamd-Queue-Id: 48D422002E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1723215769-323115 X-HE-Meta: U2FsdGVkX1+1JNd+RMy7eiihvzrEBCFxbuHfRkkFeZed6GP7zYXwoEnJecYRviteJd23tUdBaAV+SvmHcIADLj+CmfAumVgJNv+Cnw3IU0gB9PCvpcH9NGlF1EYfGk0aDkYYvy/4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Uq42CQs5NqZg3BkH4ULAsMDNgr/WE+EtZDozTtzLQYRGwj0i87Z90ZScS6TZHIa1I86C/HsfUEWi5oJ0LFEiRzAIrdJ3x3zUCQD/BRrCltTJqPC41KMzsdiI1k1c1ZLUOgN8c9HcUu6IWFld4Q7LHbtxcD7T3Jx6w/BJYb659LwnozXG1VrSQkQ+/94pawxCi0LMZPEZVSFWcb3CEZxLS9rcRDDC1ZibCufvI30DN 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: List-Subscribe: List-Unsubscribe: On 8/7/24 12:31, Vlastimil Babka wrote: > Also in git: > https://git.kernel.org/vbabka/l/slab-kfree_rcu-destroy-v2r2 I've added this to slab/for-next, there will be some conflicts and here's my resulting git show or the merge commit I tried over today's next. It might look a bit different with tomorrow's next as mm will have v7 of the conflicting series from Jann: https://lore.kernel.org/all/1ca6275f-a2fc-4bad-81dc-6257d4f8d750@suse.cz/ (also I did resolve it in the way I suggested to move Jann's block before taking slab_mutex() but unless that happens in mm-unstable it would probably be more correct to keep where he did) ---8<--- commit 444486f2b7b0325ba026e0ad129eba3f54c18301 Merge: 61c01d2e181a 63eac6bdcf9f Author: Vlastimil Babka Date: Fri Aug 9 16:49:03 2024 +0200 Merge branch 'slab/for-6.12/rcu_barriers' into HEAD +++ b/include/linux/rcutree.h @@@ -35,9 -35,10 +35,10 @@@ static inline void rcu_virt_note_contex void synchronize_rcu_expedited(void); void kvfree_call_rcu(struct rcu_head *head, void *ptr); + void kvfree_rcu_barrier(void); void rcu_barrier(void); -void rcu_momentary_dyntick_idle(void); +void rcu_momentary_eqs(void); void kfree_rcu_scheduler_running(void); bool rcu_gp_might_be_stalled(void); +++ b/kernel/rcu/tree.c @@@ -3614,7 -3631,7 +3611,7 @@@ kvfree_rcu_queue_batch(struct kfree_rcu // be that the work is in the pending state when // channels have been detached following by each // other. - queue_rcu_work(system_unbound_wq, &krwp->rcu_work); - queued = queue_rcu_work(system_wq, &krwp->rcu_work); ++ queued = queue_rcu_work(system_unbound_wq, &krwp->rcu_work); } } +++ b/mm/slab_common.c @@@ -511,67 -487,40 +505,52 @@@ EXPORT_SYMBOL(kmem_buckets_create) */ static void kmem_cache_release(struct kmem_cache *s) { - if (slab_state >= FULL) { - sysfs_slab_unlink(s); + kfence_shutdown_cache(s); + if (__is_defined(SLAB_SUPPORTS_SYSFS) && slab_state >= FULL) sysfs_slab_release(s); - } else { + else slab_kmem_cache_release(s); - } } - #else - static void kmem_cache_release(struct kmem_cache *s) + + void slab_kmem_cache_release(struct kmem_cache *s) { - slab_kmem_cache_release(s); + __kmem_cache_release(s); + kfree_const(s->name); + kmem_cache_free(kmem_cache, s); } - #endif - static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work) + void kmem_cache_destroy(struct kmem_cache *s) { - LIST_HEAD(to_destroy); - struct kmem_cache *s, *s2; - - /* - * On destruction, SLAB_TYPESAFE_BY_RCU kmem_caches are put on the - * @slab_caches_to_rcu_destroy list. The slab pages are freed - * through RCU and the associated kmem_cache are dereferenced - * while freeing the pages, so the kmem_caches should be freed only - * after the pending RCU operations are finished. As rcu_barrier() - * is a pretty slow operation, we batch all pending destructions - * asynchronously. - */ - mutex_lock(&slab_mutex); - list_splice_init(&slab_caches_to_rcu_destroy, &to_destroy); - mutex_unlock(&slab_mutex); + int err; - if (list_empty(&to_destroy)) + if (unlikely(!s) || !kasan_check_byte(s)) return; - rcu_barrier(); + /* in-flight kfree_rcu()'s may include objects from our cache */ + kvfree_rcu_barrier(); - list_for_each_entry_safe(s, s2, &to_destroy, list) { - debugfs_slab_release(s); - kfence_shutdown_cache(s); - kmem_cache_release(s); - } - } - - static int shutdown_cache(struct kmem_cache *s) - { + if (IS_ENABLED(CONFIG_SLUB_RCU_DEBUG) && + (s->flags & SLAB_TYPESAFE_BY_RCU)) { + /* + * Under CONFIG_SLUB_RCU_DEBUG, when objects in a + * SLAB_TYPESAFE_BY_RCU slab are freed, SLUB will internally + * defer their freeing with call_rcu(). + * Wait for such call_rcu() invocations here before actually + * destroying the cache. + */ + rcu_barrier(); + } + + cpus_read_lock(); + mutex_lock(&slab_mutex); + + s->refcount--; + if (s->refcount) { + mutex_unlock(&slab_mutex); + cpus_read_unlock(); + return; + } + /* free asan quarantined objects */ kasan_cache_shutdown(s); diff --cc include/linux/rcutree.h index 7dbde2b6f714,58e7db80f3a8..90a684f94776 --- a/include/linux/rcutree.h diff --cc kernel/rcu/tree.c index 930846f06bee,ebcfed9b570e..4606fa361b06 --- a/kernel/rcu/tree.c diff --cc mm/slab_common.c index fc7b1250d929,1a2873293f5d..82f287c21954 --- a/mm/slab_common.c