Received: by 10.223.176.46 with SMTP id f43csp3338740wra; Mon, 22 Jan 2018 12:23:09 -0800 (PST) X-Google-Smtp-Source: AH8x226aOjmBB7Olb01c492EioMEODQ5q0zOj1r9YbEUoNd1tHV3wYHFsijE5cdnaxTs+SHGXjE3 X-Received: by 10.36.243.7 with SMTP id t7mr9603ith.139.1516652589911; Mon, 22 Jan 2018 12:23:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516652589; cv=none; d=google.com; s=arc-20160816; b=Vmihdoaji4srxQF3cFped0v9JmWHOGEEqFCLvMdvuZDOeRwKpXRa3hebyWFQxORt3R zVuZQdLCQeVn9uTDXNLSBjaaYFAP5QAXccm0Jlfko8ueQYNLQ6Voa9vlgtlu9YSRCquj YWXYF8XlPiYBge6klkD9h7Wqm/h+Q3rwS/9C0cP1V3XQmGFy1Qy8eiNmtAF5baLspope PqJc1kez6KPrlcGD+z7b7yFN2byDyI4qCnuHWOKZTmkfhINarNv0HLOmekHhZX3zERd0 0Zrl63f6VbZmtK1z8hm9TUt5eZMEECJJupQfERlKV0Q28IradK82wkWjqLGgD2eWNu0G DCJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=C8QX4F2mYgUDDhM92GYLQVcsSo0kNdYCg2uw9ebfCig=; b=WnZ1ud/ZdAlKHdqhtHJBAH0RfUWt8H+7saipJ5VVsTSGVgsK9t7lhq5pPf41PufArW gaoAL88uZOCQ7lUjHnATC86p1SqUVnxIys3B6LGInZNOaEkMX0xyiIp/coOZ+AllaidG OoQJkNmquEX590Q0FIoOPvtWHOfQGD5L/zfFKq7RZDyoTh0CvG/3OdsEudODHSh2NsZQ F3hJ3WwnfMNJCq1FxXp3FK2I6p1zslBLLtk4DFgP8GgKaNGVjvVPE36GFpFF5TlUz1WF p5FnD4ZGFeLdvLQOfM2kRNU1CrcXHE8XNv9nLgxSvOKbFHBX+YlexgmeGpdM0VY2Dxdc sQoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZQvnO/aW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k66si6524149ita.171.2018.01.22.12.22.56; Mon, 22 Jan 2018 12:23:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZQvnO/aW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751653AbeAVUNu (ORCPT + 99 others); Mon, 22 Jan 2018 15:13:50 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:48113 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751632AbeAVUNr (ORCPT ); Mon, 22 Jan 2018 15:13:47 -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=ZQvnO/aWaxc09SladWWE7hcWw xBa0xmL8DkJD9OPYtiyLuTnVq03adNoQDXg/dxD/JuZnqDKrcWQShWNh6RUPhMkeUkLlzKwKPx5pj LVprf4NOIsasMehgXq2OG30QeZtG7NN8fMjyphaacOvBUpP0mUnB3s3OZS2gw/TlydZL9QCLPc91P Nw+kHLP0ErAb3n1FqDw4LuK9lsvgHEuULaHBajh2mcnpfLIPM0i57OZJAXCU5f7mW/zjREukNh2rs jYsCgbYE3T8YwBxasPXuPHDp4whNs+q2qSuBYFtM2etTmmd9skIzlMld5GKLAcgwxeZ5/6VlkmjTT FvbWKhkkQ==; Received: from 178.114.226.247.wireless.dyn.drei.com ([178.114.226.247] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1ediTQ-0007eg-SG; Mon, 22 Jan 2018 20:13:45 +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: Mon, 22 Jan 2018 21:12:25 +0100 Message-Id: <20180122201243.31610-19-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180122201243.31610-1-hch@lst.de> References: <20180122201243.31610-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.14.2