From: "Paul E. McKenney" <paulmck@kernel.org>
To: Keith Busch <kbusch@kernel.org>
Cc: Nilay Shroff <nilay@linux.ibm.com>, Keith Busch <kbusch@meta.com>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, hch@lst.de, sagi@grimberg.me,
davidgow@google.com, akpm@linux-foundation.org,
venkat88@linux.vnet.ibm.com
Subject: Re: [PATCH 1/2] list: introduce a new cutting helper
Date: Thu, 13 Jun 2024 10:39:12 -0700 [thread overview]
Message-ID: <c65e7fef-cfee-4360-b03c-cfdd832912a4@paulmck-laptop> (raw)
In-Reply-To: <ZmsZ_lKgOlB6Wypy@kbusch-mbp.dhcp.thefacebook.com>
On Thu, Jun 13, 2024 at 10:10:38AM -0600, Keith Busch wrote:
> On Thu, Jun 13, 2024 at 09:01:47AM -0700, Paul E. McKenney wrote:
> >
> > Is there a way to avoid this issue by making this be a statement parameter
> > to a macro?
>
> Something like this? It appears to work for the intended use, at least.
>
> ---
> diff --git a/include/linux/rculist.h b/include/linux/rculist.h
> index 3dc1e58865f77..cdd2e5c0d5cdb 100644
> --- a/include/linux/rculist.h
> +++ b/include/linux/rculist.h
> @@ -204,6 +204,30 @@ static inline void list_replace_rcu(struct list_head *old,
> old->prev = LIST_POISON2;
> }
>
> +
> +static inline void __list_cut_start(struct list_head *list,
> + struct list_head *head,
> + struct list_head *entry)
> +{
> + list->next = entry;
> + list->prev = head->prev;
> + __list_del(entry->prev, head);
> +}
> +
> +static inline void __list_cut_end(struct list_head *list,
> + struct list_head *entry)
> +{
> + entry->prev = list;
> + list->prev->next = list;
> +}
> +
> +#define list_cut_rcu(list, head, entry, sync) \
> + do { \
> + __list_cut_start(list, head, entry); \
At this point, old readers might see the new list starting from "head"
and new readers see the new (shorter) list, again, starting from "head".
Presumably no readers can yet see "list".
> + sync; \
There are now no old readers, and thus no readers that can see
any elements in the list starting from "entry".
> + __list_cut_end(list, entry); \
And this fixes up the list now headed by "list".
So:
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
And another argument for lambdas, not that there is a shortage of
arguments against them. ;-)
> + } while (0)
> +
> /**
> * __list_splice_init_rcu - join an RCU-protected list into an existing list.
> * @list: the RCU-protected list to splice
> --
prev parent reply other threads:[~2024-06-13 17:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 15:51 [PATCH 1/2] list: introduce a new cutting helper Keith Busch
2024-06-12 15:51 ` [PATCH 2/2] nvme: fix namespace removal list Keith Busch
2024-06-12 17:20 ` Chaitanya Kulkarni
2024-06-12 17:24 ` Keith Busch
2024-06-12 17:19 ` [PATCH 1/2] list: introduce a new cutting helper Chaitanya Kulkarni
2024-06-13 4:56 ` Nilay Shroff
2024-06-13 8:10 ` Christoph Hellwig
2024-06-13 13:00 ` Keith Busch
2024-06-13 12:56 ` Keith Busch
2024-06-13 13:41 ` Nilay Shroff
2024-06-13 14:36 ` Keith Busch
2024-06-13 14:43 ` Paul E. McKenney
2024-06-13 14:47 ` Keith Busch
2024-06-13 15:15 ` Paul E. McKenney
2024-06-13 15:40 ` Keith Busch
2024-06-13 16:01 ` Paul E. McKenney
2024-06-13 16:10 ` Keith Busch
2024-06-13 17:39 ` Paul E. McKenney [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c65e7fef-cfee-4360-b03c-cfdd832912a4@paulmck-laptop \
--to=paulmck@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=davidgow@google.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kbusch@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=nilay@linux.ibm.com \
--cc=sagi@grimberg.me \
--cc=venkat88@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).