lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c65e7fef-cfee-4360-b03c-cfdd832912a4@paulmck-laptop>
Date: Thu, 13 Jun 2024 10:39:12 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Keith Busch <kbusch@...nel.org>
Cc: Nilay Shroff <nilay@...ux.ibm.com>, Keith Busch <kbusch@...a.com>,
	linux-nvme@...ts.infradead.org, linux-kernel@...r.kernel.org,
	linux-kselftest@...r.kernel.org, hch@....de, sagi@...mberg.me,
	davidgow@...gle.com, akpm@...ux-foundation.org,
	venkat88@...ux.vnet.ibm.com
Subject: Re: [PATCH 1/2] list: introduce a new cutting helper

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@...nel.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
> --

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ