af_unix: optimize unix_dgram_poll()
authorEric Dumazet <eric.dumazet@gmail.com>
Sun, 31 Oct 2010 05:38:25 +0000 (05:38 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Nov 2010 21:50:09 +0000 (13:50 -0800)
commit973a34aa8593dbfe84386343c694f5beecb51d8a
treefc2531a0641cbf9caa474518dccb3266d8e2bf05
parent5456f09aaf88731e16dbcea7522cb330b6846415
af_unix: optimize unix_dgram_poll()

unix_dgram_poll() is pretty expensive to check POLLOUT status, because
it has to lock the socket to get its peer, take a reference on the peer
to check its receive queue status, and queue another poll_wait on
peer_wait. This all can be avoided if the process calling
unix_dgram_poll() is not interested in POLLOUT status. It makes
unix_dgram_recvmsg() faster by not queueing irrelevant pollers in
peer_wait.

On a test program provided by Alan Crequy :

Before:

real    0m0.211s
user    0m0.000s
sys     0m0.208s

After:

real    0m0.044s
user    0m0.000s
sys     0m0.040s

Suggested-by: Davide Libenzi <davidel@xmailserver.org>
Reported-by: Alban Crequy <alban.crequy@collabora.co.uk>
Acked-by: Davide Libenzi <davidel@xmailserver.org>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/unix/af_unix.c