From: Andrew Morton <[EMAIL PROTECTED]>
Date: Sun, 11 Dec 2005 00:19:58 -0800

> Ah, sorry.  -mm's git-net is from
> git+ssh://master.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.16.git
> 
> I tend to prefer the latest and greatest of everything.

Ok.  Ben, you're not off the hook sorry :-)
Maybe that stream sendmsg() AF_UNIX peer socket
reference bump is really needed.

Andrew, does reverting the following make the problem go
away?

diff-tree 918374e04126ac04f42c58905cd3e88d785a8eef (from 
1e0fe0b7e1b017d47930351ec50a3f49d7c7257b)
Author: Benjamin LaHaise <[EMAIL PROTECTED]>
Date:   Sat Dec 10 11:52:17 2005 -0800

    [AF_UNIX]: Remove superfluous reference counting in unix_stream_sendmsg
    
    AF_UNIX stream socket performance on P4 CPUs tends to suffer due to a
    lot of pipeline flushes from atomic operations.  The patch below
    removes the sock_hold() and sock_put() in unix_stream_sendmsg().  This
    should be safe as the socket still holds a reference to its peer which
    is only released after the file descriptor's final user invokes
    unix_release_sock().  The only consideration is that we must add a
    memory barrier before setting the peer initially.
    
    Signed-off-by: Benjamin LaHaise <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index acc73ba..3593b90 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1063,10 +1063,12 @@ restart:
        /* Set credentials */
        sk->sk_peercred = other->sk_peercred;
 
-       sock_hold(newsk);
-       unix_peer(sk)   = newsk;
        sock->state     = SS_CONNECTED;
        sk->sk_state    = TCP_ESTABLISHED;
+       sock_hold(newsk);
+
+       smp_mb__after_atomic_inc();     /* sock_hold() does an atomic_inc() */
+       unix_peer(sk)   = newsk;
 
        unix_state_wunlock(sk);
 
@@ -1414,7 +1416,7 @@ static int unix_stream_sendmsg(struct ki
        } else {
                sunaddr = NULL;
                err = -ENOTCONN;
-               other = unix_peer_get(sk);
+               other = unix_peer(sk);
                if (!other)
                        goto out_err;
        }
@@ -1476,7 +1478,6 @@ static int unix_stream_sendmsg(struct ki
                other->sk_data_ready(other, size);
                sent+=size;
        }
-       sock_put(other);
 
        scm_destroy(siocb->scm);
        siocb->scm = NULL;
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to