linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: paulmck@linux.vnet.ibm.com
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Trond Myklebust <trond.myklebust@primarydata.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	linux-nfs@vger.kernel.org, Lai Jiangshan <jiangshanlai@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4 v2] rculist: add list_for_each_entry_from_rcu()
Date: Wed, 02 May 2018 07:34:56 +1000	[thread overview]
Message-ID: <87vac7giv3.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20180501141404.GD26088@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 4635 bytes --]

On Tue, May 01 2018, Paul E. McKenney wrote:

> On Tue, May 01, 2018 at 01:11:29PM +1000, NeilBrown wrote:
>> 
>> list_for_each_entry_from_rcu() is an RCU version of
>> list_for_each_entry_from().  It walks a linked list under rcu
>> protection, from a given start point.
>> 
>> It is similar to list_for_each_entry_continue_rcu() but starts *at*
>> the given position rather than *after* it.
>> 
>> Naturally, the start point must be known to be in the list.
>> 
>> Also update the documentation for list_for_each_entry_continue_rcu()
>> to match the documentation for the new list_for_each_entry_from_rcu(),
>> and add list_for_each_entry_from_rcu() and the already existing
>> hlist_for_each_entry_from_rcu() to section 7 of whatisRCU.txt.
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>
> I am guessing that it would be more convenient for you to carry this
> with the patches using it, so:
>
> Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Thanks Paul,
 yes I do hope this patch will go in with the other NFS patches.
 I'll wait to see what Trond and Anna think before proceeding with
 anything myself.

Thanks a lot,
NeilBrown


>
> If not, please let me know.
>
> 							Thanx, Paul
>
>> ---
>>  Documentation/RCU/whatisRCU.txt |  2 ++
>>  include/linux/rculist.h         | 32 +++++++++++++++++++++++++++++++-
>>  2 files changed, 33 insertions(+), 1 deletion(-)
>> 
>> diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
>> index a27fbfb0efb8..b7d38bd212d2 100644
>> --- a/Documentation/RCU/whatisRCU.txt
>> +++ b/Documentation/RCU/whatisRCU.txt
>> @@ -814,11 +814,13 @@ RCU list traversal:
>>  	list_next_rcu
>>  	list_for_each_entry_rcu
>>  	list_for_each_entry_continue_rcu
>> +	list_for_each_entry_from_rcu
>>  	hlist_first_rcu
>>  	hlist_next_rcu
>>  	hlist_pprev_rcu
>>  	hlist_for_each_entry_rcu
>>  	hlist_for_each_entry_rcu_bh
>> +	hlist_for_each_entry_from_rcu
>>  	hlist_for_each_entry_continue_rcu
>>  	hlist_for_each_entry_continue_rcu_bh
>>  	hlist_nulls_first_rcu
>> diff --git a/include/linux/rculist.h b/include/linux/rculist.h
>> index 127f534fec94..4786c2235b98 100644
>> --- a/include/linux/rculist.h
>> +++ b/include/linux/rculist.h
>> @@ -396,13 +396,43 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,
>>   * @member:	the name of the list_head within the struct.
>>   *
>>   * Continue to iterate over list of given type, continuing after
>> - * the current position.
>> + * the current position which must have been in the list when the RCU read
>> + * lock was taken.
>> + * This would typically require either that you obtained the node from a
>> + * previous walk of the list in the same RCU read-side critical section, or
>> + * that you held some sort of non-RCU reference (such as a reference count)
>> + * to keep the node alive *and* in the list.
>> + *
>> + * This iterator is similar to list_for_each_entry_from_rcu() except
>> + * this starts after the given position and that one starts at the given
>> + * position.
>>   */
>>  #define list_for_each_entry_continue_rcu(pos, head, member) 		\
>>  	for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
>>  	     &pos->member != (head);	\
>>  	     pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
>>  
>> +/**
>> + * list_for_each_entry_from_rcu - iterate over a list from current point
>> + * @pos:	the type * to use as a loop cursor.
>> + * @head:	the head for your list.
>> + * @member:	the name of the list_node within the struct.
>> + *
>> + * Iterate over the tail of a list starting from a given position,
>> + * which must have been in the list when the RCU read lock was taken.
>> + * This would typically require either that you obtained the node from a
>> + * previous walk of the list in the same RCU read-side critical section, or
>> + * that you held some sort of non-RCU reference (such as a reference count)
>> + * to keep the node alive *and* in the list.
>> + *
>> + * This iterator is similar to list_for_each_entry_continue_rcu() except
>> + * this starts from the given position and that one starts from the position
>> + * after the given position.
>> + */
>> +#define list_for_each_entry_from_rcu(pos, head, member)			\
>> +	for (; &(pos)->member != (head);					\
>> +		pos = list_entry_rcu(pos->member.next, typeof(*(pos)), member))
>> +
>>  /**
>>   * hlist_del_rcu - deletes entry from hash list without re-initialization
>>   * @n: the element to delete from the hash list.
>> -- 
>> 2.14.0.rc0.dirty
>> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2018-05-01 21:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30  4:31 [PATCH 0/4 V2] Avoid quadratic search when freeing delegations NeilBrown
2018-04-30  4:31 ` [PATCH 3/4] rculist: add list_for_each_entry_from_rcu() NeilBrown
2018-04-30  5:20   ` Josh Triplett
2018-04-30 13:43     ` Paul E. McKenney
2018-04-30 15:14       ` Steven Rostedt
2018-04-30 15:35         ` Paul E. McKenney
2018-05-01  3:11           ` [PATCH 3/4 v2] " NeilBrown
2018-05-01 14:14             ` Paul E. McKenney
2018-05-01 21:34               ` NeilBrown [this message]
2018-04-30  4:31 ` [PATCH 1/4] NFS: slight optimization for walking list for delegations NeilBrown
2018-04-30 15:17   ` Steven Rostedt
2018-05-31  5:23     ` [PATCH 1/4 v2] " NeilBrown
2018-06-04 21:31       ` Steven Rostedt
2018-04-30  4:31 ` [PATCH 2/4] NFS: use cond_resched() when restarting walk of delegation list NeilBrown
2018-04-30  4:31 ` [PATCH 4/4] NFS: Avoid quadratic search when freeing delegations NeilBrown

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=87vac7giv3.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=anna.schumaker@netapp.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=trond.myklebust@primarydata.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).