public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>,
	Ling Ma <ling.ma.program@gmail.com>
Subject: Re: [PATCH net-next] net: move inet_dport/inet_num in sock_common
Date: Wed, 28 Nov 2012 03:27:41 -0800	[thread overview]
Message-ID: <1354102061.14302.84.camel@edumazet-glaptop> (raw)
In-Reply-To: <1354075918.14302.77.camel@edumazet-glaptop>

On Tue, 2012-11-27 at 20:12 -0800, Eric Dumazet wrote:

> The point of having the cond jump on sk_hash/hash was that in one
> compare, we catch the yes/no status with 99.999999 % success rate.
> 
> All the following compares are predicted by the cpu and essentially are
> free. Adding the AND or OR will basically have the same cpu cost.
> 
> If we wanted to do a full test of all tuple fields and a single
> conditional jump, we would not have to include hash test at all.
> 
> (If the 4-tuple matches, then sk_hash/hash value _must_ be the same by
> definition)

What I am going to do is to remove the hash compare from the macros so
that we can use likely()/unlikely() to explicitly give hints to the
compiler.

The hash compare can be omitted in the validation done after the
atomic_inc_not_zero() [ done to make sure keys didnt change ]

begin:
        sk_nulls_for_each_rcu(sk, node, &head->chain) {
                if (sk->sk_hash != hash)
                        continue;
                if (likely(INET_MATCH(sk, net, acookie,
                                      saddr, daddr, ports, dif))) {
                        if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt)))
                                goto begintw;
                        if (unlikely(!INET_MATCH(sk, net, acookie,
                                                 saddr, daddr, ports, dif))) {
                                sock_put(sk);
                                goto begin;
                        }
                        goto out;
                }
        }
 

  reply	other threads:[~2012-11-28 11:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27 15:06 [PATCH net-next] net: move inet_dport/inet_num in sock_common Eric Dumazet
2012-11-27 17:23 ` Joe Perches
2012-11-27 21:24   ` Eric Dumazet
2012-11-28  2:23     ` Joe Perches
2012-11-28  3:12       ` Ben Hutchings
2012-11-28  3:31         ` Joe Perches
2012-11-28  3:55           ` Ben Hutchings
2012-11-28  4:11       ` Eric Dumazet
2012-11-28 11:27         ` Eric Dumazet [this message]
2012-11-28 12:56           ` [PATCH v2 " Eric Dumazet
2012-11-28 16:48             ` David Miller
2012-11-28 17:02               ` David Miller
2012-11-28 17:18                 ` Eric Dumazet
2012-11-28 18:20             ` Eric Dumazet
2012-11-27 19:05 ` [PATCH " Ben Hutchings
2012-11-27 21:23   ` Eric Dumazet
2012-11-28  3:13     ` Eric Dumazet

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=1354102061.14302.84.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=joe@perches.com \
    --cc=ling.ma.program@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