aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/inetpeer.h
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-06-09 02:31:27 -0400
committerDavid S. Miller <davem@davemloft.net>2011-06-09 02:31:27 -0400
commit2b77bdde97ae8241dcc23110a4e837acfbc83438 (patch)
treea9af81a3ed7b6ee04e7c1b38c3bc77ec295562c8 /include/net/inetpeer.h
parent1a7a10325d370e2cbed0c5bb7313904545f6dac8 (diff)
inetpeer: lower false sharing effect
Profiles show false sharing in addr_compare() because refcnt/dtime changes dirty the first inet_peer cache line, where are lying the keys used at lookup time. If many cpus are calling inet_getpeer() and inet_putpeer(), or need frag ids, addr_compare() is in 2nd position in "perf top". Before patch, my udpflood bench (16 threads) on my 2x4x2 machine : 5784.00 9.7% csum_partial_copy_generic [kernel] 3356.00 5.6% addr_compare [kernel] 2638.00 4.4% fib_table_lookup [kernel] 2625.00 4.4% ip_fragment [kernel] 1934.00 3.2% neigh_lookup [kernel] 1617.00 2.7% udp_sendmsg [kernel] 1608.00 2.7% __ip_route_output_key [kernel] 1480.00 2.5% __ip_append_data [kernel] 1396.00 2.3% kfree [kernel] 1195.00 2.0% kmem_cache_free [kernel] 1157.00 1.9% inet_getpeer [kernel] 1121.00 1.9% neigh_resolve_output [kernel] 1012.00 1.7% dev_queue_xmit [kernel] # time ./udpflood.sh real 0m44.511s user 0m20.020s sys 11m22.780s # time ./udpflood.sh real 0m44.099s user 0m20.140s sys 11m15.870s After patch, no more addr_compare() in profiles : 4171.00 10.7% csum_partial_copy_generic [kernel] 1787.00 4.6% fib_table_lookup [kernel] 1756.00 4.5% ip_fragment [kernel] 1234.00 3.2% udp_sendmsg [kernel] 1191.00 3.0% neigh_lookup [kernel] 1118.00 2.9% __ip_append_data [kernel] 1022.00 2.6% kfree [kernel] 993.00 2.5% __ip_route_output_key [kernel] 841.00 2.2% neigh_resolve_output [kernel] 816.00 2.1% kmem_cache_free [kernel] 658.00 1.7% ia32_sysenter_target [kernel] 632.00 1.6% kmem_cache_alloc_node [kernel] # time ./udpflood.sh real 0m41.587s user 0m19.190s sys 10m36.370s # time ./udpflood.sh real 0m41.486s user 0m19.290s sys 10m33.650s Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/inetpeer.h')
-rw-r--r--include/net/inetpeer.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index 1f0966f9176..39d123081e7 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -32,12 +32,17 @@ struct inet_peer {
32 struct inet_peer __rcu *avl_left, *avl_right; 32 struct inet_peer __rcu *avl_left, *avl_right;
33 struct inetpeer_addr daddr; 33 struct inetpeer_addr daddr;
34 __u32 avl_height; 34 __u32 avl_height;
35 __u32 dtime; /* the time of last use of not 35
36 * referenced entries */ 36 u32 metrics[RTAX_MAX];
37 atomic_t refcnt; 37 u32 rate_tokens; /* rate limiting for ICMP */
38 unsigned long rate_last;
39 unsigned long pmtu_expires;
40 u32 pmtu_orig;
41 u32 pmtu_learned;
42 struct inetpeer_addr_base redirect_learned;
38 /* 43 /*
39 * Once inet_peer is queued for deletion (refcnt == -1), following fields 44 * Once inet_peer is queued for deletion (refcnt == -1), following fields
40 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp, metrics 45 * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp
41 * We can share memory with rcu_head to help keep inet_peer small. 46 * We can share memory with rcu_head to help keep inet_peer small.
42 */ 47 */
43 union { 48 union {
@@ -46,17 +51,14 @@ struct inet_peer {
46 atomic_t ip_id_count; /* IP ID for the next packet */ 51 atomic_t ip_id_count; /* IP ID for the next packet */
47 __u32 tcp_ts; 52 __u32 tcp_ts;
48 __u32 tcp_ts_stamp; 53 __u32 tcp_ts_stamp;
49 u32 metrics[RTAX_MAX];
50 u32 rate_tokens; /* rate limiting for ICMP */
51 unsigned long rate_last;
52 unsigned long pmtu_expires;
53 u32 pmtu_orig;
54 u32 pmtu_learned;
55 struct inetpeer_addr_base redirect_learned;
56 }; 54 };
57 struct rcu_head rcu; 55 struct rcu_head rcu;
58 struct inet_peer *gc_next; 56 struct inet_peer *gc_next;
59 }; 57 };
58
59 /* following fields might be frequently dirtied */
60 __u32 dtime; /* the time of last use of not referenced entries */
61 atomic_t refcnt;
60}; 62};
61 63
62void inet_initpeers(void) __init; 64void inet_initpeers(void) __init;