aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
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
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')
-rw-r--r--include/net/netns/packet.h4
-rw-r--r--include/net/sock.h10
2 files changed, 12 insertions, 2 deletions
diff --git a/include/net/netns/packet.h b/include/net/netns/packet.h
index 637daf698884..cb4e894c0f8d 100644
--- a/include/net/netns/packet.h
+++ b/include/net/netns/packet.h
@@ -4,11 +4,11 @@
4#ifndef __NETNS_PACKET_H__ 4#ifndef __NETNS_PACKET_H__
5#define __NETNS_PACKET_H__ 5#define __NETNS_PACKET_H__
6 6
7#include <linux/list.h> 7#include <linux/rculist.h>
8#include <linux/spinlock.h> 8#include <linux/spinlock.h>
9 9
10struct netns_packet { 10struct netns_packet {
11 rwlock_t sklist_lock; 11 spinlock_t sklist_lock;
12 struct hlist_head sklist; 12 struct hlist_head sklist;
13}; 13};
14 14
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) \