aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2010-02-22 02:57:18 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-22 18:45:56 -0500
commit808f5114a9206fee855117d416440e1071ab375c (patch)
treecec3f04220909b77c0880029b63862553ad5161c /include/net/sock.h
parent1cc523271ef0b6305c565a143e3d48f6fff826dd (diff)
packet: convert socket list to RCU (v3)
Convert AF_PACKET to use RCU, eliminating one more reader/writer lock. There is no need for a real sk_del_node_init_rcu(), because sk_del_node_init is doing the equivalent thing to hlst_del_init_rcu already; but added some comments to try and make that obvious. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 580d51fa28e9..6cb1676e409a 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -381,6 +381,7 @@ static __inline__ void __sk_del_node(struct sock *sk)
381 __hlist_del(&sk->sk_node); 381 __hlist_del(&sk->sk_node);
382} 382}
383 383
384/* NB: equivalent to hlist_del_init_rcu */
384static __inline__ int __sk_del_node_init(struct sock *sk) 385static __inline__ int __sk_del_node_init(struct sock *sk)
385{ 386{
386 if (sk_hashed(sk)) { 387 if (sk_hashed(sk)) {
@@ -421,6 +422,7 @@ static __inline__ int sk_del_node_init(struct sock *sk)
421 } 422 }
422 return rc; 423 return rc;
423} 424}
425#define sk_del_node_init_rcu(sk) sk_del_node_init(sk)
424 426
425static __inline__ int __sk_nulls_del_node_init_rcu(struct sock *sk) 427static __inline__ int __sk_nulls_del_node_init_rcu(struct sock *sk)
426{ 428{
@@ -454,6 +456,12 @@ static __inline__ void sk_add_node(struct sock *sk, struct hlist_head *list)
454 __sk_add_node(sk, list); 456 __sk_add_node(sk, list);
455} 457}
456 458
459static __inline__ void sk_add_node_rcu(struct sock *sk, struct hlist_head *list)
460{
461 sock_hold(sk);
462 hlist_add_head_rcu(&sk->sk_node, list);
463}
464
457static __inline__ void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list) 465static __inline__ void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list)
458{ 466{
459 hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list); 467 hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list);
@@ -478,6 +486,8 @@ static __inline__ void sk_add_bind_node(struct sock *sk,
478 486
479#define sk_for_each(__sk, node, list) \ 487#define sk_for_each(__sk, node, list) \
480 hlist_for_each_entry(__sk, node, list, sk_node) 488 hlist_for_each_entry(__sk, node, list, sk_node)
489#define sk_for_each_rcu(__sk, node, list) \
490 hlist_for_each_entry_rcu(__sk, node, list, sk_node)
481#define sk_nulls_for_each(__sk, node, list) \ 491#define sk_nulls_for_each(__sk, node, list) \
482 hlist_nulls_for_each_entry(__sk, node, list, sk_nulls_node) 492 hlist_nulls_for_each_entry(__sk, node, list, sk_nulls_node)
483#define sk_nulls_for_each_rcu(__sk, node, list) \ 493#define sk_nulls_for_each_rcu(__sk, node, list) \