diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-10-31 01:38:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-11-08 16:50:09 -0500 |
commit | 973a34aa8593dbfe84386343c694f5beecb51d8a (patch) | |
tree | fc2531a0641cbf9caa474518dccb3266d8e2bf05 /net/unix | |
parent | 5456f09aaf88731e16dbcea7522cb330b6846415 (diff) |
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>
Diffstat (limited to 'net/unix')
-rw-r--r-- | net/unix/af_unix.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index e8898758dd31..7ff31c60186a 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -2091,6 +2091,10 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock, | |||
2091 | return mask; | 2091 | return mask; |
2092 | } | 2092 | } |
2093 | 2093 | ||
2094 | /* No write status requested, avoid expensive OUT tests. */ | ||
2095 | if (wait && !(wait->key & (POLLWRBAND | POLLWRNORM | POLLOUT))) | ||
2096 | return mask; | ||
2097 | |||
2094 | writable = unix_writable(sk); | 2098 | writable = unix_writable(sk); |
2095 | other = unix_peer_get(sk); | 2099 | other = unix_peer_get(sk); |
2096 | if (other) { | 2100 | if (other) { |