From: Eric Dumazet <eric.dumazet@gmail.com>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: Alban Crequy <alban.crequy@collabora.co.uk>,
"David S. Miller" <davem@davemloft.net>,
Stephen Hemminger <shemminger@vyatta.com>,
Cyrill Gorcunov <gorcunov@openvz.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
netdev@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Pauli Nieminen <pauli.nieminen@collabora.co.uk>,
Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: [PATCH] af_unix: optimize unix_dgram_poll()
Date: Sat, 30 Oct 2010 11:53:40 +0200 [thread overview]
Message-ID: <1288432420.2680.933.camel@edumazet-laptop> (raw)
In-Reply-To: <alpine.DEB.2.00.1010291339180.8517@davide-lnx1>
Le vendredi 29 octobre 2010 à 13:46 -0700, Davide Libenzi a écrit :
> Also, why not using the existing wait->key instead of adding a poll2()?
Indeed, if wait is not null, we have in wait->key the interest of
poller. If a particular poll() function is expensive, it can test these
bits.
Thanks !
Note: I chose the 'goto skip_write' to make this patch really obvious.
[PATCH] 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>
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 3c95304..dcb84fe 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2090,6 +2090,9 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
return mask;
}
+ if (wait && !(wait->key & (POLLWRBAND | POLLWRNORM | POLLOUT)))
+ goto skip_write;
+
/* writable? */
writable = unix_writable(sk);
if (writable) {
@@ -2111,6 +2114,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
else
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
+skip_write:
return mask;
}
next prev parent reply other threads:[~2010-10-30 9:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-29 18:18 [PATCH 0/1] RFC: poll/select performance on datagram sockets Alban Crequy
2010-10-29 18:21 ` [PATCH] " Alban Crequy
2010-10-29 19:27 ` [PATCH 0/1] RFC: " Eric Dumazet
2010-10-29 20:08 ` Davide Libenzi
2010-10-29 20:20 ` Eric Dumazet
2010-10-29 20:46 ` Davide Libenzi
2010-10-29 21:05 ` Eric Dumazet
2010-10-29 21:57 ` Davide Libenzi
2010-10-29 22:08 ` Eric Dumazet
2010-10-30 9:53 ` Eric Dumazet [this message]
2010-10-30 17:45 ` [PATCH] af_unix: optimize unix_dgram_poll() Davide Libenzi
2010-10-29 20:20 ` [PATCH 0/1] RFC: poll/select performance on datagram sockets Jesper Juhl
2010-10-29 20:40 ` David Miller
2010-10-29 20:45 ` Eric Dumazet
2010-10-30 6:44 ` [PATCH] af_unix: unix_write_space() use keyed wakeups Eric Dumazet
2010-10-30 15:03 ` Davide Libenzi
2010-11-08 21:44 ` David Miller
2010-10-30 21:36 ` Alban Crequy
[not found] ` <1290554876.2158.5.camel@Nokia-N900-51-1>
2010-11-24 0:20 ` Alban Crequy
2010-11-24 0:28 ` Eric Dumazet
2010-10-30 11:34 ` [PATCH 0/1] RFC: poll/select performance on datagram sockets Alban Crequy
2010-10-30 12:53 ` Eric Dumazet
2010-10-30 13:17 ` Eric Dumazet
[not found] ` <20101030224703.065e70f6@chocolatine.cbg.collabora.co.uk>
2010-10-31 15:36 ` [PATCH 1/2] af_unix: fix unix_dgram_poll() behavior for EPOLLOUT event Eric Dumazet
2010-10-31 19:07 ` Davide Libenzi
2010-11-08 21:44 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1288432420.2680.933.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=adobriyan@gmail.com \
--cc=alban.crequy@collabora.co.uk \
--cc=davem@davemloft.net \
--cc=davidel@xmailserver.org \
--cc=gorcunov@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pauli.nieminen@collabora.co.uk \
--cc=rweikusat@mssgmbh.com \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox