summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-05-12 10:39:27 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-12 10:39:27 -0400
commit8df2914598c5300a937760daa271fdbddce1108c (patch)
tree1b67a0aa202e867b950b6ac2062df7faaa5c1d23 /include
parentb396cca6fafccf16206a5d041d59c9e6b65b6f5a (diff)
parente51423d9959df283c5af4ff13703f87e39d6e144 (diff)
downloadlinux-8df2914598c5300a937760daa271fdbddce1108c.tar.gz
linux-8df2914598c5300a937760daa271fdbddce1108c.tar.bz2
linux-8df2914598c5300a937760daa271fdbddce1108c.zip
Merge branch 'netdev_page_frags'
Alexander Duyck says: ==================== Refactor netdev page frags and move them into mm/ This patch series addresses several things. First I found an issue in the performance of the pfmemalloc check from build_skb. To work around it I have provided a cached copy of pfmemalloc to be used in __netdev_alloc_skb and __napi_alloc_skb. Second I moved the page fragment allocation logic into the mm tree and added functionality for freeing page fragments. I had to fix igb before I could do this as it was using a reference to NETDEV_FRAG_PAGE_MAX_SIZE incorrectly. Finally I went through and replaced all of the duplicate code that was calling put_page and replaced it with calls to skb_free_frag. With these changes in place a simple receive and drop test increased from a packet rate of 8.9Mpps to 9.8Mpps. The gains breakdown as follows: 8.9Mpps Before 9.8Mpps After ------------------------ ------------------------ 7.8% put_compound_page 9.1% __free_page_frag 3.9% skb_free_head 1.1% put_page 4.9% build_skb 3.8% __napi_alloc_skb 2.5% __alloc_rx_skb 1.9% __napi_alloc_skb ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/gfp.h5
-rw-r--r--include/linux/mm_types.h18
-rw-r--r--include/linux/skbuff.h9
3 files changed, 28 insertions, 4 deletions
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 97a9373e61e8..70a7fee1efb3 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -366,6 +366,11 @@ extern void free_pages(unsigned long addr, unsigned int order);
extern void free_hot_cold_page(struct page *page, bool cold);
extern void free_hot_cold_page_list(struct list_head *list, bool cold);
+struct page_frag_cache;
+extern void *__alloc_page_frag(struct page_frag_cache *nc,
+ unsigned int fragsz, gfp_t gfp_mask);
+extern void __free_page_frag(void *addr);
+
extern void __free_kmem_pages(struct page *page, unsigned int order);
extern void free_kmem_pages(unsigned long addr, unsigned int order);
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 8d37e26a1007..0038ac7466fd 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -226,6 +226,24 @@ struct page_frag {
#endif
};
+#define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
+#define PAGE_FRAG_CACHE_MAX_ORDER get_order(PAGE_FRAG_CACHE_MAX_SIZE)
+
+struct page_frag_cache {
+ void * va;
+#if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
+ __u16 offset;
+ __u16 size;
+#else
+ __u32 offset;
+#endif
+ /* we maintain a pagecount bias, so that we dont dirty cache line
+ * containing page->_count every time we allocate a fragment.
+ */
+ unsigned int pagecnt_bias;
+ bool pfmemalloc;
+};
+
typedef unsigned long __nocast vm_flags_t;
/*
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9c2f793573fa..c0b574a414e7 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2128,10 +2128,6 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
kfree_skb(skb);
}
-#define NETDEV_FRAG_PAGE_MAX_ORDER get_order(32768)
-#define NETDEV_FRAG_PAGE_MAX_SIZE (PAGE_SIZE << NETDEV_FRAG_PAGE_MAX_ORDER)
-#define NETDEV_PAGECNT_MAX_BIAS NETDEV_FRAG_PAGE_MAX_SIZE
-
void *netdev_alloc_frag(unsigned int fragsz);
struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int length,
@@ -2186,6 +2182,11 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
return __netdev_alloc_skb_ip_align(dev, length, GFP_ATOMIC);
}
+static inline void skb_free_frag(void *addr)
+{
+ __free_page_frag(addr);
+}
+
void *napi_alloc_frag(unsigned int fragsz);
struct sk_buff *__napi_alloc_skb(struct napi_struct *napi,
unsigned int length, gfp_t gfp_mask);