aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-28 12:43:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-28 13:40:47 -0400
commita11e1d432b51f63ba698d044441284a661f01144 (patch)
tree9f3c5a10bf0d7f9a342d5fb39c0c35ea14170124 /net/unix
parentf57494321cbf5b1e7769b6135407d2995a369e28 (diff)
Revert changes to convert to ->poll_mask() and aio IOCB_CMD_POLL
The poll() changes were not well thought out, and completely unexplained. They also caused a huge performance regression, because "->poll()" was no longer a trivial file operation that just called down to the underlying file operations, but instead did at least two indirect calls. Indirect calls are sadly slow now with the Spectre mitigation, but the performance problem could at least be largely mitigated by changing the "->get_poll_head()" operation to just have a per-file-descriptor pointer to the poll head instead. That gets rid of one of the new indirections. But that doesn't fix the new complexity that is completely unwarranted for the regular case. The (undocumented) reason for the poll() changes was some alleged AIO poll race fixing, but we don't make the common case slower and more complex for some uncommon special case, so this all really needs way more explanations and most likely a fundamental redesign. [ This revert is a revert of about 30 different commits, not reverted individually because that would just be unnecessarily messy - Linus ] Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/unix')
-rw-r--r--net/unix/af_unix.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 95b02a71fd47..e5473c03d667 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -638,8 +638,9 @@ static int unix_stream_connect(struct socket *, struct sockaddr *,
638static int unix_socketpair(struct socket *, struct socket *); 638static int unix_socketpair(struct socket *, struct socket *);
639static int unix_accept(struct socket *, struct socket *, int, bool); 639static int unix_accept(struct socket *, struct socket *, int, bool);
640static int unix_getname(struct socket *, struct sockaddr *, int); 640static int unix_getname(struct socket *, struct sockaddr *, int);
641static __poll_t unix_poll_mask(struct socket *, __poll_t); 641static __poll_t unix_poll(struct file *, struct socket *, poll_table *);
642static __poll_t unix_dgram_poll_mask(struct socket *, __poll_t); 642static __poll_t unix_dgram_poll(struct file *, struct socket *,
643 poll_table *);
643static int unix_ioctl(struct socket *, unsigned int, unsigned long); 644static int unix_ioctl(struct socket *, unsigned int, unsigned long);
644static int unix_shutdown(struct socket *, int); 645static int unix_shutdown(struct socket *, int);
645static int unix_stream_sendmsg(struct socket *, struct msghdr *, size_t); 646static int unix_stream_sendmsg(struct socket *, struct msghdr *, size_t);
@@ -680,7 +681,7 @@ static const struct proto_ops unix_stream_ops = {
680 .socketpair = unix_socketpair, 681 .socketpair = unix_socketpair,
681 .accept = unix_accept, 682 .accept = unix_accept,
682 .getname = unix_getname, 683 .getname = unix_getname,
683 .poll_mask = unix_poll_mask, 684 .poll = unix_poll,
684 .ioctl = unix_ioctl, 685 .ioctl = unix_ioctl,
685 .listen = unix_listen, 686 .listen = unix_listen,
686 .shutdown = unix_shutdown, 687 .shutdown = unix_shutdown,
@@ -703,7 +704,7 @@ static const struct proto_ops unix_dgram_ops = {
703 .socketpair = unix_socketpair, 704 .socketpair = unix_socketpair,
704 .accept = sock_no_accept, 705 .accept = sock_no_accept,
705 .getname = unix_getname, 706 .getname = unix_getname,
706 .poll_mask = unix_dgram_poll_mask, 707 .poll = unix_dgram_poll,
707 .ioctl = unix_ioctl, 708 .ioctl = unix_ioctl,
708 .listen = sock_no_listen, 709 .listen = sock_no_listen,
709 .shutdown = unix_shutdown, 710 .shutdown = unix_shutdown,
@@ -725,7 +726,7 @@ static const struct proto_ops unix_seqpacket_ops = {
725 .socketpair = unix_socketpair, 726 .socketpair = unix_socketpair,
726 .accept = unix_accept, 727 .accept = unix_accept,
727 .getname = unix_getname, 728 .getname = unix_getname,
728 .poll_mask = unix_dgram_poll_mask, 729 .poll = unix_dgram_poll,
729 .ioctl = unix_ioctl, 730 .ioctl = unix_ioctl,
730 .listen = unix_listen, 731 .listen = unix_listen,
731 .shutdown = unix_shutdown, 732 .shutdown = unix_shutdown,
@@ -2629,10 +2630,13 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
2629 return err; 2630 return err;
2630} 2631}
2631 2632
2632static __poll_t unix_poll_mask(struct socket *sock, __poll_t events) 2633static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wait)
2633{ 2634{
2634 struct sock *sk = sock->sk; 2635 struct sock *sk = sock->sk;
2635 __poll_t mask = 0; 2636 __poll_t mask;
2637
2638 sock_poll_wait(file, sk_sleep(sk), wait);
2639 mask = 0;
2636 2640
2637 /* exceptional events? */ 2641 /* exceptional events? */
2638 if (sk->sk_err) 2642 if (sk->sk_err)
@@ -2661,11 +2665,15 @@ static __poll_t unix_poll_mask(struct socket *sock, __poll_t events)
2661 return mask; 2665 return mask;
2662} 2666}
2663 2667
2664static __poll_t unix_dgram_poll_mask(struct socket *sock, __poll_t events) 2668static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
2669 poll_table *wait)
2665{ 2670{
2666 struct sock *sk = sock->sk, *other; 2671 struct sock *sk = sock->sk, *other;
2667 int writable; 2672 unsigned int writable;
2668 __poll_t mask = 0; 2673 __poll_t mask;
2674
2675 sock_poll_wait(file, sk_sleep(sk), wait);
2676 mask = 0;
2669 2677
2670 /* exceptional events? */ 2678 /* exceptional events? */
2671 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) 2679 if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
@@ -2691,7 +2699,7 @@ static __poll_t unix_dgram_poll_mask(struct socket *sock, __poll_t events)
2691 } 2699 }
2692 2700
2693 /* No write status requested, avoid expensive OUT tests. */ 2701 /* No write status requested, avoid expensive OUT tests. */
2694 if (!(events & (EPOLLWRBAND|EPOLLWRNORM|EPOLLOUT))) 2702 if (!(poll_requested_events(wait) & (EPOLLWRBAND|EPOLLWRNORM|EPOLLOUT)))
2695 return mask; 2703 return mask;
2696 2704
2697 writable = unix_writable(sk); 2705 writable = unix_writable(sk);