From: Joe Perches <joe@perches.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 03/16] tcp: Maintain dynamic metrics in local cache.
Date: Tue, 10 Jul 2012 18:22:16 -0700 [thread overview]
Message-ID: <1341969736.13724.32.camel@joe2Laptop> (raw)
In-Reply-To: <20120710.180137.2161994914932724530.davem@davemloft.net>
On Tue, 2012-07-10 at 18:01 -0700, David Miller wrote:
> From: Joe Perches <joe@perches.com>
> Date: Tue, 10 Jul 2012 17:44:46 -0700
>
> > I'd guess the one above is faster to execute.
>
> It is.
>
> > If it's not, the code in ipv6_addr_equal
> > should be reverted. commit fed85383ac34d82
> > ("[IPV6]: Use XOR and OR rather than mutiple ands for ipv6 address comparisons")
>
> Not necessarily.
>
> My version here is faster because we unconditionally test
> the first word, which we need to do for both the ipv4 and
> ipv6 cases.
I don't think that's correct.
Look at what I posted again.
If it's IPv4,
if (a->family == AF_INET)
return a->addr.a4 == b->addr.a4;
return ipv6_addr_equal((const struct in6_addr *)&a->addr.a6,
(const struct in6_addr *)&b->addr.a6);
so it's a single word test or a 4 word test.
Your code is compare/branch/continue in a loop with an
increment and test. I find it hard to believe that's
faster. I suppose it _could_ be faster dependent on the
data in the words though.
> The ipv6 routine optimization you mention exists in a
> world where we know we have an ipv6 address always, which
> is not the case here.
What do I miss?
Is there a case where a->family is neither
AF_INET or AF_INET6?
> If anything, we should do XOR's on the final three words,
> but we should not remove the first word optimization for
> ipv4 which is the common case.
cheers, Joe
next prev parent reply other threads:[~2012-07-11 1:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-10 15:07 [PATCH 03/16] tcp: Maintain dynamic metrics in local cache David Miller
2012-07-10 15:31 ` Eric Dumazet
2012-07-10 15:33 ` David Miller
2012-07-10 17:02 ` Joe Perches
2012-07-11 0:29 ` David Miller
2012-07-11 0:44 ` Joe Perches
2012-07-11 1:01 ` David Miller
2012-07-11 1:22 ` Joe Perches [this message]
2012-07-11 3:56 ` David Miller
2012-07-11 3:59 ` 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=1341969736.13724.32.camel@joe2Laptop \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--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