Re: [PATCH] udp: Introduce special NULL pointers for hlist termination
From: Peter Zijlstra <hidden>
Date: 2008-10-30 16:01:19
On Thu, 2008-10-30 at 16:40 +0100, Eric Dumazet wrote:
[PATCH] udp: Introduce special NULL pointers for hlist termination In order to safely detect changes in chains, we would like to have different 'NULL' pointers. Each chain in hash table is terminated by an unique 'NULL' value, so that the lockless readers can detect their lookups evaded from their starting chain. We introduce a new type of hlist implementation, named hlist_nulls, were we use the least significant bit of the 'ptr' to tell if its a "NULL" value or a pointer to an object. We expect to use this new hlist variant for TCP as well. For UDP/UDP-Lite hash table, we use 128 different "NULL" values, (UDP_HTABLE_SIZE=128) Using hlist_nulls saves memory barriers (a read barrier to fetch 'next' pointers *before* checking key values) we added in commit 96631ed16c514cf8b28fab991a076985ce378c26 (udp: introduce sk_for_each_rcu_safenext()) This also saves a write memory barrier in udp_lib_get_port(), between sk->sk_hash update and sk->next update) Signed-off-by: Eric Dumazet <redacted> --- include/linux/list_nulls.h | 97 ++++++++++++++++++++++++++++++++ include/linux/rculist.h | 17 ----- include/linux/rculist_nulls.h | 55 ++++++++++++++++++ include/net/sock.h | 50 ++++++++++++---- include/net/udp.h | 2 net/ipv4/udp.c | 40 ++++++------- net/ipv6/udp.c | 22 ++++--- 7 files changed, 228 insertions(+), 55 deletions(-)
If we're going to do this, It'd be good to have the list_nulls stuff in their own patch, as clearly they are not UDP specific. Also, I think it would be very good to have some extensive comments in the list_nulls files describing their use in clear and concise language, because the above changelog doesn't even begin to explain things for those not following this thread.