Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 351983
b: refs/heads/master
c: 6d7b857
h: refs/heads/master
i:
  351981: a41b004
  351979: cbccc36
  351975: 0c93740
  351967: 8f9d9d6
v: v3
  • Loading branch information
Jesper Dangaard Brouer authored and David S. Miller committed Jan 29, 2013
1 parent 7ddf164 commit 0832a97
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d433673e5f9180e05a770c4b2ab18c08ad51cc21
refs/heads/master: 6d7b857d541ecd1d9bd997c97242d4ef94b19de2
26 changes: 18 additions & 8 deletions trunk/include/net/inet_frag.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#ifndef __NET_FRAG_H__
#define __NET_FRAG_H__

#include <linux/percpu_counter.h>

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;
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions trunk/net/ipv4/inet_fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 0832a97

Please sign in to comment.