aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2012-07-31 01:45:30 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-31 17:41:39 -0400
commitd26b3a7c4b3b26319f18bb645de93eba8f4bdcd5 (patch)
treeca86c03450fafdc89dac98ce403b1906fcaa025d /net/ipv4/route.c
parent54764bb647b2e847c512acf8d443df965da35000 (diff)
ipv4: percpu nh_rth_output cache
Input path is mostly run under RCU and doesnt touch dst refcnt But output path on forwarding or UDP workloads hits badly dst refcount, and we have lot of false sharing, for example in ipv4_mtu() when reading rt->rt_pmtu Using a percpu cache for nh_rth_output gives a nice performance increase at a small cost. 24 udpflood test on my 24 cpu machine (dummy0 output device) (each process sends 1.000.000 udp frames, 24 processes are started) before : 5.24 s after : 2.06 s For reference, time on linux-3.5 : 6.60 s Signed-off-by: Eric Dumazet <edumazet@google.com> Tested-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 2bd107477469..4f6276ce0af3 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1206,11 +1206,15 @@ static inline void rt_free(struct rtable *rt)
1206 1206
1207static void rt_cache_route(struct fib_nh *nh, struct rtable *rt) 1207static void rt_cache_route(struct fib_nh *nh, struct rtable *rt)
1208{ 1208{
1209 struct rtable *orig, *prev, **p = (struct rtable **)&nh->nh_rth_output; 1209 struct rtable *orig, *prev, **p;
1210 1210
1211 if (rt_is_input_route(rt)) 1211 if (rt_is_input_route(rt)) {
1212 p = (struct rtable **)&nh->nh_rth_input; 1212 p = (struct rtable **)&nh->nh_rth_input;
1213 1213 } else {
1214 if (!nh->nh_pcpu_rth_output)
1215 goto nocache;
1216 p = (struct rtable **)__this_cpu_ptr(nh->nh_pcpu_rth_output);
1217 }
1214 orig = *p; 1218 orig = *p;
1215 1219
1216 prev = cmpxchg(p, orig, rt); 1220 prev = cmpxchg(p, orig, rt);
@@ -1223,6 +1227,7 @@ static void rt_cache_route(struct fib_nh *nh, struct rtable *rt)
1223 * unsuccessful at storing this route into the cache 1227 * unsuccessful at storing this route into the cache
1224 * we really need to set it. 1228 * we really need to set it.
1225 */ 1229 */
1230nocache:
1226 rt->dst.flags |= DST_NOCACHE; 1231 rt->dst.flags |= DST_NOCACHE;
1227 } 1232 }
1228} 1233}
@@ -1749,8 +1754,11 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1749 fnhe = NULL; 1754 fnhe = NULL;
1750 if (fi) { 1755 if (fi) {
1751 fnhe = find_exception(&FIB_RES_NH(*res), fl4->daddr); 1756 fnhe = find_exception(&FIB_RES_NH(*res), fl4->daddr);
1752 if (!fnhe) { 1757 if (!fnhe && FIB_RES_NH(*res).nh_pcpu_rth_output) {
1753 rth = rcu_dereference(FIB_RES_NH(*res).nh_rth_output); 1758 struct rtable __rcu **prth;
1759
1760 prth = __this_cpu_ptr(FIB_RES_NH(*res).nh_pcpu_rth_output);
1761 rth = rcu_dereference(*prth);
1754 if (rt_cache_valid(rth)) { 1762 if (rt_cache_valid(rth)) {
1755 dst_hold(&rth->dst); 1763 dst_hold(&rth->dst);
1756 return rth; 1764 return rth;