[{"id":3677775,"web_url":"http://patchwork.ozlabs.org/comment/3677775/","msgid":"<9210a276-8158-40f4-b3b5-6431f5f13541@paulmck-laptop>","list_archive_url":null,"date":"2026-04-15T17:39:33","subject":"Re: [PATCH nf,v2 1/3] rculist: add list_splice_rcu() for private\n lists","submitter":{"id":77583,"url":"http://patchwork.ozlabs.org/api/people/77583/","name":"Paul E. McKenney","email":"paulmck@kernel.org"},"content":"On Wed, Apr 15, 2026 at 07:08:44PM +0200, Pablo Neira Ayuso wrote:\n> This patch adds a helper function, list_splice_rcu(), to safely splice\n> a private (non-RCU-protected) list into an RCU-protected list.\n> \n> The function ensures that only the pointer visible to RCU readers\n> (prev->next) is updated using rcu_assign_pointer(), while the rest of\n> the list manipulations are performed with regular assignments, as the\n> source list is private and not visible to concurrent RCU readers.\n> \n> This is useful for moving elements from a private list into a global\n> RCU-protected list, ensuring safe publication for RCU readers.\n> Subsystems with some sort of batching mechanism from userspace can\n> benefit from this new function.\n> \n> The function __list_splice_rcu() has been added for clarity and to\n> follow the same pattern as in the existing list_splice*() interfaces,\n> where there is a check to ensure that that the list to splice is not\n> empty. Note that __list_splice_rcu() has no documentation for this\n> reason.\n> \n> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>\n> ---\n> v2: including comments by Paul McKenney.\n> \n>     Except, I have deliberately keep back the suggestion to squash\n>     __list_splice_rcu() into list_splice_rcu(), I instead removed\n>     the documentation for __list_splice_rcu(). I am looking\n>     at other existing list_splice*() function in list.h and rculist.h\n>     to get this aligned with __list_splice(), which also has no users\n>     in the tree and no documentation. I find it easier to read with\n>     __list_splice(), but if this explaination is not sound so...\n> \n>     @Paul: I can post v3 squashing __list_splice_rcu(), just let me\n>            know.\n\nRemoving the comment addresses most of my concerns.  I do have a slight\nbut not overwhelming preference for the squashed version, but either way:\n\nReviewed-by: Paul E. McKenney <paulmck@kernel.org>\n\nOr if you want this to go in via RCU, please let us know.  My guess is\nthat it would be easier for you to take it in with the code using it.\n\n\t\t\t\t\t\t\tThanx, Paul\n\n>     Thanks!\n> \n>  include/linux/rculist.h | 29 +++++++++++++++++++++++++++++\n>  1 file changed, 29 insertions(+)\n> \n> diff --git a/include/linux/rculist.h b/include/linux/rculist.h\n> index 2abba7552605..e3bc44225692 100644\n> --- a/include/linux/rculist.h\n> +++ b/include/linux/rculist.h\n> @@ -261,6 +261,35 @@ static inline void list_replace_rcu(struct list_head *old,\n>  \told->prev = LIST_POISON2;\n>  }\n>  \n> +static inline void __list_splice_rcu(struct list_head *list,\n> +\t\t\t\t     struct list_head *prev,\n> +\t\t\t\t     struct list_head *next)\n> +{\n> +\tstruct list_head *first = list->next;\n> +\tstruct list_head *last = list->prev;\n> +\n> +\tlast->next = next;\n> +\tfirst->prev = prev;\n> +\tnext->prev = last;\n> +\trcu_assign_pointer(list_next_rcu(prev), first);\n> +}\n> +\n> +/**\n> + * list_splice_rcu - splice a non-RCU list into an RCU-protected list,\n> + *                   designed for stacks.\n> + * @list:\tthe non RCU-protected list to splice\n> + * @head:\tthe place in the existing RCU-protected list to splice\n> + *\n> + * The list pointed to by @head can be RCU-read traversed concurrently with\n> + * this function.\n> + */\n> +static inline void list_splice_rcu(struct list_head *list,\n> +\t\t\t\t   struct list_head *head)\n> +{\n> +\tif (!list_empty(list))\n> +\t\t__list_splice_rcu(list, head, head->next);\n> +}\n> +\n>  /**\n>   * __list_splice_init_rcu - join an RCU-protected list into an existing list.\n>   * @list:\tthe RCU-protected list to splice\n> -- \n> 2.47.3\n> \n>","headers":{"Return-Path":"\n <netfilter-devel+bounces-11934-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","netfilter-devel@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=KvNpJEJT;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-11934-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"KvNpJEJT\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fwpLX6H6Qz1yHd\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 03:39:48 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id C61D2301231C\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 17:39:37 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 20D0F3E6386;\n\tWed, 15 Apr 2026 17:39:35 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A1ED6314A82;\n\tWed, 15 Apr 2026 17:39:34 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 004B1C19424;\n\tWed, 15 Apr 2026 17:39:33 +0000 (UTC)","by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000)\n\tid 93032CE0781; Wed, 15 Apr 2026 10:39:33 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776274774; cv=none;\n b=cXuOVk+hPoFuJK2uplairrauGIkdR07WzQz9K+PxeMiPeWQtp4UfoRL+zyP8VOnkeZ9kkbT3FdBRgElR7HIqWlh3jk4Y9VaPZJGkj5zDshyj1/T9thV8vdWFPnVscDODK2SJZoT1WKFk+cgBiftp94hM86F/osNyV4JD6tdNWDk=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776274774; c=relaxed/simple;\n\tbh=gPGHF3cu/RG4HIb6IsiMrXmvpuVwVLlNLA7KZZAJZV8=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=hUWzop2pTq1ZFzBOkfUl6hQKfcyiOXs/W8zljI9mUCHlvQsqkU8pTXixDB9Itcik8e7nu740ZgNsPl4A8Qbbldl+XmPzJO97v3AwTP4XfWGWPYs4Dbw6khpya8admKSxbaZ+QJ0XG5lgI7pVmP2b/xuxQZIwCjkCd5KsSOKxagA=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=KvNpJEJT; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1776274774;\n\tbh=gPGHF3cu/RG4HIb6IsiMrXmvpuVwVLlNLA7KZZAJZV8=;\n\th=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From;\n\tb=KvNpJEJTZzxeF/asC9lOsWr0VJ1wskeSDoV2h1oqRp/5db6vmR7BrvVG0JAtoA6IQ\n\t lq+LvzuKaCZeJ99zWBdaLQ1vO4Lb0Gqu4XXx7hXOEv0YkDwjkaxwxtuvHBi3i0gtLk\n\t LHxK5KUs2mGDZfm801QCIhJgbpa71orsntHgjztcUNS/m4IAC5O+8IG7Crckij9M7N\n\t AzdrLbcI3LKsRwK/dfCV8nvw7Fz78fy2FSySWe/SgA3jfoJtlghab5SAifpiPn33Br\n\t lesJNG/6BtmsymgG52TBzAgxJ8vv1oogI3Cpyy3gHPh1sgjaPHFwJa3Ywe6kpzAYuJ\n\t YkNdGG0aedeEw==","Date":"Wed, 15 Apr 2026 10:39:33 -0700","From":"\"Paul E. McKenney\" <paulmck@kernel.org>","To":"Pablo Neira Ayuso <pablo@netfilter.org>","Cc":"netfilter-devel@vger.kernel.org, davem@davemloft.net,\n\tnetdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,\n\tedumazet@google.com, fw@strlen.de, horms@kernel.org,\n\tjoelagnelf@nvidia.com, josh@joshtriplett.org, boqun@kernel.org,\n\turezki@gmail.com, rostedt@goodmis.org,\n\tmathieu.desnoyers@efficios.com, jiangshanlai@gmail.com,\n\tqiang.zhang@linux.dev, rcu@vger.kernel.org","Subject":"Re: [PATCH nf,v2 1/3] rculist: add list_splice_rcu() for private\n lists","Message-ID":"<9210a276-8158-40f4-b3b5-6431f5f13541@paulmck-laptop>","Reply-To":"paulmck@kernel.org","References":"<20260415170844.41355-1-pablo@netfilter.org>","Precedence":"bulk","X-Mailing-List":"netfilter-devel@vger.kernel.org","List-Id":"<netfilter-devel.vger.kernel.org>","List-Subscribe":"<mailto:netfilter-devel+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:netfilter-devel+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260415170844.41355-1-pablo@netfilter.org>"}},{"id":3677811,"web_url":"http://patchwork.ozlabs.org/comment/3677811/","msgid":"<ad_0N6yAOenXeXR7@chamomile>","list_archive_url":null,"date":"2026-04-15T20:25:27","subject":"Re: [PATCH nf,v2 1/3] rculist: add list_splice_rcu() for private\n lists","submitter":{"id":1315,"url":"http://patchwork.ozlabs.org/api/people/1315/","name":"Pablo Neira Ayuso","email":"pablo@netfilter.org"},"content":"On Wed, Apr 15, 2026 at 10:39:33AM -0700, Paul E. McKenney wrote:\n> On Wed, Apr 15, 2026 at 07:08:44PM +0200, Pablo Neira Ayuso wrote:\n> > This patch adds a helper function, list_splice_rcu(), to safely splice\n> > a private (non-RCU-protected) list into an RCU-protected list.\n> > \n> > The function ensures that only the pointer visible to RCU readers\n> > (prev->next) is updated using rcu_assign_pointer(), while the rest of\n> > the list manipulations are performed with regular assignments, as the\n> > source list is private and not visible to concurrent RCU readers.\n> > \n> > This is useful for moving elements from a private list into a global\n> > RCU-protected list, ensuring safe publication for RCU readers.\n> > Subsystems with some sort of batching mechanism from userspace can\n> > benefit from this new function.\n> > \n> > The function __list_splice_rcu() has been added for clarity and to\n> > follow the same pattern as in the existing list_splice*() interfaces,\n> > where there is a check to ensure that that the list to splice is not\n> > empty. Note that __list_splice_rcu() has no documentation for this\n> > reason.\n> > \n> > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>\n> > ---\n> > v2: including comments by Paul McKenney.\n> > \n> >     Except, I have deliberately keep back the suggestion to squash\n> >     __list_splice_rcu() into list_splice_rcu(), I instead removed\n> >     the documentation for __list_splice_rcu(). I am looking\n> >     at other existing list_splice*() function in list.h and rculist.h\n> >     to get this aligned with __list_splice(), which also has no users\n> >     in the tree and no documentation. I find it easier to read with\n> >     __list_splice(), but if this explaination is not sound so...\n> > \n> >     @Paul: I can post v3 squashing __list_splice_rcu(), just let me\n> >            know.\n> \n> Removing the comment addresses most of my concerns.  I do have a slight\n> but not overwhelming preference for the squashed version, but either way:\n> \n> Reviewed-by: Paul E. McKenney <paulmck@kernel.org>\n> \n> Or if you want this to go in via RCU, please let us know.  My guess is\n> that it would be easier for you to take it in with the code using it.\n\nI'd prefer to take it through nf.git, I need this as a fix for an\ninvalid use of list_splice() on a RCU-protected list.\n\nThanks for your quick review Paul!","headers":{"Return-Path":"\n <netfilter-devel+bounces-11940-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","netfilter-devel@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=netfilter.org header.i=@netfilter.org\n header.a=rsa-sha256 header.s=2025 header.b=QL9cHMuZ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-11940-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org\n header.b=\"QL9cHMuZ\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=217.70.190.124","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=netfilter.org","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=netfilter.org"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fwt2G6WDHz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 06:25:58 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id A96DF302A7EC\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 20:25:39 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 66F9B388382;\n\tWed, 15 Apr 2026 20:25:35 +0000 (UTC)","from mail.netfilter.org (mail.netfilter.org [217.70.190.124])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 92ED231D372;\n\tWed, 15 Apr 2026 20:25:32 +0000 (UTC)","from netfilter.org (mail-agni [217.70.190.124])\n\tby mail.netfilter.org (Postfix) with UTF8SMTPSA id 392A0600B9;\n\tWed, 15 Apr 2026 22:25:30 +0200 (CEST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776284735; cv=none;\n b=n6djdQE4NxOCApdwspXKa59xvlxhVoUSIEGO6v0lA5nLJpqy983FqBdRI7lmYVTpkZMM8MZ+I4veBoNPt4e6u2bpdlSfGmF0pycfCY+aRNqGRwc7uh5dnbT5563qHThlzWIxLTpCFTQfn7n06JB72+7LcULWguyLLWkFVFLlvXM=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776284735; c=relaxed/simple;\n\tbh=lTDSEfgLiPb6Zc6xiCp9O+PQaNg/usqGgZY7lpdsvjk=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=XI/Dm+l0VFXHYn3wxDzK4NqVP32925+06MXB9KM5ntzW/eYQTaQ5Blka38wvWsxwXYTw8wVK/v0h7zZXVEk6yBy1ukDS0KffSahpuQyvnD10HQdopdm16CJE9diH1L1YQngieC7E/gAISOTotA/lWwS4ljHStg0iZ1QLovuwgFc=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=netfilter.org;\n spf=pass smtp.mailfrom=netfilter.org;\n dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org\n header.b=QL9cHMuZ; arc=none smtp.client-ip=217.70.190.124","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org;\n\ts=2025; t=1776284730;\n\tbh=05tOkxOHaDMCzwX9o+tLfnCgbcASN3tKZPZ703Z0qLA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=QL9cHMuZ7P9f/cOcS15BsGu1PaFGWrUUs0WXR/eAkKBrimFL5yZ/dDV0vqjSGO7WM\n\t 83e5Ilv4mfAWq35SWajTqRAbXA9UzcfM2+yTi0gMQsRHB8j5cp4tnirCu5oGvRHWEy\n\t 3wtnXH1joB67pNU0P6SqgzMHUQkJ0X/YBW3j7Vlrccm85wDmUs1gJymHQDtNP9MeLY\n\t Jfw1NXqHrDAs4O6ferznZw6drjnWm+F79XG6cBJAohsVzVsv9/Ik4XbIN/ASVrItZo\n\t 6nO+Y5fxjmhtLRoEIZShNiH4vpgx5RSaKXMcz6FHTl5KtLUNve4U3G4PDdUW5R0nmp\n\t sfnbdTlZfpHPQ==","Date":"Wed, 15 Apr 2026 22:25:27 +0200","From":"Pablo Neira Ayuso <pablo@netfilter.org>","To":"\"Paul E. McKenney\" <paulmck@kernel.org>","Cc":"netfilter-devel@vger.kernel.org, davem@davemloft.net,\n\tnetdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,\n\tedumazet@google.com, fw@strlen.de, horms@kernel.org,\n\tjoelagnelf@nvidia.com, josh@joshtriplett.org, boqun@kernel.org,\n\turezki@gmail.com, rostedt@goodmis.org,\n\tmathieu.desnoyers@efficios.com, jiangshanlai@gmail.com,\n\tqiang.zhang@linux.dev, rcu@vger.kernel.org","Subject":"Re: [PATCH nf,v2 1/3] rculist: add list_splice_rcu() for private\n lists","Message-ID":"<ad_0N6yAOenXeXR7@chamomile>","References":"<20260415170844.41355-1-pablo@netfilter.org>\n <9210a276-8158-40f4-b3b5-6431f5f13541@paulmck-laptop>","Precedence":"bulk","X-Mailing-List":"netfilter-devel@vger.kernel.org","List-Id":"<netfilter-devel.vger.kernel.org>","List-Subscribe":"<mailto:netfilter-devel+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:netfilter-devel+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<9210a276-8158-40f4-b3b5-6431f5f13541@paulmck-laptop>"}}]