From: Luis R. Rodriguez Date: Tue, 1 Apr 2014 21:32:38 +0000 (+0000) Subject: backports: backport frag helper functions for mem limit tracking X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=357791393648fc97e66aa8dd914f43cc7c908864;p=openwrt%2Fstaging%2Fblogic.git backports: backport frag helper functions for mem limit tracking Jesper added frag helper functions through commit d433673e5f added on. This is a straight forward backport using the LINUX_BACKPORT() namespace. mcgrof@ergon ~/linux-next (git::master)$ git describe --contains d433673e5f v3.9-rc1~139^2~232^2~2 commit d433673e5f9180e05a770c4b2ab18c08ad51cc21 Author: Jesper Dangaard Brouer Date: Mon Jan 28 23:45:12 2013 +0000 net: frag helper functions for mem limit tracking This change is primarily a preparation to ease the extension of memory limit tracking. The change does reduce the number atomic operation, during freeing of a frag queue. This does introduce a some performance improvement, as these atomic operations are at the core of the performance problems seen on NUMA systems. Signed-off-by: Jesper Dangaard Brouer Signed-off-by: David S. Miller Cc: Jesper Dangaard Brouer Signed-off-by: Luis R. Rodriguez --- diff --git a/backport/backport-include/net/inet_frag.h b/backport/backport-include/net/inet_frag.h new file mode 100644 index 000000000000..167792bfdd59 --- /dev/null +++ b/backport/backport-include/net/inet_frag.h @@ -0,0 +1,39 @@ +#ifndef __BACKPORT__NET_FRAG_H__ +#define __BACKPORT__NET_FRAG_H__ +#include_next +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) +/* Memory Tracking Functions. */ +#define frag_mem_limit LINUX_BACKPORT(frag_mem_limit) +static inline int frag_mem_limit(struct netns_frags *nf) +{ + return atomic_read(&nf->mem); +} + +#define sub_frag_mem_limit LINUX_BACKPORT(sub_frag_mem_limit) +static inline void sub_frag_mem_limit(struct inet_frag_queue *q, int i) +{ + atomic_sub(i, &q->net->mem); +} + +#define add_frag_mem_limit LINUX_BACKPORT(add_frag_mem_limit) +static inline void add_frag_mem_limit(struct inet_frag_queue *q, int i) +{ + atomic_add(i, &q->net->mem); +} + +#define init_frag_mem_limit LINUX_BACKPORT(init_frag_mem_limit) +static inline void init_frag_mem_limit(struct netns_frags *nf) +{ + atomic_set(&nf->mem, 0); +} + +#define sum_frag_mem_limit LINUX_BACKPORT(sum_frag_mem_limit) +static inline int sum_frag_mem_limit(struct netns_frags *nf) +{ + return atomic_read(&nf->mem); +} +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) */ + +#endif /* __BACKPORT__NET_FRAG_H__ */