Similar to the previous patch, the atomic xchg in sock_error() results in extra pipeline flushes due to the need to perform full synchronization as a memory barrier. Avoid calling sock_error() in a couple of places where it is safe to do a racy version of the test. Combined with the refcounting patch, this improves LMbench's bw_unix results from ~346K/s to ~570K/s on my test system.
-ben Signed-off-by: Benjamin LaHaise <[EMAIL PROTECTED]> diff --git a/net/core/datagram.c b/net/core/datagram.c index 1bcfef5..1c4af6f 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -149,11 +149,15 @@ struct sk_buff *skb_recv_datagram(struct long timeo; /* * Caller is allowed not to check sk->sk_err before skb_recv_datagram() + * because of this, we allow ourselves to do the fast (racy) test first. */ - int error = sock_error(sk); + int error; - if (error) - goto no_packet; + if (sk->sk_err) { + error = sock_error(sk); + if (error) + goto no_packet; + } timeo = sock_rcvtimeo(sk, noblock); diff --git a/net/core/sock.c b/net/core/sock.c index 13cc3be..463576b 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -950,9 +950,14 @@ static struct sk_buff *sock_alloc_send_p timeo = sock_sndtimeo(sk, noblock); while (1) { - err = sock_error(sk); - if (err != 0) - goto failure; + /* Avoid atomic xchg operation -- the pending error will + * be tested again, so the racy check is okay. + */ + if (sk->sk_err) { + err = sock_error(sk); + if (err != 0) + goto failure; + } err = -EPIPE; if (sk->sk_shutdown & SEND_SHUTDOWN) -- "You know, I've seen some crystals do some pretty trippy shit, man." Don't Email: <[EMAIL PROTECTED]>. - 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