From patchwork Fri Jun 23 22:54:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36AC0C0015E for ; Fri, 23 Jun 2023 22:55:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12E0B8D0003; Fri, 23 Jun 2023 18:55:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B6BC8D0001; Fri, 23 Jun 2023 18:55:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E71C38D0003; Fri, 23 Jun 2023 18:55:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D7E988D0001 for ; Fri, 23 Jun 2023 18:55:32 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A1A9EA0332 for ; Fri, 23 Jun 2023 22:55:32 +0000 (UTC) X-FDA: 80935520904.05.49DC454 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id BF51A80006 for ; Fri, 23 Jun 2023 22:55:30 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OYqBxrVc; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560930; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+rBMqYSyv/4ZPCkVQAGQaA6Fc9mkJmC9WKrulhUVyYg=; b=HFy7St/hFV7y9qbkyLDTWQcBmmJQxiThHPy55dGR3va2kz5TxEvV6byiPcXbm/ksflgCus EThP3Nqo/orMZUlmZ0ekQnU5bHsGj996t/4oURSX6y+tXrc8bZy9e1j3p/cN4kBV+ndQMc 6om1JZc5y69e579liG4LPzpEZaIP8u4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560930; a=rsa-sha256; cv=none; b=FjEthiTVASVrAh5oJAGYQ7/ljQ5Z+I4EfWQ6oc7iyn8MqugNRJPPbfktSOw7JD4nUC0aFP AH6FJCwsfigMn3OBhttkCohHSNeVIUhJ9eA85nmYnY1WvwHup2lM33DnW4fw/cI+ug7rH4 gbqfFEu+sRwrHqAPIjtQt987QS/FYC4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OYqBxrVc; spf=pass (imf02.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+rBMqYSyv/4ZPCkVQAGQaA6Fc9mkJmC9WKrulhUVyYg=; b=OYqBxrVcXd+46JJJo3T1o0CoiTRkcFRblOjX69jHcAs4zXT/4Zq4w1BAM5JN+KKzDtPk2m oEhf+qTPxnOaoopiVrOkxU77T4fneYSlWkPzRRqYdXsbQ20QJlxYYoeh4K764xHVcuEvSt o8MsyCG8EImOUfIvdbGLAAbKvSa4ytY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-XZyhTNHGPUuH2-31Her6VQ-1; Fri, 23 Jun 2023 18:55:24 -0400 X-MC-Unique: XZyhTNHGPUuH2-31Her6VQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA74E185A78F; Fri, 23 Jun 2023 22:55:22 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 518A01121314; Fri, 23 Jun 2023 22:55:19 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Bernard Metzler , Jason Gunthorpe , Leon Romanovsky , John Fastabend , Jakub Sitnicki , Karsten Graul , Wenjia Zhang , Jan Karcher , "D. Wythe" , Tony Lu , Wen Gu , Boris Pismenny , Steffen Klassert , Herbert Xu , bpf@vger.kernel.org, linux-s390@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH net-next v5 01/16] tcp_bpf, smc, tls, espintcp, siw: Reduce MSG_SENDPAGE_NOTLAST usage Date: Fri, 23 Jun 2023 23:54:58 +0100 Message-ID: <20230623225513.2732256-2-dhowells@redhat.com> In-Reply-To: <20230623225513.2732256-1-dhowells@redhat.com> References: <20230623225513.2732256-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: BF51A80006 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 9oczku4dp9nudwxu3n33oqmhckf3p88g X-HE-Tag: 1687560930-197992 X-HE-Meta: U2FsdGVkX19sEovxC5UjSuTSnZ3zB75gPF2kAOhk6dbCCXq8+nZdcm2f/usqMKrXyxSeviwAAxye9AASfUQgX1K2p/nQyGrLOMIjGOj3bjgfTd3iVASmofZ/iz0zVkwpbXUGnww+e1Oy8i31Y3gH19Iy8unZbRyMGco/JDeyvUaB8aTknmqXWcpkwM409YEvJhrxqFsrRhfvu4TwZ83QO4eOsrv77ADBYpxerxhaDPc6/PMjsNSWGHqUgC9lafChitMjaSSbU9IIFbWjzwkCzh674NhToi4qNXEzkxwd/BRyUAYcrCc6RM1pjEu02vQy2Pd8qkvl5XanWCUfS3RY91w75o7ylK5o6f7thoQLqRv0qGFzl1t5fFcNxhyYbRRSxv5aNZnxIhXlOrutd4aUmuFYoZmHvQcPr1i4W8FMBu6iQggg/qTc7ppr2K1uHSyXv5Tv1XaKhaprjU7a8A+FbhpnKltDxKzla0/G+1So/GLv7OPD499xZdmTM9mV+F0sGeC8eVzo8+LT3rvimW1cWcjJr0KbFN3INyHqXAU6lz91fNxNuRzRbo6qKCExyaAMyBIUDmvF0+T4FQVMHR993phLS47zKpzPw4zJKj23540tdq19CM9mc1smUKzx/AtKAPReFgPrt71HTnxz0iCfqVVK2DcCoVN5JGRMoK0+VNZNJh/85QYFR3rFuBBzzpqBilSrMmg+r06fSdS4tJutvY6oR9cWWkgggl/XCI4yrc+MXFA2Y2AAJMMZsjw0VM+786SUTvAFtODTvyMn1zegvBvvlZi9A94ZbBm7yisGQaPy6hhq/lazDXvj2SiWJ02JV/Bced7GSowx9YBNbpGG3CLnm/MZUpF2XwWIDa+iDJELZY2a6WAeYl0b7YkYacerw/cRxIRkNrARgQrvJNAUWmZXXaX3QjSeMHDrkGeLAU9G2+gIyeRnKayevDvWet6vAljaUqaa8MAv+KvAgq1 iZ1/xgW0 j5TXVSyXNsHCk8Nk83bmMD4jWL26qYhPel9OPb3AjUMUulvJ+jLiIwlVM3wOugENyMkohQEhyI+18KL+rYKqyRJYI7n/K1oJGdqkIUbzrKPndSZNuMRdrxgH7pyRZeVXiavsCxlnI46EYDWea6fM0vYsLgETJmxO7MJGvxG+3tROjcZRXPbUge52XWzY7pBXiES2l2DAWAI6BZdEzxRVSwagK3WxW69d82qG+x9mJj4oy81Qauzbt72hiPWhsjPG5aXqvIuhFZLz5pPNdex3nWs7VCSoeEXPZBH9QQ0XwKHzyyYEkxzppKBW2TaD1wigoLp/kIA55TqlUCHdJp8dNtZy84T4zZnM+w0fbYjf5jLO1VYyopoCYzyugTcw9DmvhjLuY0qtsLjFu9RHPP7LvWrWoqzs+6/Dwa7OCiyliC7bEv50uQQEXiJx19Z2QN88EQ6GOymvhjIEKKG3Pv6AyX6poeGjpnMJiJ8cP64FLg3zoJrVGXEYhPcEDYSyiTun/MDhxhWDhvsPVSeJZt3gwfVvhAnrIdt1S49fBfA6T/A+RlvbuzSbls50wCAv5QwFQFwz8J6hIXKRLgM3vSs0M7LRZmKxN9jQPApEt/lxi7LCc76gCir1jkrRBFswJmxSCzSZzHWT84lH8c2bEmf+DJZ0YAkbRW6WdRjo+EuiidEi3DBnnyAFkMxoYo7yE80o6s/GrHFUbSxjpQ6VaiA1pyZupMgbCcY6/mkr1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: As MSG_SENDPAGE_NOTLAST is being phased out along with sendpage(), don't use it further in than the sendpage methods, but rather translate it to MSG_MORE and use that instead. Signed-off-by: David Howells cc: Willem de Bruijn cc: Bernard Metzler cc: Jason Gunthorpe cc: Leon Romanovsky cc: John Fastabend cc: Jakub Sitnicki cc: Eric Dumazet cc: "David S. Miller" cc: David Ahern cc: Jakub Kicinski cc: Paolo Abeni cc: Karsten Graul cc: Wenjia Zhang cc: Jan Karcher cc: "D. Wythe" cc: Tony Lu cc: Wen Gu cc: Boris Pismenny cc: Steffen Klassert cc: Herbert Xu cc: netdev@vger.kernel.org cc: bpf@vger.kernel.org cc: linux-s390@vger.kernel.org cc: linux-rdma@vger.kernel.org --- Notes: ver #3) - In tcp_bpf, reset msg_flags on each iteration to clear MSG_MORE. - In tcp_bpf, set MSG_MORE if there's more data in the sk_msg. drivers/infiniband/sw/siw/siw_qp_tx.c | 5 ++--- net/ipv4/tcp_bpf.c | 5 +++-- net/smc/smc_tx.c | 6 ++++-- net/tls/tls_device.c | 4 ++-- net/xfrm/espintcp.c | 10 ++++++---- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c index ffb16beb6c30..7c7a51d36d0c 100644 --- a/drivers/infiniband/sw/siw/siw_qp_tx.c +++ b/drivers/infiniband/sw/siw/siw_qp_tx.c @@ -325,8 +325,7 @@ static int siw_tcp_sendpages(struct socket *s, struct page **page, int offset, { struct bio_vec bvec; struct msghdr msg = { - .msg_flags = (MSG_MORE | MSG_DONTWAIT | MSG_SENDPAGE_NOTLAST | - MSG_SPLICE_PAGES), + .msg_flags = (MSG_MORE | MSG_DONTWAIT | MSG_SPLICE_PAGES), }; struct sock *sk = s->sk; int i = 0, rv = 0, sent = 0; @@ -335,7 +334,7 @@ static int siw_tcp_sendpages(struct socket *s, struct page **page, int offset, size_t bytes = min_t(size_t, PAGE_SIZE - offset, size); if (size + offset <= PAGE_SIZE) - msg.msg_flags &= ~MSG_SENDPAGE_NOTLAST; + msg.msg_flags &= ~MSG_MORE; tcp_rate_check_app_limited(sk); bvec_set_page(&bvec, page[i], bytes, offset); diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 5a84053ac62b..31d6005cea9b 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -88,9 +88,9 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock, static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, int flags, bool uncharge) { + struct msghdr msghdr = {}; bool apply = apply_bytes; struct scatterlist *sge; - struct msghdr msghdr = { .msg_flags = flags | MSG_SPLICE_PAGES, }; struct page *page; int size, ret = 0; u32 off; @@ -107,11 +107,12 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, tcp_rate_check_app_limited(sk); retry: + msghdr.msg_flags = flags | MSG_SPLICE_PAGES; has_tx_ulp = tls_sw_has_ctx_tx(sk); if (has_tx_ulp) msghdr.msg_flags |= MSG_SENDPAGE_NOPOLICY; - if (flags & MSG_SENDPAGE_NOTLAST) + if (size < sge->length && msg->sg.start != msg->sg.end) msghdr.msg_flags |= MSG_MORE; bvec_set_page(&bvec, page, size, off); diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c index 45128443f1f1..9b9e0a190734 100644 --- a/net/smc/smc_tx.c +++ b/net/smc/smc_tx.c @@ -168,8 +168,7 @@ static bool smc_tx_should_cork(struct smc_sock *smc, struct msghdr *msg) * should known how/when to uncork it. */ if ((msg->msg_flags & MSG_MORE || - smc_tx_is_corked(smc) || - msg->msg_flags & MSG_SENDPAGE_NOTLAST) && + smc_tx_is_corked(smc)) && atomic_read(&conn->sndbuf_space)) return true; @@ -306,6 +305,9 @@ int smc_tx_sendpage(struct smc_sock *smc, struct page *page, int offset, struct kvec iov; int rc; + if (flags & MSG_SENDPAGE_NOTLAST) + msg.msg_flags |= MSG_MORE; + iov.iov_base = kaddr + offset; iov.iov_len = size; iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &iov, 1, size); diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index b82770f68807..975299d7213b 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -449,7 +449,7 @@ static int tls_push_data(struct sock *sk, return -sk->sk_err; flags |= MSG_SENDPAGE_DECRYPTED; - tls_push_record_flags = flags | MSG_SENDPAGE_NOTLAST; + tls_push_record_flags = flags | MSG_MORE; timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); if (tls_is_partially_sent_record(tls_ctx)) { @@ -532,7 +532,7 @@ static int tls_push_data(struct sock *sk, if (!size) { last_record: tls_push_record_flags = flags; - if (flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE)) { + if (flags & MSG_MORE) { more = true; break; } diff --git a/net/xfrm/espintcp.c b/net/xfrm/espintcp.c index 3504925babdb..d3b3f9e720b3 100644 --- a/net/xfrm/espintcp.c +++ b/net/xfrm/espintcp.c @@ -205,13 +205,15 @@ static int espintcp_sendskb_locked(struct sock *sk, struct espintcp_msg *emsg, static int espintcp_sendskmsg_locked(struct sock *sk, struct espintcp_msg *emsg, int flags) { - struct msghdr msghdr = { .msg_flags = flags | MSG_SPLICE_PAGES, }; + struct msghdr msghdr = { + .msg_flags = flags | MSG_SPLICE_PAGES | MSG_MORE, + }; struct sk_msg *skmsg = &emsg->skmsg; + bool more = flags & MSG_MORE; struct scatterlist *sg; int done = 0; int ret; - msghdr.msg_flags |= MSG_SENDPAGE_NOTLAST; sg = &skmsg->sg.data[skmsg->sg.start]; do { struct bio_vec bvec; @@ -221,8 +223,8 @@ static int espintcp_sendskmsg_locked(struct sock *sk, emsg->offset = 0; - if (sg_is_last(sg)) - msghdr.msg_flags &= ~MSG_SENDPAGE_NOTLAST; + if (sg_is_last(sg) && !more) + msghdr.msg_flags &= ~MSG_MORE; p = sg_page(sg); retry: