diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-10-04 01:17:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-04 01:17:54 -0400 |
commit | c7d4426a98a5f6654cd0b4b33d9dab2e77192c18 (patch) | |
tree | 0db2524e6f3f742861765dd6aa696a9271767056 | |
parent | 9a7241c21b06c3a3f8ebcf3e347bd68556369da7 (diff) |
net: introduce DST_NOCACHE flag
While doing stress tests with IP route cache disabled, and multi queue
devices, I noticed a very high contention on one rwlock used in
neighbour code.
When many cpus are trying to send frames (possibly using a high
performance multiqueue device) to the same neighbour, they fight for the
neigh->lock rwlock in order to call neigh_hh_init(), and fight on
hh->hh_refcnt (a pair of atomic_inc/atomic_dec_and_test())
But we dont need to call neigh_hh_init() for dst that are used only
once. It costs four atomic operations at least, on two contended cache
lines, plus the high contention on neigh->lock rwlock.
Introduce a new dst flag, DST_NOCACHE, that is set when dst was not
inserted in route cache.
With the stress test bench, sending 160000000 frames on one neighbour,
results are :
Before patch:
real 2m28.406s
user 0m11.781s
sys 36m17.964s
After patch:
real 1m26.532s
user 0m12.185s
sys 20m3.903s
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/dst.h | 9 | ||||
-rw-r--r-- | net/core/neighbour.c | 4 | ||||
-rw-r--r-- | net/ipv4/route.c | 1 |
3 files changed, 9 insertions, 5 deletions
diff --git a/include/net/dst.h b/include/net/dst.h index aa53fbc34b2b..a217c838ec0d 100644 --- a/include/net/dst.h +++ b/include/net/dst.h | |||
@@ -43,10 +43,11 @@ struct dst_entry { | |||
43 | short error; | 43 | short error; |
44 | short obsolete; | 44 | short obsolete; |
45 | int flags; | 45 | int flags; |
46 | #define DST_HOST 1 | 46 | #define DST_HOST 0x0001 |
47 | #define DST_NOXFRM 2 | 47 | #define DST_NOXFRM 0x0002 |
48 | #define DST_NOPOLICY 4 | 48 | #define DST_NOPOLICY 0x0004 |
49 | #define DST_NOHASH 8 | 49 | #define DST_NOHASH 0x0008 |
50 | #define DST_NOCACHE 0x0010 | ||
50 | unsigned long expires; | 51 | unsigned long expires; |
51 | 52 | ||
52 | unsigned short header_len; /* more space at head required */ | 53 | unsigned short header_len; /* more space at head required */ |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 96b1a749abb4..b142a0d76072 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -1210,7 +1210,9 @@ int neigh_resolve_output(struct sk_buff *skb) | |||
1210 | if (!neigh_event_send(neigh, skb)) { | 1210 | if (!neigh_event_send(neigh, skb)) { |
1211 | int err; | 1211 | int err; |
1212 | struct net_device *dev = neigh->dev; | 1212 | struct net_device *dev = neigh->dev; |
1213 | if (dev->header_ops->cache && !dst->hh) { | 1213 | if (dev->header_ops->cache && |
1214 | !dst->hh && | ||
1215 | !(dst->flags & DST_NOCACHE)) { | ||
1214 | write_lock_bh(&neigh->lock); | 1216 | write_lock_bh(&neigh->lock); |
1215 | if (!dst->hh) | 1217 | if (!dst->hh) |
1216 | neigh_hh_init(neigh, dst, dst->ops->protocol); | 1218 | neigh_hh_init(neigh, dst, dst->ops->protocol); |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index a61acea975f1..c3cb8bd23638 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1107,6 +1107,7 @@ restart: | |||
1107 | * on the route gc list. | 1107 | * on the route gc list. |
1108 | */ | 1108 | */ |
1109 | 1109 | ||
1110 | rt->dst.flags |= DST_NOCACHE; | ||
1110 | if (rt->rt_type == RTN_UNICAST || rt->fl.iif == 0) { | 1111 | if (rt->rt_type == RTN_UNICAST || rt->fl.iif == 0) { |
1111 | int err = arp_bind_neighbour(&rt->dst); | 1112 | int err = arp_bind_neighbour(&rt->dst); |
1112 | if (err) { | 1113 | if (err) { |