From patchwork Wed Jan 17 19:27:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10170579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B33D260386 for ; Wed, 17 Jan 2018 19:36:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2FE9204C3 for ; Wed, 17 Jan 2018 19:36:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97F27204FA; Wed, 17 Jan 2018 19:36:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12336204C3 for ; Wed, 17 Jan 2018 19:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753750AbeAQT2v (ORCPT ); Wed, 17 Jan 2018 14:28:51 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:38097 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753732AbeAQT2s (ORCPT ); Wed, 17 Jan 2018 14:28:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=C8QX4F2mYgUDDhM92GYLQVcsSo0kNdYCg2uw9ebfCig=; b=apwLKoTJvPLe5g9gzPg9xatyK 7TPa4ufa2YHjHmQowSa7z1Oqra2gMthR0fLyUvD4aNPpJIp7I0LzAVqW/q49AYM2c6JSaO3Z3RGTd D/7HM6FNZx/1lpI3v6xSZ1orE5k8MCNhdq5RqOFr8EldFNgn4BMvGqmMpov9ZbJPgL+pddRXZ0lao o92H8awk8eC0ltp7GO66iWIgDP4cP+loU1u2fOj75GWE+SexKn8+5RUioj2e+h1bChBUFXadu97pB d/TCIFlZ2VhHSXOEtqRWD1xhvB9EqbNVUNbHuJ2gC0ohdfoPaQYKlr0SP5NhudUDcOmCjRTn7MfNv I2wK2NBbw==; Received: from 77.117.185.35.wireless.dyn.drei.com ([77.117.185.35] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1ebtOA-00036t-P5; Wed, 17 Jan 2018 19:28:47 +0000 From: Christoph Hellwig To: viro@zeniv.linux.org.uk Cc: Avi Kivity , linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/36] net/tcp: convert to ->poll_mask Date: Wed, 17 Jan 2018 20:27:24 +0100 Message-Id: <20180117192742.710-19-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180117192742.710-1-hch@lst.de> References: <20180117192742.710-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig --- include/net/tcp.h | 4 ++-- net/ipv4/af_inet.c | 3 ++- net/ipv4/tcp.c | 33 ++++++++++++++------------------- net/ipv6/af_inet6.c | 3 ++- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 50b21a49d870..75b3ce444b1c 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -387,8 +387,8 @@ bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst); void tcp_close(struct sock *sk, long timeout); void tcp_init_sock(struct sock *sk); void tcp_init_transfer(struct sock *sk, int bpf_op); -__poll_t tcp_poll(struct file *file, struct socket *sock, - struct poll_table_struct *wait); +struct wait_queue_head *tcp_get_poll_head(struct socket *sock, __poll_t events); +__poll_t tcp_poll_mask(struct socket *sock, __poll_t events); int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); int tcp_setsockopt(struct sock *sk, int level, int optname, diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index f00499a46927..2a362198a03e 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -934,7 +934,8 @@ const struct proto_ops inet_stream_ops = { .socketpair = sock_no_socketpair, .accept = inet_accept, .getname = inet_getname, - .poll = tcp_poll, + .get_poll_head = tcp_get_poll_head, + .poll_mask = tcp_poll_mask, .ioctl = inet_ioctl, .listen = inet_listen, .shutdown = inet_shutdown, diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index c4a7ee7f6721..4d88c765cfcc 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -486,35 +486,30 @@ static void tcp_tx_timestamp(struct sock *sk, u16 tsflags) } } +struct wait_queue_head *tcp_get_poll_head(struct socket *sock, __poll_t events) +{ + sock_poll_busy_loop(sock, events); + sock_rps_record_flow(sock->sk); + return sk_sleep(sock->sk); +} +EXPORT_SYMBOL(tcp_get_poll_head); + /* - * Wait for a TCP event. - * - * Note that we don't need to lock the socket, as the upper poll layers - * take care of normal races (between the test and the event) and we don't - * go look at any of the socket buffers directly. + * Socket is not locked. We are protected from async events by poll logic and + * correct handling of state changes made by other threads is impossible in + * any case. */ -__poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait) +__poll_t tcp_poll_mask(struct socket *sock, __poll_t events) { - __poll_t mask; struct sock *sk = sock->sk; const struct tcp_sock *tp = tcp_sk(sk); + __poll_t mask = 0; int state; - sock_rps_record_flow(sk); - - sock_poll_wait(file, sk_sleep(sk), wait); - state = sk_state_load(sk); if (state == TCP_LISTEN) return inet_csk_listen_poll(sk); - /* Socket is not locked. We are protected from async events - * by poll logic and correct handling of state changes - * made by other threads is impossible in any case. - */ - - mask = 0; - /* * POLLHUP is certainly not done right. But poll() doesn't * have a notion of HUP in just one direction, and for a @@ -595,7 +590,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait) return mask; } -EXPORT_SYMBOL(tcp_poll); +EXPORT_SYMBOL(tcp_poll_mask); int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg) { diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index c9441ca45399..cccbb6e6603a 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -544,7 +544,8 @@ const struct proto_ops inet6_stream_ops = { .socketpair = sock_no_socketpair, /* a do nothing */ .accept = inet_accept, /* ok */ .getname = inet6_getname, - .poll = tcp_poll, /* ok */ + .get_poll_head = tcp_get_poll_head, + .poll_mask = tcp_poll_mask, /* ok */ .ioctl = inet6_ioctl, /* must change */ .listen = inet_listen, /* ok */ .shutdown = inet_shutdown, /* ok */