All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cody P Schafer <cody@linux.vnet.ibm.com>
To: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux MM <linux-mm@kvack.org>,
	David Woodhouse <David.Woodhouse@intel.com>,
	Rik van Riel <riel@redhat.com>,
	Michel Lespinasse <walken@google.com>
Subject: Re: [PATCH 2/5] rbtree: add rbtree_postorder_for_each_entry_safe() helper
Date: Mon, 29 Jul 2013 10:41:07 -0700	[thread overview]
Message-ID: <51F6A933.4050301@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130729150624.GB4381@variantweb.net>

On 07/29/2013 08:06 AM, Seth Jennings wrote:
> On Fri, Jul 26, 2013 at 02:13:40PM -0700, Cody P Schafer wrote:
>> Because deletion (of the entire tree) is a relatively common use of the
>> rbtree_postorder iteration, and because doing it safely means fiddling
>> with temporary storage, provide a helper to simplify postorder rbtree
>> iteration.
>>
>> Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
>> ---
>>   include/linux/rbtree.h | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
>> index 2879e96..64ab98b 100644
>> --- a/include/linux/rbtree.h
>> +++ b/include/linux/rbtree.h
>> @@ -85,4 +85,21 @@ static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
>>   	*rb_link = node;
>>   }
>>
>> +/**
>> + * rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of
>> + * given type safe against removal of rb_node entry
>> + *
>> + * @pos:	the 'type *' to use as a loop cursor.
>> + * @n:		another 'type *' to use as temporary storage
>> + * @root:	'rb_root *' of the rbtree.
>> + * @field:	the name of the rb_node field within 'type'.
>> + */
>> +#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \
>> +	for (pos = rb_entry(rb_first_postorder(root), typeof(*pos), field),\
>> +	      n = rb_entry(rb_next_postorder(&pos->field), \
>> +		      typeof(*pos), field); \
>> +	     &pos->field; \
>> +	     pos = n, \
>> +	      n = rb_entry(rb_next_postorder(&pos->field), typeof(*pos), field))
>
> One too many spaces.  Also mix of tabs and spaces is weird, but
> checkpatch doesn't complain so...
>
> Seth

The extra space is to set off ';' vs ',' in the macro. And I did that 
instead of a tab to avoid wrapping. I've adjusted them (in the next 
version) to use the same style as list.h's list_for_each*() macros. 
Which results in more wrapping :( .

>
>> +
>>   #endif	/* _LINUX_RBTREE_H */
>> --
>> 1.8.3.4
>>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Cody P Schafer <cody@linux.vnet.ibm.com>
To: Seth Jennings <sjenning@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux MM <linux-mm@kvack.org>,
	David Woodhouse <David.Woodhouse@intel.com>,
	Rik van Riel <riel@redhat.com>,
	Michel Lespinasse <walken@google.com>
Subject: Re: [PATCH 2/5] rbtree: add rbtree_postorder_for_each_entry_safe() helper
Date: Mon, 29 Jul 2013 10:41:07 -0700	[thread overview]
Message-ID: <51F6A933.4050301@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130729150624.GB4381@variantweb.net>

On 07/29/2013 08:06 AM, Seth Jennings wrote:
> On Fri, Jul 26, 2013 at 02:13:40PM -0700, Cody P Schafer wrote:
>> Because deletion (of the entire tree) is a relatively common use of the
>> rbtree_postorder iteration, and because doing it safely means fiddling
>> with temporary storage, provide a helper to simplify postorder rbtree
>> iteration.
>>
>> Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
>> ---
>>   include/linux/rbtree.h | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
>> index 2879e96..64ab98b 100644
>> --- a/include/linux/rbtree.h
>> +++ b/include/linux/rbtree.h
>> @@ -85,4 +85,21 @@ static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
>>   	*rb_link = node;
>>   }
>>
>> +/**
>> + * rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of
>> + * given type safe against removal of rb_node entry
>> + *
>> + * @pos:	the 'type *' to use as a loop cursor.
>> + * @n:		another 'type *' to use as temporary storage
>> + * @root:	'rb_root *' of the rbtree.
>> + * @field:	the name of the rb_node field within 'type'.
>> + */
>> +#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \
>> +	for (pos = rb_entry(rb_first_postorder(root), typeof(*pos), field),\
>> +	      n = rb_entry(rb_next_postorder(&pos->field), \
>> +		      typeof(*pos), field); \
>> +	     &pos->field; \
>> +	     pos = n, \
>> +	      n = rb_entry(rb_next_postorder(&pos->field), typeof(*pos), field))
>
> One too many spaces.  Also mix of tabs and spaces is weird, but
> checkpatch doesn't complain so...
>
> Seth

The extra space is to set off ';' vs ',' in the macro. And I did that 
instead of a tab to avoid wrapping. I've adjusted them (in the next 
version) to use the same style as list.h's list_for_each*() macros. 
Which results in more wrapping :( .

>
>> +
>>   #endif	/* _LINUX_RBTREE_H */
>> --
>> 1.8.3.4
>>


  reply	other threads:[~2013-07-29 17:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 21:13 [PATCH 0/5] Add rbtree postorder iteration functions, runtime tests, and update zswap to use Cody P Schafer
2013-07-26 21:13 ` Cody P Schafer
2013-07-26 21:13 ` [PATCH 1/5] rbtree: add postorder iteration functions Cody P Schafer
2013-07-26 21:13   ` Cody P Schafer
2013-07-29 15:01   ` Seth Jennings
2013-07-29 15:01     ` Seth Jennings
2013-07-29 17:32     ` Cody P Schafer
2013-07-29 17:32       ` Cody P Schafer
2013-07-26 21:13 ` [PATCH 2/5] rbtree: add rbtree_postorder_for_each_entry_safe() helper Cody P Schafer
2013-07-26 21:13   ` Cody P Schafer
2013-07-29 15:06   ` Seth Jennings
2013-07-29 15:06     ` Seth Jennings
2013-07-29 17:41     ` Cody P Schafer [this message]
2013-07-29 17:41       ` Cody P Schafer
2013-07-26 21:13 ` [PATCH 3/5] rbtree_test: add test for postorder iteration Cody P Schafer
2013-07-26 21:13   ` Cody P Schafer
2013-07-26 21:13 ` [PATCH 4/5] rbtree: allow tests to run as builtin Cody P Schafer
2013-07-26 21:13   ` Cody P Schafer
2013-07-26 21:13 ` [PATCH 5/5] mm/zswap: use postorder iteration when destroying rbtree Cody P Schafer
2013-07-26 21:13   ` Cody P Schafer
2013-07-29 15:08   ` Seth Jennings
2013-07-29 15:08     ` Seth Jennings
2013-07-29 15:11 ` [PATCH 0/5] Add rbtree postorder iteration functions, runtime tests, and update zswap to use Seth Jennings
2013-07-29 15:11   ` Seth Jennings

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=51F6A933.4050301@linux.vnet.ibm.com \
    --to=cody@linux.vnet.ibm.com \
    --cc=David.Woodhouse@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=riel@redhat.com \
    --cc=sjenning@linux.vnet.ibm.com \
    --cc=walken@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.