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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 12 Dec 2012 10:32:31 +0100
From:	Roger Pau Monné <roger.pau@...rix.com>
To:	Huang Ying <ying.huang@...el.com>
CC:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Konrad Rzeszutek Wilk <konrad@...nel.org>
Subject: Re: [PATCH v3] llist: add a safe version of llist_for_each_entry

On 12/12/12 01:37, Huang Ying wrote:
> On Tue, 2012-12-11 at 12:25 +0100, Roger Pau Monne wrote:
>> Signed-off-by: Roger Pau Monné <roger.pau@...rix.com>
>> Cc: Huang Ying <ying.huang@...el.com>
>> Cc: Konrad Rzeszutek Wilk <konrad@...nel.org>
>> ---
>> Changes since v2:
>>  * Allow to pass a NULL node as the first entry of deleted list
>>    entries.
>> ---
>>  include/linux/llist.h |   27 +++++++++++++++++++++++++++
>>  1 files changed, 27 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/linux/llist.h b/include/linux/llist.h
>> index a5199f6..4e0aec1 100644
>> --- a/include/linux/llist.h
>> +++ b/include/linux/llist.h
>> @@ -125,6 +125,33 @@ static inline void init_llist_head(struct llist_head *list)
>>  	     (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member))
>>  
>>  /**
>> + * llist_for_each_entry_safe - safely iterate over some deleted entries of
>> + *                             lock-less list of given type
>> + * @pos:	the type * to use as a loop cursor.
>> + * @n:		the &struct llist_node to use as a temporary loop cursor
> 
> In list_for_each_entry_safe, n is type *, why not follow that?

Thanks for the review, yes I just saw it, I was using llist_node because
I didn't need a type *, but I agree that it's best to stick with
list_for_each_entry_safe interface. Will send v4....

> 
> Best Regards,
> Huang Ying
> 
>> + * @node:	the fist entry of deleted list entries.
>> + * @member:	the name of the llist_node with the struct.
>> + *
>> + * In general, some entries of the lock-less list can be traversed
>> + * safely only after being removed from list, so start with an entry
>> + * instead of list head.
>> + *
>> + * If being used on entries deleted from lock-less list directly, the
>> + * traverse order is from the newest to the oldest added entry.  If
>> + * you want to traverse from the oldest to the newest, you must
>> + * reverse the order by yourself before traversing.
>> + *
>> + * n is used to store a reference to the next item llist_node, so
>> + * pos can be freed while iterating.
>> + */
>> +#define llist_for_each_entry_safe(pos, n, node, member)		\
>> +	for ((pos) = llist_entry((node), typeof(*(pos)), member),	\
>> +	     (n) = (&(pos)->member != NULL) ? (pos)->member.next : NULL;\
>> +	     &(pos)->member != NULL;					\
>> +	     (pos) = llist_entry(n, typeof(*(pos)), member),		\
>> +	     (n) = (&(pos)->member != NULL) ? (pos)->member.next : NULL)
>> +
>> +/**
>>   * llist_empty - tests whether a lock-less list is empty
>>   * @head:	the list to test
>>   *
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ