Skip to content

net: RCU lookups for UDP, DCCP and TCP protocol

Eric Dumazet lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 25 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3rcu: Introduce hlist_nulls variant of hlistinclude/linux/list_nulls.h include/linux/rculist_nulls.h+204 -014 replies
2/3udp: Use hlist_nulls in UDP RCU codeinclude/linux/rculist.h include/net/sock.h include/net/udp.h +2 more+83 -662 replies
3/3net: Convert TCP & DCCP hash tables to use RCU / hlist_nullsinclude/net/inet_hashtables.h include/net/inet_timewait_sock.h net/core/sock.c +10 more+151 -8413 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchPeter ZijlstraPaul E. McKenney
1/3A-b A-b R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] net: RCU lookups for UDP, DCCP and TCP protocol

Hi all

Here is a serie of three patches (based on net-next-2.6), to continue work with RCU on UDP/TCP/DCCP stacks

Many thanks for all usefull reviews and comments, especially from Paul and Corey.

1) Introduce hlist_nulls variant of hlist

hlist uses NULL value to finish a chain.
hlist_nulls variant use the low order bit set to 1 to signal an end marker. This allows to store many different end markers, so that some RCU lockless algos (used in TCP/UDP stack for example) can save some memory barriers in fast paths.

2) Use hlist_nulls in UDP RCU code

This is a straightforward patch, using hlist_nulls infrastructure. RCU-ification already done on UDP two weeks ago, so hlist_nulls permits us to avoid some memory barriers, both at lookup time and delete time. Patch is large because it adds new macros to include/net/sock.h. These macros will be used by TCP & DCCP too.

3) Convert TCP & DCCP hash tables to use RCU & hlist_nulls

RCU was added to UDP lookups, using a fast infrastructure :
- sockets kmem_cache use SLAB_DESTROY_BY_RCU and dont pay the price of call_rcu() at freeing time.
- hlist_nulls permits to use few memory barriers.

This patch uses same infrastructure for TCP/DCCP established and timewait sockets.

Thanks to SLAB_DESTROY_BY_RCU, no slowdown for applications using short lived TCP connections. A followup patch, converting rwlocks to spinlocks will even speedup this case.

__inet_lookup_established() is pretty fast now we dont have to dirty a contended cache line (read_lock/read_unlock)

Only established and timewait hashtable are converted to RCU
(bind table and listen table are still using traditional locking)