ia64/xen-unstable

changeset 7708:98bcd8fbd5e3

Fix alloc_skb() to ensure data is always physically contiguous.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Nov 08 16:48:42 2005 +0100 (2005-11-08)
parents 0915074c356e
children abbe3df33774
files linux-2.6-xen-sparse/arch/xen/Kconfig linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64 linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32 linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64 linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32 linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_64 linux-2.6-xen-sparse/arch/xen/kernel/skbuff.c linux-2.6-xen-sparse/net/core/skbuff.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/Kconfig	Tue Nov 08 15:58:31 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/Kconfig	Tue Nov 08 16:48:42 2005 +0100
     1.3 @@ -173,6 +173,10 @@ endchoice
     1.4  
     1.5  endmenu
     1.6  
     1.7 +config HAVE_ARCH_ALLOC_SKB
     1.8 +	bool
     1.9 +	default y
    1.10 +
    1.11  config HAVE_ARCH_DEV_ALLOC_SKB
    1.12  	bool
    1.13  	default y
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Tue Nov 08 15:58:31 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Tue Nov 08 16:48:42 2005 +0100
     2.3 @@ -25,6 +25,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     2.4  CONFIG_XEN_SCRUB_PAGES=y
     2.5  CONFIG_XEN_X86=y
     2.6  # CONFIG_XEN_X86_64 is not set
     2.7 +CONFIG_HAVE_ARCH_ALLOC_SKB=y
     2.8  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
     2.9  
    2.10  #
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Tue Nov 08 15:58:31 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Tue Nov 08 16:48:42 2005 +0100
     3.3 @@ -25,6 +25,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     3.4  CONFIG_XEN_SCRUB_PAGES=y
     3.5  # CONFIG_XEN_X86 is not set
     3.6  CONFIG_XEN_X86_64=y
     3.7 +CONFIG_HAVE_ARCH_ALLOC_SKB=y
     3.8  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
     3.9  
    3.10  #
     4.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32	Tue Nov 08 15:58:31 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32	Tue Nov 08 16:48:42 2005 +0100
     4.3 @@ -22,6 +22,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     4.4  CONFIG_XEN_SCRUB_PAGES=y
     4.5  CONFIG_XEN_X86=y
     4.6  # CONFIG_XEN_X86_64 is not set
     4.7 +CONFIG_HAVE_ARCH_ALLOC_SKB=y
     4.8  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
     4.9  
    4.10  #
     5.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64	Tue Nov 08 15:58:31 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64	Tue Nov 08 16:48:42 2005 +0100
     5.3 @@ -22,6 +22,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     5.4  CONFIG_XEN_SCRUB_PAGES=y
     5.5  # CONFIG_XEN_X86 is not set
     5.6  CONFIG_XEN_X86_64=y
     5.7 +CONFIG_HAVE_ARCH_ALLOC_SKB=y
     5.8  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
     5.9  
    5.10  #
     6.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32	Tue Nov 08 15:58:31 2005 +0100
     6.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_32	Tue Nov 08 16:48:42 2005 +0100
     6.3 @@ -25,6 +25,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     6.4  CONFIG_XEN_SCRUB_PAGES=y
     6.5  CONFIG_XEN_X86=y
     6.6  # CONFIG_XEN_X86_64 is not set
     6.7 +CONFIG_HAVE_ARCH_ALLOC_SKB=y
     6.8  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
     6.9  
    6.10  #
     7.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_64	Tue Nov 08 15:58:31 2005 +0100
     7.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen_defconfig_x86_64	Tue Nov 08 16:48:42 2005 +0100
     7.3 @@ -25,6 +25,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     7.4  CONFIG_XEN_SCRUB_PAGES=y
     7.5  # CONFIG_XEN_X86 is not set
     7.6  CONFIG_XEN_X86_64=y
     7.7 +CONFIG_HAVE_ARCH_ALLOC_SKB=y
     7.8  CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
     7.9  
    7.10  #
     8.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/skbuff.c	Tue Nov 08 15:58:31 2005 +0100
     8.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/skbuff.c	Tue Nov 08 16:48:42 2005 +0100
     8.3 @@ -20,6 +20,37 @@
     8.4  #define MAX_SKBUFF_ORDER 2
     8.5  static kmem_cache_t *skbuff_order_cachep[MAX_SKBUFF_ORDER + 1];
     8.6  
     8.7 +static struct {
     8.8 +	int size;
     8.9 +	kmem_cache_t *cachep;
    8.10 +} skbuff_small[] = { { 512, NULL }, { 2048, NULL } };
    8.11 +
    8.12 +struct sk_buff *alloc_skb(unsigned int length, int gfp_mask)
    8.13 +{
    8.14 +	int order, i;
    8.15 +	kmem_cache_t *cachep;
    8.16 +
    8.17 +	length = SKB_DATA_ALIGN(length) + sizeof(struct skb_shared_info);
    8.18 +
    8.19 +	if (length <= skbuff_small[ARRAY_SIZE(skbuff_small)-1].size) {
    8.20 +		for (i = 0; skbuff_small[i].size < length; i++)
    8.21 +			continue;
    8.22 +		cachep = skbuff_small[i].cachep;
    8.23 +	} else {
    8.24 +		order = get_order(length);
    8.25 +		if (order > MAX_SKBUFF_ORDER) {
    8.26 +			printk(KERN_ALERT "Attempt to allocate order %d "
    8.27 +			       "skbuff. Increase MAX_SKBUFF_ORDER.\n", order);
    8.28 +			return NULL;
    8.29 +		}
    8.30 +		cachep = skbuff_order_cachep[order];
    8.31 +	}
    8.32 +
    8.33 +	length -= sizeof(struct skb_shared_info);
    8.34 +
    8.35 +	return alloc_skb_from_cache(cachep, length, gfp_mask);
    8.36 +}
    8.37 +
    8.38  struct sk_buff *__dev_alloc_skb(unsigned int length, int gfp_mask)
    8.39  {
    8.40  	struct sk_buff *skb;
    8.41 @@ -68,8 +99,20 @@ static void skbuff_dtor(void *buf, kmem_
    8.42  static int __init skbuff_init(void)
    8.43  {
    8.44  	static char name[MAX_SKBUFF_ORDER + 1][20];
    8.45 +	static char small_name[ARRAY_SIZE(skbuff_small)][20];
    8.46  	unsigned long size;
    8.47 -	int order;
    8.48 +	int i, order;
    8.49 +
    8.50 +	for (i = 0; i < ARRAY_SIZE(skbuff_small); i++) {
    8.51 +		size = skbuff_small[i].size;
    8.52 +		sprintf(small_name[i], "xen-skb-%lu", size);
    8.53 +		/*
    8.54 +		 * No ctor/dtor: objects do not span page boundaries, and they
    8.55 +		 * are only used on transmit path so no need for scrubbing.
    8.56 +		 */
    8.57 +		skbuff_small[i].cachep = kmem_cache_create(
    8.58 +			small_name[i], size, size, 0, NULL, NULL);
    8.59 +	}
    8.60  
    8.61  	for (order = 0; order <= MAX_SKBUFF_ORDER; order++) {
    8.62  		size = PAGE_SIZE << order;
    8.63 @@ -82,7 +125,7 @@ static int __init skbuff_init(void)
    8.64  
    8.65  	return 0;
    8.66  }
    8.67 -__initcall(skbuff_init);
    8.68 +core_initcall(skbuff_init);
    8.69  
    8.70  EXPORT_SYMBOL(__dev_alloc_skb);
    8.71  
     9.1 --- a/linux-2.6-xen-sparse/net/core/skbuff.c	Tue Nov 08 15:58:31 2005 +0100
     9.2 +++ b/linux-2.6-xen-sparse/net/core/skbuff.c	Tue Nov 08 16:48:42 2005 +0100
     9.3 @@ -129,6 +129,7 @@ void skb_under_panic(struct sk_buff *skb
     9.4   *	Buffers may only be allocated from interrupts using a @gfp_mask of
     9.5   *	%GFP_ATOMIC.
     9.6   */
     9.7 +#ifndef CONFIG_HAVE_ARCH_ALLOC_SKB
     9.8  struct sk_buff *alloc_skb(unsigned int size, int gfp_mask)
     9.9  {
    9.10  	struct sk_buff *skb;
    9.11 @@ -166,6 +167,7 @@ nodata:
    9.12  	skb = NULL;
    9.13  	goto out;
    9.14  }
    9.15 +#endif /* !CONFIG_HAVE_ARCH_ALLOC_SKB */
    9.16  
    9.17  /**
    9.18   *	alloc_skb_from_cache	-	allocate a network buffer