lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 31 Oct 2010 16:38:25 +0100
From:	Eric Dumazet <>
To:	David Miller <>
Cc:	netdev <>,
	Davide Libenzi <>,
	Alban Crequy <>
Subject: [PATCH 2/2] 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

On a test program provided by Alan Crequy :


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


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

Suggested-by: Davide Libenzi <>
Reported-by: Alban Crequy <>
Acked-by: Davide Libenzi <>
Signed-off-by: Eric Dumazet <>
 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) {

To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to
More majordomo info at

Powered by blists - more mailing lists