netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: libertas-dev@lists.infradead.org, dcbw@redhat.com,
	netdev@vger.kernel.org,
	virtualization@lists.linux-foundation.org, rolandd@cisco.com,
	divy@chelsio.com, xemul@openvz.org
Subject: Re: [PATCH 1/4] net: skb_orphan on dev_hard_start_xmit
Date: Thu, 04 Jun 2009 06:54:24 +0200	[thread overview]
Message-ID: <4A275380.1050601@gmail.com> (raw)
In-Reply-To: <20090603.210054.18839960.davem@davemloft.net>

David Miller a écrit :
> From: Rusty Russell <rusty@rustcorp.com.au>
> Date: Thu, 4 Jun 2009 13:24:57 +0930
> 
>> On Thu, 4 Jun 2009 06:32:53 am Eric Dumazet wrote:
>>> Also, taking a reference on socket for each xmit packet in flight is very
>>> expensive, since it slows down receiver in __udp4_lib_lookup(). Several
>>> cpus are fighting for sk->refcnt cache line.
>> Now we have decent dynamic per-cpu, we can finally implement bigrefs.  More 
>> obvious for device counts than sockets, but perhaps applicable here as well?
> 
> It might be very beneficial for longer lasting, active, connections, but
> for high connection rates it's going to be a lose in my estimation.

Agreed.

We also can avoid the sock_put()/sock_hold() pair for each tx packet,
to only touch sk_wmem_alloc (with appropriate atomic_sub_return() in sock_wfree()
and atomic_dec_test in sk_free

We could initialize sk->sk_wmem_alloc to one instead of 0, so that
sock_wfree() could just synchronize itself with sk_free()

void sk_free(struct sock *sk)
{
	if (atomic_dec_test(&sk->sk_wmem_alloc))
		__sk_free(sk)
}

 static inline void skb_set_owner_w(struct sk_buff *skb, struct sock *sk)
 {
-       sock_hold(sk);
        skb->sk = sk;
        skb->destructor = sock_wfree;
        atomic_add(skb->truesize, &sk->sk_wmem_alloc);
 }

 void sock_wfree(struct sk_buff *skb)
 {
        struct sock *sk = skb->sk;
+       int res;

        /* In case it might be waiting for more memory. */
-       atomic_sub(skb->truesize, &sk->sk_wmem_alloc);
+       res = atomic_sub_return(skb->truesize, &sk->sk_wmem_alloc);
        if (!sock_flag(sk, SOCK_USE_WRITE_QUEUE))
                sk->sk_write_space(sk);
-       sock_put(sk);
+       if (res == 0)
+               __sk_free(sk);
 }

Patch will follow after some testing

  reply	other threads:[~2009-06-04  4:54 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-29 14:14 [PATCH 1/4] net: skb_orphan on dev_hard_start_xmit Rusty Russell
2009-05-29 15:11 ` Eric Dumazet
2009-06-01 12:27   ` Rusty Russell
2009-06-03 21:02     ` Eric Dumazet
2009-06-04  3:54       ` Rusty Russell
2009-06-04  4:00         ` David Miller
2009-06-04  4:54           ` Eric Dumazet [this message]
2009-06-04  4:56             ` David Miller
2009-06-04  9:18               ` [PATCH] net: No more expensive sock_hold()/sock_put() on each tx Eric Dumazet
2009-06-04  9:26                 ` David Miller
2009-06-10  8:17                 ` David Miller
2009-06-10  8:30                   ` Eric Dumazet
2009-06-11  9:56                     ` David Miller
2009-06-01 19:47 ` [PATCH 1/4] net: skb_orphan on dev_hard_start_xmit Patrick Ohly
2009-06-02  7:25   ` David Miller
2009-06-02 14:08     ` Rusty Russell
2009-06-03  0:14       ` David Miller
2009-07-03  7:55         ` Herbert Xu
2009-07-04  3:02           ` David Miller
2009-07-04  3:08             ` Herbert Xu
2009-07-04  3:13               ` David Miller
2009-07-04  7:42                 ` Herbert Xu
2009-07-04  9:09                   ` Herbert Xu
2009-07-05  3:26                     ` Herbert Xu
2009-07-05  3:34                       ` Herbert Xu
2009-08-18  1:47                         ` David Miller
2009-08-19  3:19                           ` Herbert Xu
2009-08-19  3:34                             ` 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=4A275380.1050601@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dcbw@redhat.com \
    --cc=divy@chelsio.com \
    --cc=libertas-dev@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=rolandd@cisco.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xemul@openvz.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).