All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [patch 08/17] sky2: avoid divide in receive path
       [not found] <200709290542.l8T5gAHW002284@imap1.linux-foundation.org>
@ 2007-09-29  5:51 ` Jeff Garzik
  0 siblings, 0 replies; only message in thread
From: Jeff Garzik @ 2007-09-29  5:51 UTC (permalink / raw)
  To: akpm, shemminger; +Cc: netdev

akpm@linux-foundation.org wrote:
> From: Stephen Hemminger <shemminger@linux-foundation.org>
> 
> Avoid divide (modulus) in receive buffer handling path.
> 
> Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  drivers/net/sky2.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff -puN drivers/net/sky2.c~sky2-avoid-divide-in-receive-path drivers/net/sky2.c
> --- a/drivers/net/sky2.c~sky2-avoid-divide-in-receive-path
> +++ a/drivers/net/sky2.c
> @@ -2155,7 +2155,8 @@ static struct sk_buff *sky2_receive(stru
>  		printk(KERN_DEBUG PFX "%s: rx slot %u status 0x%x len %d\n",
>  		       dev->name, sky2->rx_next, status, length);
>  
> -	sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending;
> +	if (++sky2->rx_next >= sky2->rx_pending)
> +		sky2->rx_next = 0;


it is silly to introduce a branch just for this.

require that the ring size is a power-of-2, and then replace the divide 
with a mask.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-29  5:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200709290542.l8T5gAHW002284@imap1.linux-foundation.org>
2007-09-29  5:51 ` [patch 08/17] sky2: avoid divide in receive path Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.