From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.zx2c4.com (lists.zx2c4.com [165.227.139.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF25CC2BB85 for ; Mon, 17 Jun 2024 21:19:44 +0000 (UTC) Received: by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 86756316; Mon, 17 Jun 2024 21:18:01 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [2a07:de40:b251:101:10:150:64:2]) by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTPS id e00d440f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Mon, 17 Jun 2024 21:17:58 +0000 (UTC) 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 ABA921F395; Mon, 17 Jun 2024 21:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1718659077; 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; bh=IUds48oScu4/C+pkGPV1ry62ZJoePkIvLYk2jW3f754=; b=pa0lswvzDFMjD8H7K4gdtAUq5symiJaQRcEJTjFu4e/Aw/UniD4OjZndbSp/Uu7qVqV4Jw Bld+pO5JBLkMwO+x3Fnd3CwF1tfQHPHFMzn7r1uQKnyFMhAHHepmbXEps5ckzykTKieaoV xFhUH1/ZZfxtme24TLVbED3e7a+sZho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1718659077; 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; bh=IUds48oScu4/C+pkGPV1ry62ZJoePkIvLYk2jW3f754=; b=uDHwF1Oro49W1/+Lg8Aumr/UbHq+X8871hqwesFOgR4apjhiRGrItN7gCEjvBAs6D+uTQz j8aLNJ49YSO7p9BQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1718659076; 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; bh=IUds48oScu4/C+pkGPV1ry62ZJoePkIvLYk2jW3f754=; b=FF0jdC88vsv3Mazo5aoTk/icaEwSKhBU9g/15c7soDFDi/7D3b7GT4wE3fOvSSfJt3Uzn/ maZOpELYGdji/vMja5AQs5K8FcMvbesycLyixY4dCanyjRNBR1LO+QH8plF1WWPo2+BK87 XYTYr6ulYEryja/CJGfoAl+B5INpgbY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1718659076; 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; bh=IUds48oScu4/C+pkGPV1ry62ZJoePkIvLYk2jW3f754=; b=TuCB6fhwOvdyoJ1YLynNsz7cy1vl4m/OgMpfHRHpVjrdJr4EDStSvK76MnPDBmm3uL3boo KLBlQyL45iZAzlAw== 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 5A0BD13AAA; Mon, 17 Jun 2024 21:17:56 +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 SlZzFQSocGYMTgAAD6G6ig (envelope-from ); Mon, 17 Jun 2024 21:17:56 +0000 Message-ID: Date: Mon, 17 Jun 2024 23:19:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 00/14] replace call_rcu by kfree_rcu for simple kmem_cache_free callback To: "Jason A. Donenfeld" Cc: Uladzislau Rezki , "Paul E. McKenney" , Jakub Kicinski , Julia Lawall , linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org, bridge@lists.linux.dev, linux-trace-kernel@vger.kernel.org, Mathieu Desnoyers , kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Naveen N. Rao" , Christophe Leroy , Nicholas Piggin , netdev@vger.kernel.org, wireguard@lists.zx2c4.com, linux-kernel@vger.kernel.org, ecryptfs@vger.kernel.org, Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , linux-nfs@vger.kernel.org, linux-can@vger.kernel.org, Lai Jiangshan , netfilter-devel@vger.kernel.org, coreteam@netfilter.org References: From: Vlastimil Babka Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-8.29 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[28]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; FREEMAIL_CC(0.00)[gmail.com,kernel.org,inria.fr,vger.kernel.org,lists.linux.dev,efficios.com,lists.ozlabs.org,linux.ibm.com,csgroup.eu,lists.zx2c4.com,suse.de,netapp.com,oracle.com,talpey.com,netfilter.org]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-BeenThere: wireguard@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: wireguard-bounces@lists.zx2c4.com Sender: "WireGuard" On 6/17/24 7:04 PM, Jason A. Donenfeld wrote: >>> Vlastimil, this is just checking a boolean (which could be >>> unlikely()'d), which should have pretty minimal overhead. Is that >>> alright with you? >> >> Well I doubt we can just set and check it without any barriers? The >> completion of the last pending kfree_rcu() might race with >> kmem_cache_destroy() in a way that will leave the cache there forever, no? >> And once we add barriers it becomes a perf issue? > > Hm, yea you might be right about barriers being required. But actually, > might this point toward a larger problem with no matter what approach, > polling or event, is chosen? If the current rule is that > kmem_cache_free() must never race with kmem_cache_destroy(), because Yes calling alloc/free operations that race with destroy is a bug and we can't prevent that. > users have always made diligent use of call_rcu()/rcu_barrier() and But the issue we are solving here is a bit different - the users are not buggy, they do kfree_rcu() and then kmem_cache_destroy() and no more operations on the cache afterwards. We need to ensure that the handling of kfree_rcu() (which ultimately is basically kmem_cache_free() but internally to rcu/slub) doesn't race with kmem_cache_destroy(). > such, but now we're going to let those race with each other - either by > my thing above or by polling - so we're potentially going to get in trouble > and need some barriers anyway. The barrier in the async part of kmem_cache_destroy() should be enough to make sure all kfree_rcu() have finished before we proceed with the potentially racy parts of destroying, and we should be able to avoid changes in kmem_cache_free(). > I think? > > Jason