From 0832a97ee53bd79afa0f93ab06cb6e02816899d7 Mon Sep 17 00:00:00 2001 From: Jesper Dangaard Brouer Date: Mon, 28 Jan 2013 23:45:33 +0000 Subject: [PATCH] --- yaml --- r: 351983 b: refs/heads/master c: 6d7b857d541ecd1d9bd997c97242d4ef94b19de2 h: refs/heads/master i: 351981: a41b004a4861bb45cc318abc985494e12bae8e11 351979: cbccc362a7f7333a814c0df4bb0925cc211c85af 351975: 0c93740f4b645834b0955de2285859783c00986a 351967: 8f9d9d66b6069f60a0f3ea79317b070a53dfe24a v: v3 --- [refs] | 2 +- trunk/include/net/inet_frag.h | 26 ++++++++++++++++++-------- trunk/net/ipv4/inet_fragment.c | 2 ++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index 2bf65a9bf4c3..cb577006ea6c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d433673e5f9180e05a770c4b2ab18c08ad51cc21 +refs/heads/master: 6d7b857d541ecd1d9bd997c97242d4ef94b19de2 diff --git a/trunk/include/net/inet_frag.h b/trunk/include/net/inet_frag.h index f2fabc2a79de..e0eec7450f15 100644 --- a/trunk/include/net/inet_frag.h +++ b/trunk/include/net/inet_frag.h @@ -1,14 +1,17 @@ #ifndef __NET_FRAG_H__ #define __NET_FRAG_H__ +#include + struct netns_frags { int nqueues; struct list_head lru_list; - /* Its important for performance to keep lru_list and mem on - * separate cachelines + /* The percpu_counter "mem" need to be cacheline aligned. + * mem.count must not share cacheline with other writers */ - atomic_t mem ____cacheline_aligned_in_smp; + struct percpu_counter mem ____cacheline_aligned_in_smp; + /* sysctls */ int timeout; int high_thresh; @@ -81,29 +84,36 @@ static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f /* Memory Tracking Functions. */ +/* The default percpu_counter batch size is not big enough to scale to + * fragmentation mem acct sizes. + * The mem size of a 64K fragment is approx: + * (44 fragments * 2944 truesize) + frag_queue struct(200) = 129736 bytes + */ +static unsigned int frag_percpu_counter_batch = 130000; + static inline int frag_mem_limit(struct netns_frags *nf) { - return atomic_read(&nf->mem); + return percpu_counter_read(&nf->mem); } static inline void sub_frag_mem_limit(struct inet_frag_queue *q, int i) { - atomic_sub(i, &q->net->mem); + __percpu_counter_add(&q->net->mem, -i, frag_percpu_counter_batch); } static inline void add_frag_mem_limit(struct inet_frag_queue *q, int i) { - atomic_add(i, &q->net->mem); + __percpu_counter_add(&q->net->mem, i, frag_percpu_counter_batch); } static inline void init_frag_mem_limit(struct netns_frags *nf) { - atomic_set(&nf->mem, 0); + percpu_counter_init(&nf->mem, 0); } static inline int sum_frag_mem_limit(struct netns_frags *nf) { - return atomic_read(&nf->mem); + return percpu_counter_sum_positive(&nf->mem); } #endif diff --git a/trunk/net/ipv4/inet_fragment.c b/trunk/net/ipv4/inet_fragment.c index e348c849c5a3..b82520565098 100644 --- a/trunk/net/ipv4/inet_fragment.c +++ b/trunk/net/ipv4/inet_fragment.c @@ -91,6 +91,8 @@ void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f) local_bh_disable(); inet_frag_evictor(nf, f, true); local_bh_enable(); + + percpu_counter_destroy(&nf->mem); } EXPORT_SYMBOL(inet_frags_exit_net);