From: Jeff Garzik <jeff@garzik•org>
To: akpm@linux-foundation•org, shemminger@linux-foundation•org
Cc: netdev <netdev@vger•kernel.org>
Subject: Re: [patch 08/17] sky2: avoid divide in receive path
Date: Sat, 29 Sep 2007 01:51:16 -0400 [thread overview]
Message-ID: <46FDE7D4.9050909@garzik.org> (raw)
In-Reply-To: <200709290542.l8T5gAHW002284@imap1.linux-foundation.org>
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.
parent reply other threads:[~2007-09-29 5:51 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <200709290542.l8T5gAHW002284@imap1.linux-foundation.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46FDE7D4.9050909@garzik.org \
--to=jeff@garzik$(echo .)org \
--cc=akpm@linux-foundation$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=shemminger@linux-foundation$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox