Fix optimization of netdev_priv() lost by the addition of multiqueue. Only configurations that define MULITQUEUE need the extra overhead in netdevice structure and the loss of the netdev_priv optimization.
Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]> --- a/include/linux/netdevice.h 2007-08-17 16:45:39.000000000 -0700 +++ b/include/linux/netdevice.h 2007-08-17 17:31:51.000000000 -0700 @@ -574,17 +574,22 @@ struct net_device const struct rtnl_link_ops *rtnl_link_ops; /* The TX queue control structures */ - unsigned int egress_subqueue_count; +#ifdef CONFIG_NETDEVICES_MULTIQUEUE + unsigned short egress_subqueue_count; struct net_device_subqueue egress_subqueue[1]; +#endif }; #define to_net_dev(d) container_of(d, struct net_device, dev) #define NETDEV_ALIGN 32 -#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) static inline void *netdev_priv(const struct net_device *dev) { +#ifdef CONFIG_NETDEVICES_MULTIQUEUE return dev->priv; +#else + return (void *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN); +#endif } #define SET_MODULE_OWNER(dev) do { } while (0) --- a/net/core/dev.c 2007-08-17 16:45:39.000000000 -0700 +++ b/net/core/dev.c 2007-08-17 17:44:02.000000000 -0700 @@ -3706,7 +3706,7 @@ EXPORT_SYMBOL(dev_get_stats); * @queue_count: the number of subqueues to allocate * * Allocates a struct net_device with private data area for driver use - * and performs basic initialization. Also allocates subquue structs + * and performs basic initialization. Also allocates subqueue structs * for each queue on the device at the end of the netdevice. */ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, @@ -3714,15 +3714,20 @@ struct net_device *alloc_netdev_mq(int s { void *p; struct net_device *dev; - int alloc_size; + size_t dev_size, alloc_size; BUG_ON(strlen(name) >= sizeof(dev->name)); +#ifndef CONFIG_NETDEVICES_MULTIQUEUE + BUG_ON(queue_count > 1); +#endif + /* ensure 32-byte alignment of both the device and private area */ - alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST + - (sizeof(struct net_device_subqueue) * (queue_count - 1))) & - ~NETDEV_ALIGN_CONST; - alloc_size += sizeof_priv + NETDEV_ALIGN_CONST; + dev_size = sizeof(*dev) + + (queue_count - 1) * sizeof(struct net_device_subqueue); + + alloc_size = roundup(dev_size, NETDEV_ALIGN); + alloc_size += sizeof_priv + NETDEV_ALIGN - 1; p = kzalloc(alloc_size, GFP_KERNEL); if (!p) { @@ -3730,19 +3735,17 @@ struct net_device *alloc_netdev_mq(int s return NULL; } - dev = (struct net_device *) - (((long)p + NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST); + dev = (struct net_device *) ALIGN((unsigned long) p, NETDEV_ALIGN); dev->padded = (char *)dev - (char *)p; - if (sizeof_priv) { - dev->priv = ((char *)dev + - ((sizeof(struct net_device) + - (sizeof(struct net_device_subqueue) * - (queue_count - 1)) + NETDEV_ALIGN_CONST) - & ~NETDEV_ALIGN_CONST)); - } - +#ifdef CONFIG_NETDEVICES_MULTIQUEUE dev->egress_subqueue_count = queue_count; + if (sizeof_priv) + dev->priv = ALIGN((unsigned long)dev + dev_size, NETDEV_ALIGN); +#else + if (sizeof_priv) + dev->priv = netdev_priv(dev); +#endif setup(dev); strcpy(dev->name, name); - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html