[Acked] [PATCH 2/2 Xenial SRU] e1000: Do not overestimate descriptor counts in Tx pre-check

Andy Whitcroft apw at canonical.com
Fri May 20 11:49:55 UTC 2016


On Mon, May 16, 2016 at 11:19:12AM -0600, Tim Gardner wrote:
> From: Alexander Duyck <aduyck at mirantis.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1582328
> 
> The current code path is capable of grossly overestimating the number of
> descriptors needed to transmit a new frame.  This specifically occurs if
> the skb contains a number of 4K pages.  The issue is that the logic for
> determining the descriptors needed is ((S) >> (X)) + 1.  When X is 12 it
> means that we were indicating that we required 2 descriptors for each 4K
> page when we only needed one.
> 
> This change corrects this by instead adding (1 << (X)) - 1 to the S value
> instead of adding 1 after the fact.  This way we get an accurate descriptor
> needed count as we are essentially doing a DIV_ROUNDUP().
> 
> Reported-by: Ivan Suzdal <isuzdal at mirantis.com>
> Signed-off-by: Alexander Duyck <aduyck at mirantis.com>
> Tested-by: Aaron Brown <aaron.f.brown at intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher at intel.com>
> (cherry picked from commit 847a1d6796c767f8b697ead60997b847a84b897b)
> Signed-off-by: Tim Gardner <tim.gardner at canonical.com>
> ---
>  drivers/net/ethernet/intel/e1000/e1000_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
> index 0b81d93..ae90d4f 100644
> --- a/drivers/net/ethernet/intel/e1000/e1000_main.c
> +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
> @@ -3106,7 +3106,7 @@ static int e1000_maybe_stop_tx(struct net_device *netdev,
>  	return __e1000_maybe_stop_tx(netdev, size);
>  }
>  
> -#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1)
> +#define TXD_USE_COUNT(S, X) (((S) + ((1 << (X)) - 1)) >> (X))
>  static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
>  				    struct net_device *netdev)
>  {
> -- 

Acked-by: Andy Whitcroft <apw at canonical.com>
-apw




More information about the kernel-team mailing list