From patchwork Fri Mar 20 09:44:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 24737 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 711C3DDE1B for ; Fri, 20 Mar 2009 20:44:48 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756989AbZCTJo0 (ORCPT ); Fri, 20 Mar 2009 05:44:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756795AbZCTJo0 (ORCPT ); Fri, 20 Mar 2009 05:44:26 -0400 Received: from gw1.cosmosbay.com ([212.99.114.194]:39256 "EHLO gw1.cosmosbay.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756514AbZCTJoZ convert rfc822-to-8bit (ORCPT ); Fri, 20 Mar 2009 05:44:25 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by gw1.cosmosbay.com (8.13.7/8.13.7) with ESMTP id n2K9iG7P019667; Fri, 20 Mar 2009 10:44:16 +0100 Message-ID: <49C36570.4010903@cosmosbay.com> Date: Fri, 20 Mar 2009 10:44:16 +0100 From: Eric Dumazet User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: David Miller CC: netdev@vger.kernel.org Subject: [NET] net: reorder struct net_device_ops References: <49C354B5.3060404@cosmosbay.com> <20090320.013611.67498837.davem@davemloft.net> In-Reply-To: <20090320.013611.67498837.davem@davemloft.net> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (gw1.cosmosbay.com [0.0.0.0]); Fri, 20 Mar 2009 10:44:16 +0100 (CET) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org David Miller a écrit : > From: Eric Dumazet > Date: Fri, 20 Mar 2009 09:32:53 +0100 > >> There is no point to use prefetch() call here. >> start_xmit() is a function like others... >> >> Signed-off-by: Eric Dumazet > > Yes but the operation pointer might not be in the CPU > cache at this time? > > And if it's not we can get it into the cpu whilst we do > other processing, such as the dev_queue_xmit_nit() stuff. This slow down fast path, but we can find a compromise. I saw a strange effect on oprofile because of this prefetch() on a situation we call xxx.xxx times per second dev_hard_start_xmit() (So this ought to be in CPU cache already) prefetch() is *free* only if the address computation is fast too :) Thank you [NET] net: reorder struct net_device_ops Moving ndo_start_xmit() field at first position in struct net_device_ops reduce the assembly needed to compute the prefetch() address. There seems to be an issue here on some cpus as spotted by oprofile in dev_hard_start_xmit() (prefetch() has a dependancy on previous add instruction) mov %eax,-0x14(%ebp) /* store ops */ add $0x10,%eax /* compute &ops->ndo_start_xmit */ prefetcht0 (%eax) /* stall here */ After patch, no add instruction is needed anymore. Signed-off-by: Eric Dumazet --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index be3ebd7..e507c6e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -547,14 +547,14 @@ struct netdev_queue { */ #define HAVE_NET_DEVICE_OPS struct net_device_ops { - int (*ndo_init)(struct net_device *dev); - void (*ndo_uninit)(struct net_device *dev); - int (*ndo_open)(struct net_device *dev); - int (*ndo_stop)(struct net_device *dev); int (*ndo_start_xmit) (struct sk_buff *skb, struct net_device *dev); u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb); + int (*ndo_init)(struct net_device *dev); + void (*ndo_uninit)(struct net_device *dev); + int (*ndo_open)(struct net_device *dev); + int (*ndo_stop)(struct net_device *dev); #define HAVE_CHANGE_RX_FLAGS void (*ndo_change_rx_flags)(struct net_device *dev, int flags); diff --git a/net/core/dev.c b/net/core/dev.c index c013031..2e5ebd0 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1670,7 +1670,7 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, const struct net_device_ops *ops = dev->netdev_ops; int rc; - prefetch(&dev->netdev_ops->ndo_start_xmit); + prefetch(&ops->ndo_start_xmit); if (likely(!skb->next)) { if (!list_empty(&ptype_all)) dev_queue_xmit_nit(skb, dev);