From 1a9914c007b3bd8620ddd95bed7874dd642cf36c Mon Sep 17 00:00:00 2001 From: Christian Limpach Date: Thu, 18 Jan 2007 18:40:30 +0000 Subject: [linux networking] Remove the code to allocate page sized skbs. This is no longer used much since the default is to always copy packets to guests. Signed-off-by: Christian Limpach --- buildconfigs/linux-defconfig_xen0_ia64 | 3 - buildconfigs/linux-defconfig_xen0_x86_32 | 2 - buildconfigs/linux-defconfig_xen0_x86_64 | 2 - buildconfigs/linux-defconfig_xenU_ia64 | 3 - buildconfigs/linux-defconfig_xenU_x86_32 | 2 - buildconfigs/linux-defconfig_xenU_x86_64 | 2 - buildconfigs/linux-defconfig_xen_ia64 | 3 - buildconfigs/linux-defconfig_xen_x86_32 | 2 - buildconfigs/linux-defconfig_xen_x86_64 | 2 - linux-2.6-xen-sparse/arch/ia64/Kconfig | 6 - linux-2.6-xen-sparse/drivers/xen/Kconfig | 13 -- linux-2.6-xen-sparse/drivers/xen/core/Makefile | 1 - linux-2.6-xen-sparse/drivers/xen/core/skbuff.c | 145 --------------------- linux-2.6-xen-sparse/drivers/xen/netback/netback.c | 38 +----- linux-2.6-xen-sparse/include/linux/skbuff.h | 5 +- linux-2.6-xen-sparse/net/core/skbuff.c | 39 ++---- 16 files changed, 14 insertions(+), 254 deletions(-) delete mode 100644 linux-2.6-xen-sparse/drivers/xen/core/skbuff.c diff --git a/buildconfigs/linux-defconfig_xen0_ia64 b/buildconfigs/linux-defconfig_xen0_ia64 index 612bcfd42d..dc97753420 100644 --- a/buildconfigs/linux-defconfig_xen0_ia64 +++ b/buildconfigs/linux-defconfig_xen0_ia64 @@ -1512,10 +1512,7 @@ CONFIG_CRYPTO_DES=y # Hardware crypto devices # # CONFIG_XEN_UTIL is not set -CONFIG_HAVE_ARCH_ALLOC_SKB=y -CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y CONFIG_XEN_BALLOON=y -CONFIG_XEN_SKBUFF=y # CONFIG_XEN_DEVMEM is not set CONFIG_XEN_REBOOT=y # CONFIG_XEN_SMPBOOT is not set diff --git a/buildconfigs/linux-defconfig_xen0_x86_32 b/buildconfigs/linux-defconfig_xen0_x86_32 index e098035f66..4cc0ac3386 100644 --- a/buildconfigs/linux-defconfig_xen0_x86_32 +++ b/buildconfigs/linux-defconfig_xen0_x86_32 @@ -1338,8 +1338,6 @@ CONFIG_XEN_SYSFS=y CONFIG_XEN_COMPAT_030002_AND_LATER=y # CONFIG_XEN_COMPAT_LATEST_ONLY is not set CONFIG_XEN_COMPAT_030002=y -CONFIG_HAVE_ARCH_ALLOC_SKB=y -CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y CONFIG_NO_IDLE_HZ=y # diff --git a/buildconfigs/linux-defconfig_xen0_x86_64 b/buildconfigs/linux-defconfig_xen0_x86_64 index 48ba626c4b..ef1443eeeb 100644 --- a/buildconfigs/linux-defconfig_xen0_x86_64 +++ b/buildconfigs/linux-defconfig_xen0_x86_64 @@ -1278,8 +1278,6 @@ CONFIG_XEN_SYSFS=y CONFIG_XEN_COMPAT_030002_AND_LATER=y # CONFIG_XEN_COMPAT_LATEST_ONLY is not set CONFIG_XEN_COMPAT_030002=y -CONFIG_HAVE_ARCH_ALLOC_SKB=y -CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y CONFIG_NO_IDLE_HZ=y # diff --git a/buildconfigs/linux-defconfig_xenU_ia64 b/buildconfigs/linux-defconfig_xenU_ia64 index a7e15190ee..537fd311a9 100644 --- a/buildconfigs/linux-defconfig_xenU_ia64 +++ b/buildconfigs/linux-defconfig_xenU_ia64 @@ -1386,10 +1386,7 @@ CONFIG_CRYPTO_DES=y # Hardware crypto devices # # CONFIG_XEN_UTIL is not set -CONFIG_HAVE_ARCH_ALLOC_SKB=y -CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y CONFIG_XEN_BALLOON=y -CONFIG_XEN_SKBUFF=y # CONFIG_XEN_DEVMEM is not set CONFIG_XEN_REBOOT=y # CONFIG_XEN_SMPBOOT is not set diff --git a/buildconfigs/linux-defconfig_xenU_x86_32 b/buildconfigs/linux-defconfig_xenU_x86_32 index ce572fa621..605b82901b 100644 --- a/buildconfigs/linux-defconfig_xenU_x86_32 +++ b/buildconfigs/linux-defconfig_xenU_x86_32 @@ -865,8 +865,6 @@ CONFIG_XEN_SYSFS=y CONFIG_XEN_COMPAT_030002_AND_LATER=y # CONFIG_XEN_COMPAT_LATEST_ONLY is not set CONFIG_XEN_COMPAT_030002=y -CONFIG_HAVE_ARCH_ALLOC_SKB=y -CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y CONFIG_NO_IDLE_HZ=y # diff --git a/buildconfigs/linux-defconfig_xenU_x86_64 b/buildconfigs/linux-defconfig_xenU_x86_64 index ce83a618b8..62b398459a 100644 --- a/buildconfigs/linux-defconfig_xenU_x86_64 +++ b/buildconfigs/linux-defconfig_xenU_x86_64 @@ -1151,8 +1151,6 @@ CONFIG_XEN_SYSFS=y CONFIG_XEN_COMPAT_030002_AND_LATER=y # CONFIG_XEN_COMPAT_LATEST_ONLY is not set CONFIG_XEN_COMPAT_030002=y -CONFIG_HAVE_ARCH_ALLOC_SKB=y -CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y CONFIG_NO_IDLE_HZ=y # diff --git a/buildconfigs/linux-defconfig_xen_ia64 b/buildconfigs/linux-defconfig_xen_ia64 index e04b1db69f..2e41eb5892 100644 --- a/buildconfigs/linux-defconfig_xen_ia64 +++ b/buildconfigs/linux-defconfig_xen_ia64 @@ -1518,10 +1518,7 @@ CONFIG_CRYPTO_DES=y # Hardware crypto devices # # CONFIG_XEN_UTIL is not set -CONFIG_HAVE_ARCH_ALLOC_SKB=y -CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y CONFIG_XEN_BALLOON=y -CONFIG_XEN_SKBUFF=y # CONFIG_XEN_DEVMEM is not set CONFIG_XEN_REBOOT=y # CONFIG_XEN_SMPBOOT is not set diff --git a/buildconfigs/linux-defconfig_xen_x86_32 b/buildconfigs/linux-defconfig_xen_x86_32 index 99eeea8d2b..111890bd48 100644 --- a/buildconfigs/linux-defconfig_xen_x86_32 +++ b/buildconfigs/linux-defconfig_xen_x86_32 @@ -3043,8 +3043,6 @@ CONFIG_XEN_SYSFS=y CONFIG_XEN_COMPAT_030002_AND_LATER=y # CONFIG_XEN_COMPAT_LATEST_ONLY is not set CONFIG_XEN_COMPAT_030002=y -CONFIG_HAVE_ARCH_ALLOC_SKB=y -CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y CONFIG_NO_IDLE_HZ=y # diff --git a/buildconfigs/linux-defconfig_xen_x86_64 b/buildconfigs/linux-defconfig_xen_x86_64 index ebee7ab056..a51bfc1226 100644 --- a/buildconfigs/linux-defconfig_xen_x86_64 +++ b/buildconfigs/linux-defconfig_xen_x86_64 @@ -2874,8 +2874,6 @@ CONFIG_XEN_SYSFS=y CONFIG_XEN_COMPAT_030002_AND_LATER=y # CONFIG_XEN_COMPAT_LATEST_ONLY is not set CONFIG_XEN_COMPAT_030002=y -CONFIG_HAVE_ARCH_ALLOC_SKB=y -CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y CONFIG_NO_IDLE_HZ=y # diff --git a/linux-2.6-xen-sparse/arch/ia64/Kconfig b/linux-2.6-xen-sparse/arch/ia64/Kconfig index b354f44498..8deae439e9 100644 --- a/linux-2.6-xen-sparse/arch/ia64/Kconfig +++ b/linux-2.6-xen-sparse/arch/ia64/Kconfig @@ -521,12 +521,6 @@ if XEN config XEN_UTIL default n -config HAVE_ARCH_ALLOC_SKB - default y - -config HAVE_ARCH_DEV_ALLOC_SKB - default y - config XEN_BALLOON default y diff --git a/linux-2.6-xen-sparse/drivers/xen/Kconfig b/linux-2.6-xen-sparse/drivers/xen/Kconfig index 907d4b5757..019256771c 100644 --- a/linux-2.6-xen-sparse/drivers/xen/Kconfig +++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig @@ -238,14 +238,6 @@ config XEN_COMPAT_030002 endmenu -config HAVE_ARCH_ALLOC_SKB - bool - default y - -config HAVE_ARCH_DEV_ALLOC_SKB - bool - default y - config HAVE_IRQ_IGNORE_UNHANDLED bool default y @@ -266,11 +258,6 @@ config XEN_DEVMEM bool default y -config XEN_SKBUFF - bool - default y - depends on NET - config XEN_REBOOT bool default y diff --git a/linux-2.6-xen-sparse/drivers/xen/core/Makefile b/linux-2.6-xen-sparse/drivers/xen/core/Makefile index 519ea37351..064105443e 100644 --- a/linux-2.6-xen-sparse/drivers/xen/core/Makefile +++ b/linux-2.6-xen-sparse/drivers/xen/core/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_PROC_FS) += xen_proc.o obj-$(CONFIG_SYSFS) += hypervisor_sysfs.o obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o obj-$(CONFIG_XEN_SYSFS) += xen_sysfs.o -obj-$(CONFIG_XEN_SKBUFF) += skbuff.o obj-$(CONFIG_XEN_REBOOT) += reboot.o machine_reboot.o obj-$(CONFIG_XEN_SMPBOOT) += smpboot.o obj-$(CONFIG_KEXEC) += machine_kexec.o diff --git a/linux-2.6-xen-sparse/drivers/xen/core/skbuff.c b/linux-2.6-xen-sparse/drivers/xen/core/skbuff.c deleted file mode 100644 index 2fa88069c4..0000000000 --- a/linux-2.6-xen-sparse/drivers/xen/core/skbuff.c +++ /dev/null @@ -1,145 +0,0 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Referenced in netback.c. */ -/*static*/ kmem_cache_t *skbuff_cachep; -EXPORT_SYMBOL(skbuff_cachep); - -/* Allow up to 64kB or page-sized packets (whichever is greater). */ -#if PAGE_SHIFT < 16 -#define MAX_SKBUFF_ORDER (16 - PAGE_SHIFT) -#else -#define MAX_SKBUFF_ORDER 0 -#endif -static kmem_cache_t *skbuff_order_cachep[MAX_SKBUFF_ORDER + 1]; - -static struct { - int size; - kmem_cache_t *cachep; -} skbuff_small[] = { { 512, NULL }, { 2048, NULL } }; - -struct sk_buff *__alloc_skb(unsigned int length, gfp_t gfp_mask, - int fclone) -{ - int order, i; - kmem_cache_t *cachep; - - length = SKB_DATA_ALIGN(length) + sizeof(struct skb_shared_info); - - if (length <= skbuff_small[ARRAY_SIZE(skbuff_small)-1].size) { - for (i = 0; skbuff_small[i].size < length; i++) - continue; - cachep = skbuff_small[i].cachep; - } else { - order = get_order(length); - if (order > MAX_SKBUFF_ORDER) { - printk(KERN_ALERT "Attempt to allocate order %d " - "skbuff. Increase MAX_SKBUFF_ORDER.\n", order); - return NULL; - } - cachep = skbuff_order_cachep[order]; - } - - length -= sizeof(struct skb_shared_info); - - return alloc_skb_from_cache(cachep, length, gfp_mask, fclone); -} - -struct sk_buff *__dev_alloc_skb(unsigned int length, gfp_t gfp_mask) -{ - struct sk_buff *skb; - int order; - - length = SKB_DATA_ALIGN(length + 16); - order = get_order(length + sizeof(struct skb_shared_info)); - if (order > MAX_SKBUFF_ORDER) { - printk(KERN_ALERT "Attempt to allocate order %d skbuff. " - "Increase MAX_SKBUFF_ORDER.\n", order); - return NULL; - } - - skb = alloc_skb_from_cache( - skbuff_order_cachep[order], length, gfp_mask, 0); - if (skb != NULL) - skb_reserve(skb, 16); - - return skb; -} - -static void skbuff_ctor(void *buf, kmem_cache_t *cachep, unsigned long unused) -{ - int order = 0; - - while (skbuff_order_cachep[order] != cachep) - order++; - - /* Do our best to allocate contiguous memory but fall back to IOMMU. */ - if (order != 0) - (void)xen_create_contiguous_region( - (unsigned long)buf, order, 0); - - scrub_pages(buf, 1 << order); -} - -static void skbuff_dtor(void *buf, kmem_cache_t *cachep, unsigned long unused) -{ - int order = 0; - - while (skbuff_order_cachep[order] != cachep) - order++; - - if (order != 0) - xen_destroy_contiguous_region((unsigned long)buf, order); -} - -static int __init skbuff_init(void) -{ - static char name[MAX_SKBUFF_ORDER + 1][20]; - static char small_name[ARRAY_SIZE(skbuff_small)][20]; - unsigned long size; - int i, order; - - for (i = 0; i < ARRAY_SIZE(skbuff_small); i++) { - size = skbuff_small[i].size; - sprintf(small_name[i], "xen-skb-%lu", size); - /* - * No ctor/dtor: objects do not span page boundaries, and they - * are only used on transmit path so no need for scrubbing. - */ - skbuff_small[i].cachep = kmem_cache_create( - small_name[i], size, size, 0, NULL, NULL); - } - - for (order = 0; order <= MAX_SKBUFF_ORDER; order++) { - size = PAGE_SIZE << order; - sprintf(name[order], "xen-skb-%lu", size); - if (is_running_on_xen() && is_initial_xendomain()) - skbuff_order_cachep[order] = kmem_cache_create( - name[order], size, size, 0, - skbuff_ctor, skbuff_dtor); - else - skbuff_order_cachep[order] = kmem_cache_create( - name[order], size, size, 0, NULL, NULL); - - } - - skbuff_cachep = skbuff_order_cachep[0]; - - return 0; -} -core_initcall(skbuff_init); - -EXPORT_SYMBOL(__dev_alloc_skb); diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c index 1884597430..0bad2226bb 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c @@ -136,42 +136,6 @@ static inline void maybe_schedule_tx_action(void) tasklet_schedule(&net_tx_tasklet); } -/* - * A gross way of confirming the origin of an skb data page. The slab - * allocator abuses a field in the page struct to cache the kmem_cache_t ptr. - */ -static inline int is_xen_skb(struct sk_buff *skb) -{ - extern kmem_cache_t *skbuff_cachep; - kmem_cache_t *cp = (kmem_cache_t *)virt_to_page(skb->head)->lru.next; - return (cp == skbuff_cachep); -} - -/* - * We can flip without copying the packet unless: - * 1. The data is not allocated from our special cache; or - * 2. The main data area is shared; or - * 3. One or more fragments are shared; or - * 4. There are chained fragments. - */ -static inline int is_flippable_skb(struct sk_buff *skb) -{ - int frag; - - if (!is_xen_skb(skb) || skb_cloned(skb)) - return 0; - - for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { - if (page_count(skb_shinfo(skb)->frags[frag].page) > 1) - return 0; - } - - if (skb_shinfo(skb)->frag_list != NULL) - return 0; - - return 1; -} - static struct sk_buff *netbk_copy_skb(struct sk_buff *skb) { struct skb_shared_info *ninfo; @@ -285,7 +249,7 @@ int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev) * Copy the packet here if it's destined for a flipping interface * but isn't flippable (e.g. extra references to data). */ - if (!netif->copying_receiver && !is_flippable_skb(skb)) { + if (!netif->copying_receiver) { struct sk_buff *nskb = netbk_copy_skb(skb); if ( unlikely(nskb == NULL) ) goto drop; diff --git a/linux-2.6-xen-sparse/include/linux/skbuff.h b/linux-2.6-xen-sparse/include/linux/skbuff.h index 07b8f3036d..b37e27dda0 100644 --- a/linux-2.6-xen-sparse/include/linux/skbuff.h +++ b/linux-2.6-xen-sparse/include/linux/skbuff.h @@ -338,8 +338,7 @@ static inline struct sk_buff *alloc_skb_fclone(unsigned int size, extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, unsigned int size, - gfp_t priority, - int fclone); + gfp_t priority); extern void kfree_skbmem(struct sk_buff *skb); extern struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t priority); @@ -1069,7 +1068,7 @@ static inline struct sk_buff *__dev_alloc_skb(unsigned int length, return skb; } #else -extern struct sk_buff *__dev_alloc_skb(unsigned int length, gfp_t gfp_mask); +extern struct sk_buff *__dev_alloc_skb(unsigned int length, int gfp_mask); #endif /** diff --git a/linux-2.6-xen-sparse/net/core/skbuff.c b/linux-2.6-xen-sparse/net/core/skbuff.c index 5a524946b0..ab4b6079e5 100644 --- a/linux-2.6-xen-sparse/net/core/skbuff.c +++ b/linux-2.6-xen-sparse/net/core/skbuff.c @@ -132,7 +132,6 @@ void skb_under_panic(struct sk_buff *skb, int sz, void *here) * Buffers may only be allocated from interrupts using a @gfp_mask of * %GFP_ATOMIC. */ -#ifndef CONFIG_HAVE_ARCH_ALLOC_SKB struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, int fclone) { @@ -187,7 +186,6 @@ nodata: skb = NULL; goto out; } -#endif /* !CONFIG_HAVE_ARCH_ALLOC_SKB */ /** * alloc_skb_from_cache - allocate a network buffer @@ -205,18 +203,14 @@ nodata: */ struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, unsigned int size, - gfp_t gfp_mask, - int fclone) + gfp_t gfp_mask) { - kmem_cache_t *cache; - struct skb_shared_info *shinfo; struct sk_buff *skb; u8 *data; - cache = fclone ? skbuff_fclone_cache : skbuff_head_cache; - /* Get the HEAD */ - skb = kmem_cache_alloc(cache, gfp_mask & ~__GFP_DMA); + skb = kmem_cache_alloc(skbuff_head_cache, + gfp_mask & ~__GFP_DMA); if (!skb) goto out; @@ -233,29 +227,18 @@ struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, skb->data = data; skb->tail = data; skb->end = data + size; - /* make sure we initialize shinfo sequentially */ - shinfo = skb_shinfo(skb); - atomic_set(&shinfo->dataref, 1); - shinfo->nr_frags = 0; - shinfo->gso_size = 0; - shinfo->gso_segs = 0; - shinfo->gso_type = 0; - shinfo->ip6_frag_id = 0; - shinfo->frag_list = NULL; - - if (fclone) { - struct sk_buff *child = skb + 1; - atomic_t *fclone_ref = (atomic_t *) (child + 1); - - skb->fclone = SKB_FCLONE_ORIG; - atomic_set(fclone_ref, 1); - child->fclone = SKB_FCLONE_UNAVAILABLE; - } + atomic_set(&(skb_shinfo(skb)->dataref), 1); + skb_shinfo(skb)->nr_frags = 0; + skb_shinfo(skb)->gso_size = 0; + skb_shinfo(skb)->gso_segs = 0; + skb_shinfo(skb)->gso_type = 0; + skb_shinfo(skb)->ip6_frag_id = 0; + skb_shinfo(skb)->frag_list = NULL; out: return skb; nodata: - kmem_cache_free(cache, skb); + kmem_cache_free(skbuff_head_cache, skb); skb = NULL; goto out; } -- cgit v1.2.3