From: Joe Perches <joe@perches.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>, netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] ipv6: optimize ipv6 addresses compares
Date: Tue, 10 Jul 2012 21:14:50 -0700 [thread overview]
Message-ID: <1341980090.13724.43.camel@joe2Laptop> (raw)
In-Reply-To: <1341978558.3265.6609.camel@edumazet-glaptop>
On Wed, 2012-07-11 at 05:49 +0200, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> On 64 bit arches having efficient unaligned accesses (eg x86_64) we can
> use long words to reduce number of instructions for free.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Joe Perches <joe@perches.com>
> ---
> include/net/ipv6.h | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index aecf884..9ac5ded 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -302,10 +302,19 @@ static inline int
> ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m,
> const struct in6_addr *a2)
> {
> +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
> + const unsigned long *ul1 = (const unsigned long *)a1;
> + const unsigned long *ulm = (const unsigned long *)m;
> + const unsigned long *ul2 = (const unsigned long *)a2;
> +
> + return !!(((ul1[0] ^ ul2[0]) & ulm[0]) |
> + ((ul1[1] ^ ul2[1]) & ulm[1]));
> +#else
> return !!(((a1->s6_addr32[0] ^ a2->s6_addr32[0]) & m->s6_addr32[0]) |
> ((a1->s6_addr32[1] ^ a2->s6_addr32[1]) & m->s6_addr32[1]) |
> ((a1->s6_addr32[2] ^ a2->s6_addr32[2]) & m->s6_addr32[2]) |
> ((a1->s6_addr32[3] ^ a2->s6_addr32[3]) & m->s6_addr32[3]));
> +#endif
> }
Come to think of it, this should probably be bool to
avoid anyone possibly using this in a sorting function.
next prev parent reply other threads:[~2012-07-11 4:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 3:49 [PATCH net-next] ipv6: optimize ipv6 addresses compares Eric Dumazet
2012-07-11 3:59 ` Joe Perches
2012-07-11 4:02 ` David Miller
2012-07-11 4:07 ` Eric Dumazet
2012-07-11 4:13 ` David Miller
2012-07-11 4:44 ` Eric Dumazet
2012-07-11 4:53 ` Eric Dumazet
2012-07-11 5:44 ` David Miller
2012-07-11 4:14 ` Joe Perches [this message]
2012-07-11 5:05 ` Eric Dumazet
2012-07-11 6:13 ` David Miller
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=1341980090.13724.43.camel@joe2Laptop \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.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;
as well as URLs for NNTP newsgroup(s).