From patchwork Fri Jun 23 11:44:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13290401 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 7F095C0015E for ; Fri, 23 Jun 2023 11:44:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6748C8D0003; Fri, 23 Jun 2023 07:44:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64A168D0001; Fri, 23 Jun 2023 07:44:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5118A8D0003; Fri, 23 Jun 2023 07:44:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 42BA58D0001 for ; Fri, 23 Jun 2023 07:44:44 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 112AA80F08 for ; Fri, 23 Jun 2023 11:44:44 +0000 (UTC) X-FDA: 80933830488.19.4033E72 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id C1B2540005 for ; Fri, 23 Jun 2023 11:44:40 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H4hJL5Rj; spf=pass (imf07.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=1687520680; 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=ivhWzudgyaDY8ijkLDZpWPEWsQie4rsiJhQ0Ls+XdqI=; b=6nqEEJ6W05t2xL/4K1moktI/QEQla+3xMy/evwgKxrJbABkC4+nn0LnOIgpraiEgUu0+rE SYUyJQzRSV4nfYqB2Lihs727B3KDhVaghQdpHrPS0Hvpt5s5yOF/BoslXz07/KcMSYebhn wNMmBx4S/Eql3pFZOyAVeX8V2RgEIDI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687520680; a=rsa-sha256; cv=none; b=M9CucJs4Hy9sUaKW2mKWaBBxcMJoCxXXowLgJYu4lEcebiZ068IqQPjcS2Z24CA7E4Rpla VuejqYUIWUVvLP8iGfW+1VpEM//Is+hHba+vn0ZajI9jfUJryW/eVPa5ny6oYwIH/Opmbg HoojVRNd2G+xYmOj3zK7whMkv7QYIiA= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H4hJL5Rj; spf=pass (imf07.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=1687520680; 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=ivhWzudgyaDY8ijkLDZpWPEWsQie4rsiJhQ0Ls+XdqI=; b=H4hJL5RjAdlViedPr81FLTq/UWdebsfe/jwFc4GVnkNgcJ2icgOCoMEqk2Mw13bGLX6rYc PEFAXSzCmhei4zVcVS8UhIUVHPkUXpppmUqV9hzMOqvuaFCfOa/SLkrpfqwVexmh/yOE2Y K99u3a9oNTDiBxpfIzK08+0SWmvY6xo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-PFLeHdiDMpWe9Zuq8IfeUA-1; Fri, 23 Jun 2023 07:44:34 -0400 X-MC-Unique: PFLeHdiDMpWe9Zuq8IfeUA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 419AB38149A6; Fri, 23 Jun 2023 11:44:33 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C9611400C35; Fri, 23 Jun 2023 11:44:30 +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, 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 Subject: [PATCH net-next v4 01/15] tcp_bpf, smc, tls, espintcp, siw: Reduce MSG_SENDPAGE_NOTLAST usage Date: Fri, 23 Jun 2023 12:44:11 +0100 Message-ID: <20230623114425.2150536-2-dhowells@redhat.com> In-Reply-To: <20230623114425.2150536-1-dhowells@redhat.com> References: <20230623114425.2150536-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Stat-Signature: ks7ufh747jufoyszg9ajnqoo8puisoo5 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C1B2540005 X-Rspam-User: X-HE-Tag: 1687520680-952919 X-HE-Meta: U2FsdGVkX19Em0XphTtBjlR9828Y29WIjKiVNsCHJnnWnLAZXFsYOrLmMRHCzAG+qiJ0/EBLw8hZI1ZlPW9UPw37XbPB1eTEhdyzArxcCuIsRm6bCMIivi1TLp1Y5a8sS+AeU7n8/LGvqdXq7EkicPIdvji0JCAY3hwqOmffgezpuZ8kvru2XF0zoi80GsTWHfedjgayPePPYNkeBOK/EkkLXOdlJf3Bil81IiGKhLsAeArgBDYW72vsBjqyhj+A+DcNbBVYs0yrxFk/wkkyJjw226vtRgiclWvhrmaQz1rsWjZ8wlCLu5Hs7MHntSAgBbTbeHKMl96/Zp2uru+5hYipSvTh3LehrqW1B6NVMLBxiHdM6LtNidz2lwxJXXP89OFj8SzCxnD6CJfDwaYOetHz9AIFB8wetMY4wB6g5hLD8GMYfsCJPWUpq4zqPQUy76Ki9ity0NIGgC1GN/mUKdWiPeswW+r+uJCXkOjHjyrancy9/ipULgbcWwJPG3grCw58Hkv+m53qBcwqDDV9tIvuLvm2JqEn+1dkCW65gTZI4G+13DOLTh8b8LGq+H60L48AhNyzeadbp9E2xZ0RUGezGrdlfrG2rsPkR3TkVGA6o0PCGSW0/FSPOd2A66/mLR5geLWpwMh98NKni753azqxWKoTCFckHZZJxueXlh56JgyTNMm9I1PtHQt3zrDZCu/7hsrOiviJdna9lMOx4fuA/dkly4YxazVE5crh0K8DWmhYEuX0SixYP+sfEtqev7KwFRi+55USbbMrDf5sLm2SM0SGxYXwJWuwsnoH/2zYU9QlZVsjGP9wvjETbqtHlM5L9OzESqBxGACT881IUfDZ9XMEZaDI8YYk/gUqUeaiRQulvqs8yeohS0YdKAWdFqYEPxLS2qAkL8ylGolGVC9NL8Vp0BBNRNV8hc6TpL+h17KQKK1AvKz0XLSMUHn/VhCZmWkBG1Xriy+0fje xYqinzEy FNQX3FXMKgZeiPVdbCVB0HFHeMITPHF/Ujy4ZW5p+k9kWqLDt3nhH4aBkNz0RMpI0AmfQQSXeOpgt+w1mKkysEnwJAhaKfpAtYRO3TH8sq4d4Jos6TQyKI/qZtV367EQZwdaGkeui7b0teTVyv7I/vHGVhaSeWAAF6/eeFLl8RHThAeOPE5Tt5DRJtgWVHr+fKCTeLQw6SBcyse18H46by0FYdIiZrD+3U3YAqoVUio/ZR5amvrMV4Gp+bEuokP27nynCYEzDJqCeU24aOe10G47X1PD2aMtIzKJwFvahz/zUd0OkBwaUQpZfUUiWCJbk/F/I2uXi/Bzpx7ucVgayeHybppkvrj9lkzlekoqibJdseZUv1StkMh5E5CkC3ko9OvzGPJ7yyU8/LNrihIBwqcAdWvubgX8LJmUw9saz9hBeLBBCpX9aWBkmNSH4Src5BMrWN2KtWqWsmXHvppb8/nrz+uuvOiCuX7xrtP/JxKO5HPEHvC7mZr+p0DMvcR7C6+Dzw3xPV7nEO0gjUBYai3f3HA7dQ1pITWQd/y7KgNT+A+g9RKmGD7utPXGbWWinzOKMYA2MaGed2/EokIFIkNrl4gg5HOLvHxUH3nHSuRvr5HneK7jYXDwwXlzfgaOk+fTciqDXGgVCW0vnnwW31Ped7YUmHCOyWfNc 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: 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 --- 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: