Netdev List
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Joe Perches <joe@perches.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH] - trivial - Improve appletalk checksum calculation
Date: Mon, 22 Oct 2007 20:30:52 -0700	[thread overview]
Message-ID: <20071022203052.23725719@freepuppy.rosehill> (raw)
In-Reply-To: <1193081779.5132.24.camel@localhost>

On Mon, 22 Oct 2007 12:36:19 -0700
Joe Perches <joe@perches.com> wrote:

> It's a bit after 2.6.1 now...
> 
> Removes unnecessary if, uses 16 bit rotate left.
> Performance improves ~30%
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> 
> diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
> index 7c0b515..1c50f4c 100644
> --- a/net/appletalk/ddp.c
> +++ b/net/appletalk/ddp.c
> @@ -925,15 +925,9 @@ static int atrtr_ioctl(unsigned int cmd, void __user *arg)
>  static unsigned long atalk_sum_partial(const unsigned char *data,
>  				       int len, unsigned long sum)
>  {
> -	/* This ought to be unwrapped neatly. I'll trust gcc for now */
>  	while (len--) {
> -		sum += *data;
> -		sum <<= 1;
> -		if (sum & 0x10000) {
> -			sum++;
> -			sum &= 0xffff;
> -		}
> -		data++;
> +		sum += *data++;
> +		sum = ((sum & 0x8000)>>15) | ((sum & 0x7fff)<<1);
>  	}
>  	return sum;
>  }
> 

The end of the message you quoted was:

> Corrected fast code is:
> 
>         while (len--) {
>                 sum += *data++;
>                 sum <<= 1;
>                 sum = (((sum & 0x10000) >> 16) + sum) & 0xffff;
>         }
> 
> At least it is correct on the standalone random data test, and the
> new code is 30% faster for the cached memory case (13.7 clks/byte vs 18 
> clks/byte).

Your code looks different...

-- 
Stephen Hemminger <shemminger@linux-foundation.org>

  parent reply	other threads:[~2007-10-23  3:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-22 19:36 [PATCH] - trivial - Improve appletalk checksum calculation Joe Perches
2007-10-23  0:35 ` David Miller
2007-10-23  1:36   ` Joe Perches
2007-10-23  1:43     ` David Miller
2007-10-23  1:53       ` Joe Perches
2007-10-23  3:51         ` Herbert Xu
2007-10-28 20:18           ` Urs Thuermann
2007-10-28 21:01             ` Joe Perches
2007-10-29  2:40               ` Joe Perches
2007-10-23  3:30 ` Stephen Hemminger [this message]
2007-10-23  3:39   ` Joe Perches

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=20071022203052.23725719@freepuppy.rosehill \
    --to=shemminger@linux-foundation.org \
    --cc=acme@ghostprotocols.net \
    --cc=davem@davemloft.net \
    --cc=joe@perches.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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