All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] af_unix: optimize unix_dgram_poll()
@ 2010-10-31 15:38 Eric Dumazet
  2010-11-08 21:44 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2010-10-31 15:38 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Davide Libenzi, Alban Crequy

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>
---
 net/unix/af_unix.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 7375131..7067c5d 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2089,6 +2089,10 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
 			return mask;
 	}
 
+	/* No write status requested, avoid expensive OUT tests. */
+	if (wait && !(wait->key & (POLLWRBAND | POLLWRNORM | POLLOUT)))
+		return mask;
+
 	writable = unix_writable(sk);
 	other = unix_peer_get(sk);
 	if (other) {



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] af_unix: optimize unix_dgram_poll()
  2010-10-31 15:38 [PATCH 2/2] af_unix: optimize unix_dgram_poll() Eric Dumazet
@ 2010-11-08 21:44 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-11-08 21:44 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, davidel, alban.crequy

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sun, 31 Oct 2010 16:38:25 +0100

> 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>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-08 21:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-31 15:38 [PATCH 2/2] af_unix: optimize unix_dgram_poll() Eric Dumazet
2010-11-08 21:44 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.