Re: [PATCH 1/2] list: add list_del_each_entry

2013-07-15 Thread Jörn Engel
On Fri, 5 July 2013 23:38:01 +0100, Filipe David Manana wrote: +#define list_del_each_entry(pos, head, member) \ + while (list_empty(head) (pos = list_first_entry((head), \ + typeof(*pos), member), list_del((head)-next), 1)) + Shouldn't it be while

Re: [PATCH 0/2] introduce list_for_each_entry_del

2013-07-05 Thread Jörn Engel
On Mon, 3 June 2013 13:28:03 -0400, Joern Engel wrote: A purely janitorial patchset. A fairly common pattern is to take a list, remove every object from it and do something with this object - usually kfree() some variant. A stupid grep identified roughly 300 instances, with many more

[PATCH 2/2] btrfs: use list_del_each_entry

2013-07-05 Thread Jörn Engel
Signed-off-by: Joern Engel jo...@logfs.org --- fs/btrfs/backref.c | 15 +++ fs/btrfs/compression.c |4 +--- fs/btrfs/disk-io.c |6 +- fs/btrfs/extent-tree.c | 17 +++-- fs/btrfs/extent_io.c|8 ++-- fs/btrfs/inode.c| 16

[PATCH 1/2] list: add list_del_each_entry

2013-07-05 Thread Jörn Engel
I have seen a lot of boilerplate code that either follows the pattern of while (!list_empty(head)) { pos = list_entry(head-next, struct foo, list); list_del(pos-list); ... } or some variant thereof. With this patch in, people can use

Re: [PATCH 1/2] list: add list_for_each_entry_del

2013-06-07 Thread Jörn Engel
On Thu, 6 June 2013 22:49:22 +0300, Andy Shevchenko wrote: On Thu, Jun 6, 2013 at 9:12 PM, Jörn Engel jo...@logfs.org wrote: On Thu, 6 June 2013 22:32:55 +0300, Andy Shevchenko wrote: On Mon, Jun 3, 2013 at 8:28 PM, Joern Engel jo...@logfs.org wrote: I have seen a lot of boilerplate code

Re: [PATCH 1/2] list: add list_for_each_entry_del

2013-06-07 Thread Jörn Engel
On Fri, 7 June 2013 21:30:16 +0300, Andy Shevchenko wrote: spin_lock list_for_each_entry_safe list_del spin_unlock Who is doing such thing? Replace list_for_each_entry_safe with 'while (!list_empty(...))' and just grep. My patch is about 'while (!list_empty(...))',

Re: [PATCH 1/2] list: add list_for_each_entry_del

2013-06-06 Thread Jörn Engel
On Thu, 6 June 2013 22:32:55 +0300, Andy Shevchenko wrote: On Mon, Jun 3, 2013 at 8:28 PM, Joern Engel jo...@logfs.org wrote: I have seen a lot of boilerplate code that either follows the pattern of while (!list_empty(head)) { pos = list_entry(head-next, struct foo,

Re: [PATCH 0/2] introduce list_for_each_entry_del

2013-06-04 Thread Jörn Engel
On Tue, 4 June 2013 22:09:13 +0200, Arne Jansen wrote: On 06/04/13 16:53, Chris Mason wrote: Quoting Christoph Hellwig (2013-06-04 10:48:56) On Mon, Jun 03, 2013 at 03:55:55PM -0400, J??rn Engel wrote: Actually, when I compare the two invocations, I prefer the list_for_each_entry_del()

[PATCH 1/2] list: add while_list_drain_entry

2013-06-04 Thread Jörn Engel
I have seen a lot of boilerplate code that either follows the pattern of while (!list_empty(head)) { pos = list_entry(head-next, struct foo, list); list_del(pos-list); ... } or some variant thereof. With this patch in, people can use

[PATCH 2/2] btrfs: use while_list_drain_entry

2013-06-04 Thread Jörn Engel
Signed-off-by: Joern Engel jo...@logfs.org --- fs/btrfs/backref.c | 15 +++ fs/btrfs/compression.c |4 +--- fs/btrfs/disk-io.c |6 +- fs/btrfs/extent-tree.c | 17 +++-- fs/btrfs/extent_io.c|8 ++-- fs/btrfs/inode.c| 16

Re: [PATCH 0/2] introduce list_for_each_entry_del

2013-06-04 Thread Jörn Engel
On Tue, 4 June 2013 14:44:35 -0400, Jörn Engel wrote: Or while_list_drain? Not sure if the silence is approval or lack of interest, but a new set of patches is posted. By playing around with the implementation a bit, I have actually found a variant that makes the object code shrink. Not one

Re: [PATCH 0/2] introduce list_for_each_entry_del

2013-06-03 Thread Jörn Engel
On Mon, 3 June 2013 13:28:03 -0400, Joern Engel wrote: Drawback is that object size is growing. I think an ideal compiler should be able to optimize all the overhead away, but 4.7 just isn't there yet. Or maybe I just messed up - patches are only compile-tested after all. Comments/ideas

Re: [PATCH 0/2] introduce list_for_each_entry_del

2013-06-03 Thread Jörn Engel
On Mon, 3 June 2013 15:36:47 -0400, Jörn Engel wrote: On Mon, 3 June 2013 13:49:30 -0700, Christoph Hellwig wrote: I can't say I like the structure. A list_pop that removes and entry from the head or returns NULL if the list is empty would lead to nice while loops that are obviously