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: From patchwork Fri Jun 23 22:54:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291440 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 4AE08EB64D7 for ; Fri, 23 Jun 2023 22:55:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CE5F8D0002; Fri, 23 Jun 2023 18:55:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 857898D0001; Fri, 23 Jun 2023 18:55:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F8488D0002; Fri, 23 Jun 2023 18:55:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5CE788D0001 for ; Fri, 23 Jun 2023 18:55:32 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 34058120363 for ; Fri, 23 Jun 2023 22:55:32 +0000 (UTC) X-FDA: 80935520904.10.4295868 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 7840318000C for ; Fri, 23 Jun 2023 22:55:30 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Oek+srM1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@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=96le6Nv7f7Jm2em1nCUehde2Ld5Ng9GbgAM0NyDY2H8=; b=q7rfaWjsuCdZVcdzjRPG36Xr31iHqIjyQtPHGcGKI/JDlPmsz++gTzX30iYUO8P09FZl41 un7J9Yp4yegoqCzPw0GYIxlVFXZxxGg+CwvKDz/PpxWhcEkiNFtJnP7ApZZc9gte/TbMpF KwUF/pTYxDBJ+Tt0kG9jrJgXYTIqawQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Oek+srM1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560930; a=rsa-sha256; cv=none; b=6XPCZMtijFAanF/o98BDqxzLInKpKcDYQdwoZfcfOM1Cp+EkMBIEvb5h9Xnn6G1M/vPw/X 5WShF5QjshOCtj5MfxBS8EmjGPHSyVooIoUqwvIobjrgRyQstALFGzLcYT3xjB5qgpdnzn dDlh64vTIC+DDJf2ZurUh6CmGv8ArzU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560929; 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=96le6Nv7f7Jm2em1nCUehde2Ld5Ng9GbgAM0NyDY2H8=; b=Oek+srM1zbfm4Miuvbv7fiEtVg0XpY8DSt9sjN0wVB0vPGBvRxM38nnKAmgugmqZ7c3uNm sTfIO+NP/vnr7fVrY9osxg4GFgYs+KEM8WawHQD6a6Sd3B/cXlvoL2mFhkcGf4TlbwDBad 03gHCKrT6xWDn0CmggHIA1RkukL2VOw= 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-470-JAj_tgg_MAmagZcoZ9ODJA-1; Fri, 23 Jun 2023 18:55:25 -0400 X-MC-Unique: JAj_tgg_MAmagZcoZ9ODJA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C11F21C05ED2; Fri, 23 Jun 2023 22:55:24 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 594DEF5ADA; Fri, 23 Jun 2023 22:55:23 +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 Subject: [PATCH net-next v5 02/16] net: Use sendmsg(MSG_SPLICE_PAGES) not sendpage in skb_send_sock() Date: Fri, 23 Jun 2023 23:54:59 +0100 Message-ID: <20230623225513.2732256-3-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.5 X-Rspamd-Queue-Id: 7840318000C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 1zw1en8hwrsshkda4m6qamjwf49gu8fd X-HE-Tag: 1687560930-176707 X-HE-Meta: U2FsdGVkX1/Rb/KTwFrQHfyh09QFHOjWpykBaBz7cL5HikeCkmsHe8qjAblMgQ1cDv5D+ea8SSiIL5mjQKsYAnIBP7LPWSOpAzSGDgmbDu6XRjNUs96EwdDfmrFEK4ds6B1nuWQRtXEIscbeLq3/8a7AE+iwyJnFeziADXd/65204tAlN5M9tRPjn+0BgZ5sYk+L+xh4J1jLYFVOY6pkN/W/nlscqlcvGwbBLKjooGRjQGHUX/5bGebh8eBc0Lbv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+g2hkJADxBb47nVheEobzlSgPjWqSjSdNbLnDoiKvlpw3K+3oRqmbZEqjhur+6s3G+ILHYjXb8CDTwXP8pZdNgujbaOtkLosneZo6DWslhSNPBurv7qjc7X3DzxUTCA+rnqkRBaPa3Zrgg== 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: Use sendmsg() with MSG_SPLICE_PAGES rather than sendpage in skb_send_sock(). This causes pages to be spliced from the source iterator if possible. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Note that this could perhaps be improved to fill out a bvec array with all the frags and then make a single sendmsg call, possibly sticking the header on the front also. Signed-off-by: David Howells cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- Notes: ver #2) - Wrap lines at 80. net/core/skbuff.c | 50 ++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index fee2b1c105fe..6c5915efbc17 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2989,32 +2989,32 @@ int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset, } EXPORT_SYMBOL_GPL(skb_splice_bits); -static int sendmsg_unlocked(struct sock *sk, struct msghdr *msg, - struct kvec *vec, size_t num, size_t size) +static int sendmsg_locked(struct sock *sk, struct msghdr *msg) { struct socket *sock = sk->sk_socket; + size_t size = msg_data_left(msg); if (!sock) return -EINVAL; - return kernel_sendmsg(sock, msg, vec, num, size); + + if (!sock->ops->sendmsg_locked) + return sock_no_sendmsg_locked(sk, msg, size); + + return sock->ops->sendmsg_locked(sk, msg, size); } -static int sendpage_unlocked(struct sock *sk, struct page *page, int offset, - size_t size, int flags) +static int sendmsg_unlocked(struct sock *sk, struct msghdr *msg) { struct socket *sock = sk->sk_socket; if (!sock) return -EINVAL; - return kernel_sendpage(sock, page, offset, size, flags); + return sock_sendmsg(sock, msg); } -typedef int (*sendmsg_func)(struct sock *sk, struct msghdr *msg, - struct kvec *vec, size_t num, size_t size); -typedef int (*sendpage_func)(struct sock *sk, struct page *page, int offset, - size_t size, int flags); +typedef int (*sendmsg_func)(struct sock *sk, struct msghdr *msg); static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, - int len, sendmsg_func sendmsg, sendpage_func sendpage) + int len, sendmsg_func sendmsg) { unsigned int orig_len = len; struct sk_buff *head = skb; @@ -3034,8 +3034,9 @@ static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, memset(&msg, 0, sizeof(msg)); msg.msg_flags = MSG_DONTWAIT; - ret = INDIRECT_CALL_2(sendmsg, kernel_sendmsg_locked, - sendmsg_unlocked, sk, &msg, &kv, 1, slen); + iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &kv, 1, slen); + ret = INDIRECT_CALL_2(sendmsg, sendmsg_locked, + sendmsg_unlocked, sk, &msg); if (ret <= 0) goto error; @@ -3066,11 +3067,18 @@ static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, slen = min_t(size_t, len, skb_frag_size(frag) - offset); while (slen) { - ret = INDIRECT_CALL_2(sendpage, kernel_sendpage_locked, - sendpage_unlocked, sk, - skb_frag_page(frag), - skb_frag_off(frag) + offset, - slen, MSG_DONTWAIT); + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = MSG_SPLICE_PAGES | MSG_DONTWAIT, + }; + + bvec_set_page(&bvec, skb_frag_page(frag), slen, + skb_frag_off(frag) + offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, + slen); + + ret = INDIRECT_CALL_2(sendmsg, sendmsg_locked, + sendmsg_unlocked, sk, &msg); if (ret <= 0) goto error; @@ -3107,16 +3115,14 @@ static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, int skb_send_sock_locked(struct sock *sk, struct sk_buff *skb, int offset, int len) { - return __skb_send_sock(sk, skb, offset, len, kernel_sendmsg_locked, - kernel_sendpage_locked); + return __skb_send_sock(sk, skb, offset, len, sendmsg_locked); } EXPORT_SYMBOL_GPL(skb_send_sock_locked); /* Send skb data on a socket. Socket must be unlocked. */ int skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, int len) { - return __skb_send_sock(sk, skb, offset, len, sendmsg_unlocked, - sendpage_unlocked); + return __skb_send_sock(sk, skb, offset, len, sendmsg_unlocked); } /** From patchwork Fri Jun 23 22:55:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291442 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 D2170C001DC for ; Fri, 23 Jun 2023 22:55:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0599B8D0006; Fri, 23 Jun 2023 18:55:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 044468D0007; Fri, 23 Jun 2023 18:55:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D12F98D0006; Fri, 23 Jun 2023 18:55:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C00148D0001 for ; Fri, 23 Jun 2023 18:55:38 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 97C91140358 for ; Fri, 23 Jun 2023 22:55:38 +0000 (UTC) X-FDA: 80935521156.01.91F0ACB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id DAC511C0010 for ; Fri, 23 Jun 2023 22:55:35 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NHG1UTsY; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560936; 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=+W533yCSJmnbFAFKHcDDwIUi7AghOBKSEvqiVzDK1MA=; b=xy2H2zmF4V8YfIgFhJ/ncHNIgzLj5PkFVMJLCpN0r6++PlK988WTMvQDadQ0uvKEXvfEY5 ehzjlSCC68TjchB1/+YxDqVpG2ZQ7Pet3qTGg5DbJKLzP8mXhLvFor4YfnMZHvVsQgVkK7 Yos1ivUW+I7bPUzMHYlRTXIhKXg7Rm0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NHG1UTsY; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560936; a=rsa-sha256; cv=none; b=pJ59uUAMT3mlRxJzI2rTF0h7XHN2+HEq4Bqud7mwRPedJpTBWZS212NZwvc0WJhNFkoxM8 THqC01bY0JpRmJrPUBQThl1E7++X1tgXuFIwGzzGNhUeFfXBQ6yjJpB8HpX2IZ2pH+w3vW sbQ0kjmD+CTnxTdZkggj7c6tmleMqYY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560935; 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=+W533yCSJmnbFAFKHcDDwIUi7AghOBKSEvqiVzDK1MA=; b=NHG1UTsYXyzn13E5+Ms52Q5c/L2dNmcHkU0Rck1V56d0FJZJP91rmTujbYSitOUIwyvFfJ A3P6LxHtMaWJtzC0rpQ+FQX7lNu8V0n/1mIKPgOpQtUvl7SRZiw7nSiSgzglK2cyrlUuWo CSP3p0PxXi2CWDClF4l7k3QbE6smmWU= 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-319-HB5p8tLTOPecSH-Xsdm32Q-1; Fri, 23 Jun 2023 18:55:28 -0400 X-MC-Unique: HB5p8tLTOPecSH-Xsdm32Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22F78101A54E; Fri, 23 Jun 2023 22:55:27 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5690840C2063; Fri, 23 Jun 2023 22:55:25 +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, Ilya Dryomov , Xiubo Li , Jeff Layton , ceph-devel@vger.kernel.org Subject: [PATCH net-next v5 03/16] ceph: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 23 Jun 2023 23:55:00 +0100 Message-ID: <20230623225513.2732256-4-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.1 X-Rspamd-Queue-Id: DAC511C0010 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 7914h9t7g789zpqb85utsyupceoifcxx X-HE-Tag: 1687560935-940638 X-HE-Meta: U2FsdGVkX189miCFLb4RP2cwHM7j6mFwj7YONJ+dMH/sjBcHLn+Nb3TrL/WSLfVM/0zraQzu8TXbk1NwmFSU/7OVLt/0fzSL6naiJQZa2aTxQUc74HiBfa6pIAXWieDVZMwvkwjO0iKOu0W5dB3MCkUACSih2RqgeqzBecWARoZEBl1/IpcJFLsFaBraTVxq/Me8zsy6JWxIAqWcii8MSOkxhNUFOtT2SrIcwcFLtUOc8RyApz878jvYa2Sth1n5w/hMB1iOUQitLT9eBZ+1DvBI3RSIMwk7wYGMNz42GYHrYo1cTr+dp/tKY3XxoaPAKDG/5UruchAINj4BgnQWpWMI9bvSdV4MHySkROgKM7Ant7VeYhDFtA66RDDG0925Xvd0N1UiopC1nGMHDltC1e9gDNjrdtNqrEVSjf4Dner6NWlJIsCvQfsmQ8iVBbqWHEjqLrPIjtdhj+auZNvCRl3g/JsWupyiDpLjPqlLxyirv3inBNpHW9UdeAWfjmRTYd7F/Cv5GpYnY4deS+XHxoHhQp/OF29Plcpi4JKAgEfgSO3Af1Jtnrg2WVDwH0PtVjZ4yJ40tuKaioTRGyJYamX10wtYneQND113CNNLwdM4F0JqVOrNoEkL14mXbSNfHV1x7mR86fzg8pSyK98q0mh6v7iUPVBdy0Es1HR3PzNQkpdoFm4aLiMiyq77LEQQMyXKbv5sU53K8kFukXwCFQqfbJHhZ+xarcMks+mdT/mNi7rLLnE+UbVuq/rkg9qXnvdu+EYN7o5BKzSizc8+s6gVr7RLu9LeswIoryVrkZDBhQh2e/2IeUZUN/vWCUpHivQIOlnpvuC1RzIgW8mP0FZ42+U0w1dQXgiESSueIevRBVOuR2p3wCE8r+ww7/Rl19W2IgizrL/cfMy31RjlAh78H+uLRAzfjBLwmMQ/qag4CIrEK+6M/1zCo1FiItbrjprxTGpky5OthVvaveK l7UPIDpj W1u8TTCL5kNd1tKJ5xEDzZ8mUwPZeOh1/othucKIIpe4fYSL0BWrZpiLhCmZoARfNpa5MJguT/Yg0cwVwkmHEGPJs3qrVNE3JY1aDjlZL0iyUjCE9EhBB7YGj2lpVYM6eqzWgF6NG4b3fEmn+0Bg9G8P9qwBY2y49gqCVdrCwB7jBYnqf0X/yWcXjban2gpG7U6Fio+M0bWCH+qYqd2CJxpkLYBecNx17vbSJ/jc9Qnc5WwZMjjoIcU3vPh5vw7h2LVsX7ey11+3tJuImiAfYkbx3z4hIW1kh/GuqC2ny9EhF2C0VxpAW4vxPztat4yTQmifN2zNbHBFVUrKjzTA2HnYCEOmGc9I7jPJ4rNUJKXM2AQa5RHR1f7GnioWZBo3EzGJBAlgPl47wOyCkn/4bsqADpQGqPUXt7pCKVhtHxYBVjuvjETGYfNlH86SotnpQppQgA2fk/1b8QLfArH5oYnzs08b+tBsNPU20LYzDhK4srwY3UbrnG/aDSa6BcammY4bVx6AUnQFxWV8= 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: Use sendmsg() and MSG_SPLICE_PAGES rather than sendpage in ceph when transmitting data. For the moment, this can only transmit one page at a time because of the architecture of net/ceph/, but if write_partial_message_data() can be given a bvec[] at a time by the iteration code, this would allow pages to be sent in a batch. Signed-off-by: David Howells cc: Ilya Dryomov cc: Xiubo Li cc: Jeff Layton cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: ceph-devel@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #5) - Switch condition for setting MSG_MORE in write_partial_message_data() net/ceph/messenger_v1.c | 60 ++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/net/ceph/messenger_v1.c b/net/ceph/messenger_v1.c index d664cb1593a7..814579f27f04 100644 --- a/net/ceph/messenger_v1.c +++ b/net/ceph/messenger_v1.c @@ -74,37 +74,6 @@ static int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov, return r; } -/* - * @more: either or both of MSG_MORE and MSG_SENDPAGE_NOTLAST - */ -static int ceph_tcp_sendpage(struct socket *sock, struct page *page, - int offset, size_t size, int more) -{ - ssize_t (*sendpage)(struct socket *sock, struct page *page, - int offset, size_t size, int flags); - int flags = MSG_DONTWAIT | MSG_NOSIGNAL | more; - int ret; - - /* - * sendpage cannot properly handle pages with page_count == 0, - * we need to fall back to sendmsg if that's the case. - * - * Same goes for slab pages: skb_can_coalesce() allows - * coalescing neighboring slab objects into a single frag which - * triggers one of hardened usercopy checks. - */ - if (sendpage_ok(page)) - sendpage = sock->ops->sendpage; - else - sendpage = sock_no_sendpage; - - ret = sendpage(sock, page, offset, size, flags); - if (ret == -EAGAIN) - ret = 0; - - return ret; -} - static void con_out_kvec_reset(struct ceph_connection *con) { BUG_ON(con->v1.out_skip); @@ -464,7 +433,6 @@ static int write_partial_message_data(struct ceph_connection *con) struct ceph_msg *msg = con->out_msg; struct ceph_msg_data_cursor *cursor = &msg->cursor; bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC); - int more = MSG_MORE | MSG_SENDPAGE_NOTLAST; u32 crc; dout("%s %p msg %p\n", __func__, con, msg); @@ -482,6 +450,10 @@ static int write_partial_message_data(struct ceph_connection *con) */ crc = do_datacrc ? le32_to_cpu(msg->footer.data_crc) : 0; while (cursor->total_resid) { + struct bio_vec bvec; + struct msghdr msghdr = { + .msg_flags = MSG_SPLICE_PAGES, + }; struct page *page; size_t page_offset; size_t length; @@ -493,10 +465,13 @@ static int write_partial_message_data(struct ceph_connection *con) } page = ceph_msg_data_next(cursor, &page_offset, &length); - if (length == cursor->total_resid) - more = MSG_MORE; - ret = ceph_tcp_sendpage(con->sock, page, page_offset, length, - more); + if (length != cursor->total_resid) + msghdr.msg_flags |= MSG_MORE; + + bvec_set_page(&bvec, page, length, page_offset); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, length); + + ret = sock_sendmsg(con->sock, &msghdr); if (ret <= 0) { if (do_datacrc) msg->footer.data_crc = cpu_to_le32(crc); @@ -526,7 +501,10 @@ static int write_partial_message_data(struct ceph_connection *con) */ static int write_partial_skip(struct ceph_connection *con) { - int more = MSG_MORE | MSG_SENDPAGE_NOTLAST; + struct bio_vec bvec; + struct msghdr msghdr = { + .msg_flags = MSG_SPLICE_PAGES | MSG_MORE, + }; int ret; dout("%s %p %d left\n", __func__, con, con->v1.out_skip); @@ -534,9 +512,11 @@ static int write_partial_skip(struct ceph_connection *con) size_t size = min(con->v1.out_skip, (int)PAGE_SIZE); if (size == con->v1.out_skip) - more = MSG_MORE; - ret = ceph_tcp_sendpage(con->sock, ceph_zero_page, 0, size, - more); + msghdr.msg_flags &= ~MSG_MORE; + bvec_set_page(&bvec, ZERO_PAGE(0), size, 0); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, size); + + ret = sock_sendmsg(con->sock, &msghdr); if (ret <= 0) goto out; con->v1.out_skip -= ret; From patchwork Fri Jun 23 22:55:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291443 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 63B51C001B1 for ; Fri, 23 Jun 2023 22:55:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0FF58D0005; Fri, 23 Jun 2023 18:55:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E99508D0001; Fri, 23 Jun 2023 18:55:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D13F58D0005; Fri, 23 Jun 2023 18:55:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BEB5A8D0001 for ; Fri, 23 Jun 2023 18:55:36 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8DE4116029D for ; Fri, 23 Jun 2023 22:55:36 +0000 (UTC) X-FDA: 80935521072.10.E9D617B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id BB70AC000D for ; Fri, 23 Jun 2023 22:55:34 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h3LErLIx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560934; a=rsa-sha256; cv=none; b=JgHwcdMjnCpT0yBaaU81fLu9Ke6iZdNfbPzP2nR/rKl2YHU3w02L8j7/h7NHQdrM6Ke5bT H0NxHTiKYwIEciZRIHxO4WBxEQurXqiN5QyKTiX4+NkCDwJFKDBKpJCvzlBiTKL4g2EZnM M9JnEHu01R6hzV7BSQxtmQlrOp5i+fQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=h3LErLIx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560934; 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=fSQZQ6YboxRaXsiohOL5R9kf0uRRv2lhrE9A+pyCn4U=; b=Yc4Ynv9o+lNBzXC4yYHGJ4VwWHOBCsfWx2E3GtEnUFL5V8b3Ztgg4gLGCExLmszVm8vwZH BC1XjDsHnhQrPA8Mszf0+qxapEeLF24I6u2B+DAbJiL+wYTNbXu4Dg4gMFcvnCcqRAYm4c aQ3z9uJPnw/iyrj370tlVufA1OgKyYk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560934; 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=fSQZQ6YboxRaXsiohOL5R9kf0uRRv2lhrE9A+pyCn4U=; b=h3LErLIxnnwWUMuAXjVstpH44Lur1vv38/3+QjnyIO66j+/5t9JqFCGpqwW1bOr6HZk8nB MpnTWDneoMHhnSQLHrTCxZVgm1NyLWGOsQ1djZU3r+DQiN3qepZolXBtV5AiMU/DkNZryB MHZywjPT9CNpSh/NHTVP/+kYqSukziw= 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-92-hF_grVzWNFeRw_hjYjCKxw-1; Fri, 23 Jun 2023 18:55:30 -0400 X-MC-Unique: hF_grVzWNFeRw_hjYjCKxw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8147F2A2AD55; Fri, 23 Jun 2023 22:55:29 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0ABB2166B25; Fri, 23 Jun 2023 22:55:27 +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, Ilya Dryomov , Xiubo Li , Jeff Layton , ceph-devel@vger.kernel.org Subject: [PATCH net-next v5 04/16] ceph: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage() Date: Fri, 23 Jun 2023 23:55:01 +0100 Message-ID: <20230623225513.2732256-5-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.6 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BB70AC000D X-Stat-Signature: x3zh18ugpiy58zhtwsq1d9xhje6mwqpd X-HE-Tag: 1687560934-391242 X-HE-Meta: U2FsdGVkX18mdW5jzXKeqaaN0oJWV5G9Me5F7VJo9tUd0y7U6AUwXOULX6us/zjquVrWLEBxqVROhtCDPPvFFuNdfs1ZOFR1xmDl32EsTV1Ld14qvnfFd8ZmN0MtK9+q/tt2UBin+aQ35U6ifWzHkOTAKU3x5zNh4Kp9D+v+c9mSBdo8yyCYcqWgl/boaq4v1qPLy/FlxfTEeKaMPdXC3HhDN/wzCKR3MrZgIPxb5vDTfljbxvS434Da88XOhXqqPxweaA9txjFB7qJ8B7oBZePTbqIihfM4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wZumonNGsEd+LFPK5RIwC4dl4jps9WwRYwkueG0pbNPHUF0q8Zt0KK8zV/g5xpYBqbBzmhvK7PPGh1siCombBQv3urxgCXfjzkbkkP3SKi2IrBbZ3a9VwvpfBJ4ATKsNJT6O46v5EM8AJBsLo= 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: Use sendmsg() and MSG_SPLICE_PAGES rather than sendpage in ceph when transmitting data. For the moment, this can only transmit one page at a time because of the architecture of net/ceph/, but if write_partial_message_data() can be given a bvec[] at a time by the iteration code, this would allow pages to be sent in a batch. Signed-off-by: David Howells cc: Ilya Dryomov cc: Xiubo Li cc: Jeff Layton cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: ceph-devel@vger.kernel.org cc: netdev@vger.kernel.org --- net/ceph/messenger_v2.c | 91 +++++++++-------------------------------- 1 file changed, 19 insertions(+), 72 deletions(-) diff --git a/net/ceph/messenger_v2.c b/net/ceph/messenger_v2.c index 301a991dc6a6..87ac97073e75 100644 --- a/net/ceph/messenger_v2.c +++ b/net/ceph/messenger_v2.c @@ -117,91 +117,38 @@ static int ceph_tcp_recv(struct ceph_connection *con) return ret; } -static int do_sendmsg(struct socket *sock, struct iov_iter *it) -{ - struct msghdr msg = { .msg_flags = CEPH_MSG_FLAGS }; - int ret; - - msg.msg_iter = *it; - while (iov_iter_count(it)) { - ret = sock_sendmsg(sock, &msg); - if (ret <= 0) { - if (ret == -EAGAIN) - ret = 0; - return ret; - } - - iov_iter_advance(it, ret); - } - - WARN_ON(msg_data_left(&msg)); - return 1; -} - -static int do_try_sendpage(struct socket *sock, struct iov_iter *it) -{ - struct msghdr msg = { .msg_flags = CEPH_MSG_FLAGS }; - struct bio_vec bv; - int ret; - - if (WARN_ON(!iov_iter_is_bvec(it))) - return -EINVAL; - - while (iov_iter_count(it)) { - /* iov_iter_iovec() for ITER_BVEC */ - bvec_set_page(&bv, it->bvec->bv_page, - min(iov_iter_count(it), - it->bvec->bv_len - it->iov_offset), - it->bvec->bv_offset + it->iov_offset); - - /* - * sendpage cannot properly handle pages with - * page_count == 0, we need to fall back to sendmsg if - * that's the case. - * - * Same goes for slab pages: skb_can_coalesce() allows - * coalescing neighboring slab objects into a single frag - * which triggers one of hardened usercopy checks. - */ - if (sendpage_ok(bv.bv_page)) { - ret = sock->ops->sendpage(sock, bv.bv_page, - bv.bv_offset, bv.bv_len, - CEPH_MSG_FLAGS); - } else { - iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bv, 1, bv.bv_len); - ret = sock_sendmsg(sock, &msg); - } - if (ret <= 0) { - if (ret == -EAGAIN) - ret = 0; - return ret; - } - - iov_iter_advance(it, ret); - } - - return 1; -} - /* * Write as much as possible. The socket is expected to be corked, - * so we don't bother with MSG_MORE/MSG_SENDPAGE_NOTLAST here. + * so we don't bother with MSG_MORE here. * * Return: - * 1 - done, nothing (else) to write + * >0 - done, nothing (else) to write * 0 - socket is full, need to wait * <0 - error */ static int ceph_tcp_send(struct ceph_connection *con) { + struct msghdr msg = { + .msg_iter = con->v2.out_iter, + .msg_flags = CEPH_MSG_FLAGS, + }; int ret; + if (WARN_ON(!iov_iter_is_bvec(&con->v2.out_iter))) + return -EINVAL; + + if (con->v2.out_iter_sendpage) + msg.msg_flags |= MSG_SPLICE_PAGES; + dout("%s con %p have %zu try_sendpage %d\n", __func__, con, iov_iter_count(&con->v2.out_iter), con->v2.out_iter_sendpage); - if (con->v2.out_iter_sendpage) - ret = do_try_sendpage(con->sock, &con->v2.out_iter); - else - ret = do_sendmsg(con->sock, &con->v2.out_iter); + + ret = sock_sendmsg(con->sock, &msg); + if (ret > 0) + iov_iter_advance(&con->v2.out_iter, ret); + else if (ret == -EAGAIN) + ret = 0; + dout("%s con %p ret %d left %zu\n", __func__, con, ret, iov_iter_count(&con->v2.out_iter)); return ret; From patchwork Fri Jun 23 22:55:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291445 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 A0105C001DD for ; Fri, 23 Jun 2023 22:55:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 946718D0008; Fri, 23 Jun 2023 18:55:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CDBF8D0001; Fri, 23 Jun 2023 18:55:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 685858D0008; Fri, 23 Jun 2023 18:55:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 504758D0001 for ; Fri, 23 Jun 2023 18:55:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2650A40C99 for ; Fri, 23 Jun 2023 22:55:42 +0000 (UTC) X-FDA: 80935521324.10.6F71337 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 70361180009 for ; Fri, 23 Jun 2023 22:55:40 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BnllqzH4; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560940; 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=B4yhQOVBi6GuvWYD5vpVZMpw478eQsHtbdlO705ACPw=; b=7wzCYVcuhLOs8HUy+Q5pRE3TFp6nOCfZpGGrhp9jKXb8mESrMiu61YiNyBy/xKZ6xYCczh Pj8OIe7bz/c0pE2MMz8a0v1PIl0ulXl/tYwEmEw6hyETdj+tiGHHSJzwOIC599Pvp99i/5 40yVqK52LQDD6rn4mk38j996UpoSIQc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BnllqzH4; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560940; a=rsa-sha256; cv=none; b=qxG4gYnucJrcpyaXX9C+IK/7C5fn5Mz6UXfr44wHhCNSfEsVjqLvFojya0BoqnDH7rfZeO 6F0Q26POSSycdAXhaQpLqOB1ggAxCnRMBMygXvZC8XemtZaTyOhl9hsOWBowE1z87eq3qq valh/SAm8nCG1StIaRau61vSq5rOav4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560939; 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=B4yhQOVBi6GuvWYD5vpVZMpw478eQsHtbdlO705ACPw=; b=BnllqzH4HjDiv0mRNMVJMq6bWmHk9zF2hp3L4+QRuuCozS4Yn3W7ScWq7AhqeiTrarvh01 1R0GxKvderUERC0R79xR1kt6FbdwXNeOc1euiIOUTZGfO1C5OGOlcSee+ep7tcYtZKZiVt gLnoXIJvmCLk01bJ6IlfC44KeCUHXpo= 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-414-0YWi76drOuGNHDR7iFGrzg-1; Fri, 23 Jun 2023 18:55:33 -0400 X-MC-Unique: 0YWi76drOuGNHDR7iFGrzg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E4F31858EED; Fri, 23 Jun 2023 22:55:31 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 370D2200C0CD; Fri, 23 Jun 2023 22:55: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, Santosh Shilimkar , linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com Subject: [PATCH net-next v5 05/16] rds: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 23 Jun 2023 23:55:02 +0100 Message-ID: <20230623225513.2732256-6-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.4 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 70361180009 X-Stat-Signature: 6ty8hn4t65hgiybzp7qfaqb9srg6f3pi X-Rspam-User: X-HE-Tag: 1687560940-198526 X-HE-Meta: U2FsdGVkX19BH0i2zAgZUbYqk+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qZU55MOFihGJq+hvIBtITxICZvP04/4bmUVUV2ceIJfaNbMNkkjzvHxPkF02wAjnwcs36DrpyUV8B158ADsKo6Xp4gqSnEf4641U3ycgesMJe3OFs1XKQRuHwlCEMvdbJw1h8l6gZcNKIkl/xtLXQPosvLqSdU8MN0m56btDh0XVBk/RTYDET4YuKLxHOihhMUWH37yJiD8Jpkd2a70Au8JnqpV2WoppIuBfLn5k9EGNpKdUhW9igBlhJlnAQWSeZmGhmZJlk9k+W5mVOLarg3B/SS5p9H15yjvLatJYBn9v/s+ZJ18yhm0j259yHIjTEZDcYzNYkyBCfzmNcwE8NIHYudQEGRGA2UcbK0G8mws5zekZi9Eg6N9xOHWnOmEsFEkvOFgelSm8pfjXSVPqaywQeVUX837HGI4= 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: When transmitting data, call down into TCP using a single sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced. To make this work, the data is assembled in a bio_vec array and attached to a BVEC-type iterator. Signed-off-by: David Howells cc: Santosh Shilimkar cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-rdma@vger.kernel.org cc: rds-devel@oss.oracle.com cc: netdev@vger.kernel.org --- Notes: ver #4) - Reduce change to only call sendmsg on a page at a time. net/rds/tcp_send.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c index 8c4d1d6e9249..7d284ac7e81a 100644 --- a/net/rds/tcp_send.c +++ b/net/rds/tcp_send.c @@ -72,9 +72,10 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, { struct rds_conn_path *cp = rm->m_inc.i_conn_path; struct rds_tcp_connection *tc = cp->cp_transport_data; + struct msghdr msg = {}; + struct bio_vec bvec; int done = 0; int ret = 0; - int more; if (hdr_off == 0) { /* @@ -111,15 +112,17 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, goto out; } - more = rm->data.op_nents > 1 ? (MSG_MORE | MSG_SENDPAGE_NOTLAST) : 0; while (sg < rm->data.op_nents) { - int flags = MSG_DONTWAIT | MSG_NOSIGNAL | more; - - ret = tc->t_sock->ops->sendpage(tc->t_sock, - sg_page(&rm->data.op_sg[sg]), - rm->data.op_sg[sg].offset + off, - rm->data.op_sg[sg].length - off, - flags); + msg.msg_flags = MSG_SPLICE_PAGES | MSG_DONTWAIT | MSG_NOSIGNAL; + if (sg + 1 < rm->data.op_nents) + msg.msg_flags |= MSG_MORE; + + bvec_set_page(&bvec, sg_page(&rm->data.op_sg[sg]), + rm->data.op_sg[sg].length - off, + rm->data.op_sg[sg].offset + off); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, + rm->data.op_sg[sg].length - off); + ret = sock_sendmsg(tc->t_sock, &msg); rdsdebug("tcp sendpage %p:%u:%u ret %d\n", (void *)sg_page(&rm->data.op_sg[sg]), rm->data.op_sg[sg].offset + off, rm->data.op_sg[sg].length - off, ret); @@ -132,8 +135,6 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, off = 0; sg++; } - if (sg == rm->data.op_nents - 1) - more = 0; } out: From patchwork Fri Jun 23 22:55:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291444 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 8AF64EB64D7 for ; Fri, 23 Jun 2023 22:55:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5004F8D0007; Fri, 23 Jun 2023 18:55:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 48A4B8D0001; Fri, 23 Jun 2023 18:55:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 242E28D0008; Fri, 23 Jun 2023 18:55:39 -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 EC97C8D0001 for ; Fri, 23 Jun 2023 18:55:38 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C33F91A033D for ; Fri, 23 Jun 2023 22:55:38 +0000 (UTC) X-FDA: 80935521156.27.39592CA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 08705C0009 for ; Fri, 23 Jun 2023 22:55:36 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WYvfvrFD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560937; 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=CX0szcw738ZS8htZ0RxEmjBFgUMhbKSUPMuc1XxmplE=; b=k7nBxsaJtHaKC5BVVURWWQ5qm2UP18F6ia6nUgUEAklNnOysrETBVR8TNjqbXIrYyEpQWO G16P9uDSkSglKgLDxnPyvrr50FaGQLj9wzUXhgOyzp4KSTlbA05xMtisOWszRUZYplCG3v 1fKUFCAx8vhVpEZOwOGTZ4sl6zcDiH0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WYvfvrFD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560937; a=rsa-sha256; cv=none; b=Z7wyL4PdmjpxmZNbwD74zvUt8eHqOTBnFlqgQk9l5YpiPgTyex6fFji00JXIyIRoJ4GZXs niXZuP0bxre97PF2AQW/mGFW+YTytoNMFRDo0KzTlXI8SeJQazLhBEn8nS/y4/HYVupUOw u41Sq7jKlG+H3ywdj51bozlqE2i+VBU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560936; 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=CX0szcw738ZS8htZ0RxEmjBFgUMhbKSUPMuc1XxmplE=; b=WYvfvrFD6BuEHOkPWPkfXbLalZuvkoIYvY1T0AIhLHql2TxB+7Ujbj5pzqJIzeEhtPyn+L 2uUpZetZZqauti21OB+XNHM2GX20OyR5f0uzrEhDezC2s0MxfYM2Sg2Yd2ZC4M0yEKVgHF cgLGBgznn6hl5Hq8iGbtlJ7PRfVNjzE= 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-380-3sv4_t5gNYKj7bwjVePyIQ-1; Fri, 23 Jun 2023 18:55:34 -0400 X-MC-Unique: 3sv4_t5gNYKj7bwjVePyIQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 41DED380451C; Fri, 23 Jun 2023 22:55:34 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C49B40C2063; Fri, 23 Jun 2023 22:55:32 +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, Christine Caulfield , David Teigland , cluster-devel@redhat.com Subject: [PATCH net-next v5 06/16] dlm: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 23 Jun 2023 23:55:03 +0100 Message-ID: <20230623225513.2732256-7-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.1 X-Rspamd-Queue-Id: 08705C0009 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: q9gecifjq5tfyx9kfigawa7n68uxcipx X-HE-Tag: 1687560936-620621 X-HE-Meta: U2FsdGVkX184J7aPlpOp38HwoA73B4dXnGDZGvEvS0DexLIKq03w1fn//xB0g9mtayGUeIY5U2N2BKJQ8Pa1ycOGAW0pK+4ZyUWQbm/GH4m2Mi5YARL8m4u16iz6Ylg4c7lm5yzkQ+3f7CGacdHnz0mH/KKnVnxdTzvFU/xq7dGUnr88TainDrMqiJ3Ut+ekDddq/waxmDm86e0CSnkGEHyFAgex9VkV7Fljbo4yOZ5wHnJRUVCMEHWtFzVMjNXZqS39i2FU6BKM6dQnJJvODF3Y17E/C4E+ZqMx0tLQ537KONopBjdH9GqDICu2xY/XEVeUj3QlOP691dhjZIoLtwjQr3KMBIvDbHi3pxlYCwJEWXZiBS6A2WO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zo69LebQkTBU94nJT3hG7bD//6ya5rtTW0sJbw== 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: When transmitting data, call down a layer using a single sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced rather using sendpage. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Christine Caulfield cc: David Teigland cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: cluster-devel@redhat.com cc: netdev@vger.kernel.org --- fs/dlm/lowcomms.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 3d3802c47b8b..5c12d8cdfc16 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c @@ -1395,8 +1395,11 @@ int dlm_lowcomms_resend_msg(struct dlm_msg *msg) /* Send a message */ static int send_to_sock(struct connection *con) { - const int msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL; struct writequeue_entry *e; + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = MSG_SPLICE_PAGES | MSG_DONTWAIT | MSG_NOSIGNAL, + }; int len, offset, ret; spin_lock_bh(&con->writequeue_lock); @@ -1412,8 +1415,9 @@ static int send_to_sock(struct connection *con) WARN_ON_ONCE(len == 0 && e->users == 0); spin_unlock_bh(&con->writequeue_lock); - ret = kernel_sendpage(con->sock, e->page, offset, len, - msg_flags); + bvec_set_page(&bvec, e->page, len, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + ret = sock_sendmsg(con->sock, &msg); trace_dlm_send(con->nodeid, ret); if (ret == -EAGAIN || ret == 0) { lock_sock(con->sock->sk); From patchwork Fri Jun 23 22:55:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291446 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 0D97CEB64D7 for ; Fri, 23 Jun 2023 22:55:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B95F8D0009; Fri, 23 Jun 2023 18:55:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 941D18D0001; Fri, 23 Jun 2023 18:55:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BBF58D0009; Fri, 23 Jun 2023 18:55:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 674B78D0001 for ; Fri, 23 Jun 2023 18:55:48 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3E3F41A02E4 for ; Fri, 23 Jun 2023 22:55:48 +0000 (UTC) X-FDA: 80935521576.08.9E5F26B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 674BB40006 for ; Fri, 23 Jun 2023 22:55:46 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VF2Evlh9; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560946; 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=W+/sbivnn4SSL91vpgGdKmYtGhKmLadJeuepui2ZFTU=; b=Zq02wcA6SAeDuHZBpWqV0U1EESKrAuvwuJYqH1Pr3O5pipfgC59yybjsy8p+nVAaXKZv59 37hudAdQo97gcBMhIRb0AJHLxEy/8tHJO8X0M3slhssAD1CStG/oX8rOqfveJ2VulErLFV csDULCHr7kSQai7aiHHZS+gmYa3zACM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VF2Evlh9; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560946; a=rsa-sha256; cv=none; b=2w0f9urF9eUxy/4vxhjn5rsBoi1SFPqa+pj/MKqgAqOt8s+0H7SX3+G2YmPEGDoXwpCdoj 1hd7roKH8ZQTYa3ESQHoe9VM+S0mVVY5iQ+BDAo6fcM5wI0lfl0vkLmkvri6WlzkKdojBt KQJliO0bsTbE/cTXafV62oPMBmkwI80= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560945; 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=W+/sbivnn4SSL91vpgGdKmYtGhKmLadJeuepui2ZFTU=; b=VF2Evlh9AGPOBy10EdZYmVzzB/UxqR9nhVppGEaQg6DU61l6TC9EoU22nt8oCMtH8+nApQ GfZWAR0/3HkWkPlfiE+grMBZcGeroKEKl4Flc82NqJ9KTgysRjsitfNbH+t0Mkc2VafaIN qqkQdpuhPULwQgL4rp+qOHqf1kDLK90= 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-84-lshSpaI8Mri8O6LpAzQ_CA-1; Fri, 23 Jun 2023 18:55:38 -0400 X-MC-Unique: lshSpaI8Mri8O6LpAzQ_CA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B008809F8F; Fri, 23 Jun 2023 22:55:37 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF64940C2063; Fri, 23 Jun 2023 22:55:34 +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, Sagi Grimberg , Willem de Bruijn , Keith Busch , Jens Axboe , Christoph Hellwig , Chaitanya Kulkarni , linux-nvme@lists.infradead.org Subject: [PATCH net-next v5 07/16] nvme-tcp: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage Date: Fri, 23 Jun 2023 23:55:04 +0100 Message-ID: <20230623225513.2732256-8-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.1 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 674BB40006 X-Stat-Signature: 3qeexbfxomyrd7mqzradt3tmtdk7tzna X-HE-Tag: 1687560946-110764 X-HE-Meta: U2FsdGVkX19gOgaXi5hM6EOFefGI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NVdUncTkw/btiiKb4H08gOnuxEhO1NL2XSHGLSWuDXCsBSKMXwKfcw0QUvRr+UoIdUX6PEjJ9acJYke5SFdYHyNz6v4ijx5n/QGdYNtrPsveck4okEB+IvnaBMTj5Vq6FIrqlQEQvnrvFCe1/toa+HoIY1bi53ZV8XfXg4xSVoAJ3Wb0kDtujMV/60uFqaCrretQENK2weQI0oyiQmLQx0wQu/VGzOEUgk0fhxl+EFBfqpgWBhvnDJ1H8yGYLS9B2I2Lsm32Fjc7V8dxVRjDOV7FH9bhiAHifmpQnH5EsFxifZmkaacMHdyM0BQipvDSS9GLGsw3wXlhEk0KxIvZAt1TM8wNJv5hSzCaHsWkupQx3ptpqAYTuyGf3iL0LvdY4LMgyEhl+MYdz418nWetmwPsnLmSpp1H1Erq1g1KsvHHz97zCuXQq0r7Rjld2pbcrMT2j9u1ofw5yRKyjD7T1NicRCQ+8JxDwsyw= 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: When transmitting data, call down into TCP using a sendmsg with MSG_SPLICE_PAGES instead of sendpage. Signed-off-by: David Howells Tested-by: Sagi Grimberg Acked-by: Willem de Bruijn cc: Keith Busch cc: Jens Axboe cc: Christoph Hellwig cc: Chaitanya Kulkarni cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-nvme@lists.infradead.org cc: netdev@vger.kernel.org --- Notes: ver #4) - Cancel MSG_SPLICE_PAGES if the page being sent fails sendpage_ok(). ver #3) - Split nvme/host from nvme/target changes. ver #2) - Wrap lines at 80. drivers/nvme/host/tcp.c | 49 +++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index bf0230442d57..47ae17f16c05 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -997,25 +997,28 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req) u32 h2cdata_left = req->h2cdata_left; while (true) { + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, + }; struct page *page = nvme_tcp_req_cur_page(req); size_t offset = nvme_tcp_req_cur_offset(req); size_t len = nvme_tcp_req_cur_length(req); bool last = nvme_tcp_pdu_last_send(req, len); int req_data_sent = req->data_sent; - int ret, flags = MSG_DONTWAIT; + int ret; if (last && !queue->data_digest && !nvme_tcp_queue_more(queue)) - flags |= MSG_EOR; + msg.msg_flags |= MSG_EOR; else - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; - if (sendpage_ok(page)) { - ret = kernel_sendpage(queue->sock, page, offset, len, - flags); - } else { - ret = sock_no_sendpage(queue->sock, page, offset, len, - flags); - } + if (!sendpage_ok(page)) + msg.msg_flags &= ~MSG_SPLICE_PAGES, + + bvec_set_page(&bvec, page, len, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + ret = sock_sendmsg(queue->sock, &msg); if (ret <= 0) return ret; @@ -1054,22 +1057,24 @@ static int nvme_tcp_try_send_cmd_pdu(struct nvme_tcp_request *req) { struct nvme_tcp_queue *queue = req->queue; struct nvme_tcp_cmd_pdu *pdu = nvme_tcp_req_cmd_pdu(req); + struct bio_vec bvec; + struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, }; bool inline_data = nvme_tcp_has_inline_data(req); u8 hdgst = nvme_tcp_hdgst_len(queue); int len = sizeof(*pdu) + hdgst - req->offset; - int flags = MSG_DONTWAIT; int ret; if (inline_data || nvme_tcp_queue_more(queue)) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; else - flags |= MSG_EOR; + msg.msg_flags |= MSG_EOR; if (queue->hdr_digest && !req->offset) nvme_tcp_hdgst(queue->snd_hash, pdu, sizeof(*pdu)); - ret = kernel_sendpage(queue->sock, virt_to_page(pdu), - offset_in_page(pdu) + req->offset, len, flags); + bvec_set_virt(&bvec, (void *)pdu + req->offset, len); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + ret = sock_sendmsg(queue->sock, &msg); if (unlikely(ret <= 0)) return ret; @@ -1093,6 +1098,8 @@ static int nvme_tcp_try_send_data_pdu(struct nvme_tcp_request *req) { struct nvme_tcp_queue *queue = req->queue; struct nvme_tcp_data_pdu *pdu = nvme_tcp_req_data_pdu(req); + struct bio_vec bvec; + struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_MORE, }; u8 hdgst = nvme_tcp_hdgst_len(queue); int len = sizeof(*pdu) - req->offset + hdgst; int ret; @@ -1101,13 +1108,11 @@ static int nvme_tcp_try_send_data_pdu(struct nvme_tcp_request *req) nvme_tcp_hdgst(queue->snd_hash, pdu, sizeof(*pdu)); if (!req->h2cdata_left) - ret = kernel_sendpage(queue->sock, virt_to_page(pdu), - offset_in_page(pdu) + req->offset, len, - MSG_DONTWAIT | MSG_MORE | MSG_SENDPAGE_NOTLAST); - else - ret = sock_no_sendpage(queue->sock, virt_to_page(pdu), - offset_in_page(pdu) + req->offset, len, - MSG_DONTWAIT | MSG_MORE); + msg.msg_flags |= MSG_SPLICE_PAGES; + + bvec_set_virt(&bvec, (void *)pdu + req->offset, len); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + ret = sock_sendmsg(queue->sock, &msg); if (unlikely(ret <= 0)) return ret; From patchwork Fri Jun 23 22:55:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291447 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 4523FEB64DD for ; Fri, 23 Jun 2023 22:55:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC63A8D000B; Fri, 23 Jun 2023 18:55:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C4E788D0001; Fri, 23 Jun 2023 18:55:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA1A28D000B; Fri, 23 Jun 2023 18:55:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8E81B8D0001 for ; Fri, 23 Jun 2023 18:55:52 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 407C1B0E35 for ; Fri, 23 Jun 2023 22:55:52 +0000 (UTC) X-FDA: 80935521744.11.26C618A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 7E3D8100007 for ; Fri, 23 Jun 2023 22:55:50 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FF0DPQbC; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560950; a=rsa-sha256; cv=none; b=AziDbsO2HuKFFvyikw8FSqfABLc74R9m2kagyWDBiw96T5eocu2RTyliKVETBvdmOCV0Tj IDRGfOypWA6V+dZb+riXgFbaPRU1fzrZcmleY1wtG5jL40zfm60ayTSJxOhLFAXbGP7tpK 1lVAmF1Ckhcog3PbUChnyeRzYdiAqBQ= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FF0DPQbC; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1687560950; 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=wPelxPY/D2Xo1HQrs/bARLsTqDBy+xx6UHdo64Xl3wM=; b=Cfdm3ZJfUWUZPfUWA5DseyLXDwSnyKbkkuv4mBVfe/olMOMuZ1deYpAK8Ktqy3o4ti7pRc sNBKZWMh+Sd7q7xK8X0MWy2Aq0aClwLnPLdvwW6s+ls3wX+rt2jn7ow1j/Av5TP8yT60Z5 jIYzJjZCFVwEMkPE2Sxy9Y+3qhknqhY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560949; 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=wPelxPY/D2Xo1HQrs/bARLsTqDBy+xx6UHdo64Xl3wM=; b=FF0DPQbCNrZOEgFzktD5n6ZLdcGp9g5GkJ5/5079H+t6thXPV4GBX+Q0AVEY0v7HFrgOEW MF3BztZ6utzdp1/OQzbpgFu4IlIhk3ds5oBI3CHqI0si928dWzSzj88oEEDihtS54b4XrE fou5aNyy/R0NrPLqa+8KNTv3AO/u63A= 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-499-DUpz--sjP3qXGQTmp0UmAQ-1; Fri, 23 Jun 2023 18:55:41 -0400 X-MC-Unique: DUpz--sjP3qXGQTmp0UmAQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F295B185A78F; Fri, 23 Jun 2023 22:55:39 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id E079340C2063; Fri, 23 Jun 2023 22:55:37 +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, Sagi Grimberg , Willem de Bruijn , Keith Busch , Jens Axboe , Christoph Hellwig , Chaitanya Kulkarni , linux-nvme@lists.infradead.org Subject: [PATCH net-next v5 08/16] nvmet-tcp: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage Date: Fri, 23 Jun 2023 23:55:05 +0100 Message-ID: <20230623225513.2732256-9-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.1 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 7E3D8100007 X-Stat-Signature: 6ncfset1ap9s3ajuf69ofnqk1d6umbmw X-Rspam-User: X-HE-Tag: 1687560950-451568 X-HE-Meta: U2FsdGVkX18xCM6ceLWur13kyPfIeAQE/CV3eVbyNWoChYBzhIR4H++u3y9Gbzlzapa5ZB/WANtDD90ATzokh7w4tx7Pp+WZ0kzS/MsO/9Wxr0TqR2BIpu+l9lMgK4PyadZaUsNfrdACbn0yEcMdDfcoC2EKwhHsc+oFhWf0Fh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7ORxPqVsFV+zsBjaZlMhwfGXfMPqK81bfU612Z8TlvLtBN00Vy7NAFAg2yLpBdzwc8dW54DNccAkJE2OM8uQR868n0KpRz0KP03RVo4fWZNhaTZojTAcQBrycg0YdRRY28pSVHPIP1tSaHX41FjYI5TAMqHl2raGy44r9RzunE4jSDAqCsRbAxhlaG6VHYrSqGOUN8q5lsRjC2qeCabPPiwwvLjjRs5uzjufmnqeWN4vzbWqgPxxLcWpQW/9ofBuXSQC0EntkHua3hc+KA88tN1dPrgsMIIRrJ6hRq6iSGSkMwakM4YphrOVwTAHElwkKheQ2E+zkwa7Sg= 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: When transmitting data, call down into TCP using a single sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced rather than copied instead of calling sendpage. Signed-off-by: David Howells Tested-by: Sagi Grimberg Acked-by: Willem de Bruijn cc: Keith Busch cc: Jens Axboe cc: Christoph Hellwig cc: Chaitanya Kulkarni cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-nvme@lists.infradead.org cc: netdev@vger.kernel.org --- Notes: ver #3) - Split nvme/host from nvme/target changes. ver #2) - Wrap lines at 80. drivers/nvme/target/tcp.c | 46 ++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index ed98df72c76b..868aa4de2e4c 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -576,13 +576,17 @@ static void nvmet_tcp_execute_request(struct nvmet_tcp_cmd *cmd) static int nvmet_try_send_data_pdu(struct nvmet_tcp_cmd *cmd) { + struct msghdr msg = { + .msg_flags = MSG_DONTWAIT | MSG_MORE | MSG_SPLICE_PAGES, + }; + struct bio_vec bvec; u8 hdgst = nvmet_tcp_hdgst_len(cmd->queue); int left = sizeof(*cmd->data_pdu) - cmd->offset + hdgst; int ret; - ret = kernel_sendpage(cmd->queue->sock, virt_to_page(cmd->data_pdu), - offset_in_page(cmd->data_pdu) + cmd->offset, - left, MSG_DONTWAIT | MSG_MORE | MSG_SENDPAGE_NOTLAST); + bvec_set_virt(&bvec, (void *)cmd->data_pdu + cmd->offset, left); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, left); + ret = sock_sendmsg(cmd->queue->sock, &msg); if (ret <= 0) return ret; @@ -603,17 +607,21 @@ static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd, bool last_in_batch) int ret; while (cmd->cur_sg) { + struct msghdr msg = { + .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, + }; struct page *page = sg_page(cmd->cur_sg); + struct bio_vec bvec; u32 left = cmd->cur_sg->length - cmd->offset; - int flags = MSG_DONTWAIT; if ((!last_in_batch && cmd->queue->send_list_len) || cmd->wbytes_done + left < cmd->req.transfer_len || queue->data_digest || !queue->nvme_sq.sqhd_disabled) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; - ret = kernel_sendpage(cmd->queue->sock, page, cmd->offset, - left, flags); + bvec_set_page(&bvec, page, left, cmd->offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, left); + ret = sock_sendmsg(cmd->queue->sock, &msg); if (ret <= 0) return ret; @@ -649,18 +657,20 @@ static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd, bool last_in_batch) static int nvmet_try_send_response(struct nvmet_tcp_cmd *cmd, bool last_in_batch) { + struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, }; + struct bio_vec bvec; u8 hdgst = nvmet_tcp_hdgst_len(cmd->queue); int left = sizeof(*cmd->rsp_pdu) - cmd->offset + hdgst; - int flags = MSG_DONTWAIT; int ret; if (!last_in_batch && cmd->queue->send_list_len) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; else - flags |= MSG_EOR; + msg.msg_flags |= MSG_EOR; - ret = kernel_sendpage(cmd->queue->sock, virt_to_page(cmd->rsp_pdu), - offset_in_page(cmd->rsp_pdu) + cmd->offset, left, flags); + bvec_set_virt(&bvec, (void *)cmd->rsp_pdu + cmd->offset, left); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, left); + ret = sock_sendmsg(cmd->queue->sock, &msg); if (ret <= 0) return ret; cmd->offset += ret; @@ -677,18 +687,20 @@ static int nvmet_try_send_response(struct nvmet_tcp_cmd *cmd, static int nvmet_try_send_r2t(struct nvmet_tcp_cmd *cmd, bool last_in_batch) { + struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, }; + struct bio_vec bvec; u8 hdgst = nvmet_tcp_hdgst_len(cmd->queue); int left = sizeof(*cmd->r2t_pdu) - cmd->offset + hdgst; - int flags = MSG_DONTWAIT; int ret; if (!last_in_batch && cmd->queue->send_list_len) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; else - flags |= MSG_EOR; + msg.msg_flags |= MSG_EOR; - ret = kernel_sendpage(cmd->queue->sock, virt_to_page(cmd->r2t_pdu), - offset_in_page(cmd->r2t_pdu) + cmd->offset, left, flags); + bvec_set_virt(&bvec, (void *)cmd->r2t_pdu + cmd->offset, left); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, left); + ret = sock_sendmsg(cmd->queue->sock, &msg); if (ret <= 0) return ret; cmd->offset += ret; From patchwork Fri Jun 23 22:55:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291448 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 7B137C0015E for ; Fri, 23 Jun 2023 22:55:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A3938D000A; Fri, 23 Jun 2023 18:55:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10F838D0001; Fri, 23 Jun 2023 18:55:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC5C98D000A; Fri, 23 Jun 2023 18:55:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A64D88D000A for ; Fri, 23 Jun 2023 18:55:52 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 80B684036C for ; Fri, 23 Jun 2023 22:55:52 +0000 (UTC) X-FDA: 80935521744.10.87FEBDF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id BF8654000A for ; Fri, 23 Jun 2023 22:55:50 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DEL++WQD; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1687560950; 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=PSe/ILwvcvKNAe9EBhS3HTJsxWKySCoAZiMEUxcxN8I=; b=rk/C1M/aRlT0B/OxKmc67tXQf3DyRbXYi9stpK6v0hmfZtHRmI1vCkL0hKwO/g2M+WpoWR fnXE6Pob/28RRhpW20YWmsaHmweA3t8c0gCeeichKJAqUhuwQZsBGZ4rxrMXovg8d4Wefh UfIO1XiyyIBfskhxctF5Hun06T5JD0s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560950; a=rsa-sha256; cv=none; b=nXtOO438Wd/z7teJZ5bN9Hkyzx9GX+sN/XRpAiuBdmRNdGFO+9QizO3tfdoJueXXHP46l3 S/7fccW0uxdKOA3UJvTPCBwI1XpTqAwH8+jLX6P3CJy2zcr3rieEB4eEIYnqTWsOt5Dhmy 9shOhIkiZEK8TD4QjJzX+jlQcvrrpZw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DEL++WQD; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1687560950; 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=PSe/ILwvcvKNAe9EBhS3HTJsxWKySCoAZiMEUxcxN8I=; b=DEL++WQDGOwEhvdQ0TeukEiuBH4+7WInHMLR3fADbzmtb/C2TsMXLvPHnvMeJ1IiPM8TKe Zr7OQSe/D2e0EKm47ckJWgPMyw1pXLLcHQfN8ypULIJUKHRVsR8ItempswzzPLwgqo8uki sFJ+1ocoUyOYlsR35QyXJGN66J7kTw0= 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-435-6ad3DI-XOqS6VIWlsOJ3Ag-1; Fri, 23 Jun 2023 18:55:43 -0400 X-MC-Unique: 6ad3DI-XOqS6VIWlsOJ3Ag-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A924B3804521; Fri, 23 Jun 2023 22:55:42 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95903492B01; Fri, 23 Jun 2023 22:55:40 +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, Karsten Graul , Wenjia Zhang , Jan Karcher , "D. Wythe" , Tony Lu , Wen Gu , linux-s390@vger.kernel.org Subject: [PATCH net-next v5 09/16] smc: Drop smc_sendpage() in favour of smc_sendmsg() + MSG_SPLICE_PAGES Date: Fri, 23 Jun 2023 23:55:06 +0100 Message-ID: <20230623225513.2732256-10-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.9 X-Stat-Signature: 86fj3hz78hoxk3yxgze874p9qsacakjs X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BF8654000A X-Rspam-User: X-HE-Tag: 1687560950-657877 X-HE-Meta: U2FsdGVkX18yq25//kFT7thBIILfdDZYc3pA7DGYDl1MFPyx8nwkDYMF03lTz6+3GpEAPx/9aFKveeRLWPadlSyuSHABy5RCwRR+wVjYezCm8283oAPUJEnCl3iKwAQM03miiH01DjcbWgK2+BuoOpBN9lSNSmqjiPKyz1GJvjd6Fo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jRxh4xemCCXnwufi23k8/weoO/AbqwhoQKL6UiL3FVW8rq7XLjlD0+wk/2vPIyEuRryP1rHSRXeb2icsqtOZcTQbTAEIo1cqnApKeelFyFkjTb8dCMsssjPxLABoD8Uf0WUFOf1tAPSwc/AzXplYQxw8k/hB3MDBvH5VVvFlrz8yZkudghtgmv8v5Kf50sPpRuVyWFOS+YLG5ps6QN6+RTimePio9kL8nadoUDbmXgjkcnCMIQw2vNPW6bN4aFNbiwMvLb7nW3f03lpl005HLmp+ 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: Drop the smc_sendpage() code as smc_sendmsg() just passes the call down to the underlying TCP socket and smc_tx_sendpage() is just a wrapper around its sendmsg implementation. Signed-off-by: David Howells cc: Karsten Graul cc: Wenjia Zhang cc: Jan Karcher cc: "D. Wythe" cc: Tony Lu cc: Wen Gu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-s390@vger.kernel.org cc: netdev@vger.kernel.org --- net/smc/af_smc.c | 29 ----------------------------- net/smc/smc_stats.c | 2 +- net/smc/smc_stats.h | 1 - net/smc/smc_tx.c | 19 ------------------- net/smc/smc_tx.h | 2 -- 5 files changed, 1 insertion(+), 52 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 538e9c6ec8c9..a7f887d91d89 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -3133,34 +3133,6 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd, return put_user(answ, (int __user *)arg); } -static ssize_t smc_sendpage(struct socket *sock, struct page *page, - int offset, size_t size, int flags) -{ - struct sock *sk = sock->sk; - struct smc_sock *smc; - int rc = -EPIPE; - - smc = smc_sk(sk); - lock_sock(sk); - if (sk->sk_state != SMC_ACTIVE) { - release_sock(sk); - goto out; - } - release_sock(sk); - if (smc->use_fallback) { - rc = kernel_sendpage(smc->clcsock, page, offset, - size, flags); - } else { - lock_sock(sk); - rc = smc_tx_sendpage(smc, page, offset, size, flags); - release_sock(sk); - SMC_STAT_INC(smc, sendpage_cnt); - } - -out: - return rc; -} - /* Map the affected portions of the rmbe into an spd, note the number of bytes * to splice in conn->splice_pending, and press 'go'. Delays consumer cursor * updates till whenever a respective page has been fully processed. @@ -3232,7 +3204,6 @@ static const struct proto_ops smc_sock_ops = { .sendmsg = smc_sendmsg, .recvmsg = smc_recvmsg, .mmap = sock_no_mmap, - .sendpage = smc_sendpage, .splice_read = smc_splice_read, }; diff --git a/net/smc/smc_stats.c b/net/smc/smc_stats.c index e80e34f7ac15..ca14c0f3a07d 100644 --- a/net/smc/smc_stats.c +++ b/net/smc/smc_stats.c @@ -227,7 +227,7 @@ static int smc_nl_fill_stats_tech_data(struct sk_buff *skb, SMC_NLA_STATS_PAD)) goto errattr; if (nla_put_u64_64bit(skb, SMC_NLA_STATS_T_SENDPAGE_CNT, - smc_tech->sendpage_cnt, + 0, SMC_NLA_STATS_PAD)) goto errattr; if (nla_put_u64_64bit(skb, SMC_NLA_STATS_T_CORK_CNT, diff --git a/net/smc/smc_stats.h b/net/smc/smc_stats.h index 84b7ecd8c05c..b60fe1eb37ab 100644 --- a/net/smc/smc_stats.h +++ b/net/smc/smc_stats.h @@ -71,7 +71,6 @@ struct smc_stats_tech { u64 clnt_v2_succ_cnt; u64 srv_v1_succ_cnt; u64 srv_v2_succ_cnt; - u64 sendpage_cnt; u64 urg_data_cnt; u64 splice_cnt; u64 cork_cnt; diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c index 9b9e0a190734..3b0ff3b589c7 100644 --- a/net/smc/smc_tx.c +++ b/net/smc/smc_tx.c @@ -297,25 +297,6 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len) return rc; } -int smc_tx_sendpage(struct smc_sock *smc, struct page *page, int offset, - size_t size, int flags) -{ - struct msghdr msg = {.msg_flags = flags}; - char *kaddr = kmap(page); - 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); - rc = smc_tx_sendmsg(smc, &msg, size); - kunmap(page); - return rc; -} - /***************************** sndbuf consumer *******************************/ /* sndbuf consumer: actual data transfer of one target chunk with ISM write */ diff --git a/net/smc/smc_tx.h b/net/smc/smc_tx.h index 34b578498b1f..a59f370b8b43 100644 --- a/net/smc/smc_tx.h +++ b/net/smc/smc_tx.h @@ -31,8 +31,6 @@ void smc_tx_pending(struct smc_connection *conn); void smc_tx_work(struct work_struct *work); void smc_tx_init(struct smc_sock *smc); int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len); -int smc_tx_sendpage(struct smc_sock *smc, struct page *page, int offset, - size_t size, int flags); int smc_tx_sndbuf_nonempty(struct smc_connection *conn); void smc_tx_sndbuf_nonfull(struct smc_sock *smc); void smc_tx_consumer_update(struct smc_connection *conn, bool force); From patchwork Fri Jun 23 22:55:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291456 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 BC6ABC001DE for ; Fri, 23 Jun 2023 22:55:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C0A8D000D; Fri, 23 Jun 2023 18:55:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DE2C8D0001; Fri, 23 Jun 2023 18:55:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E24948D000D; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C6EED8D0001 for ; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 946164036C for ; Fri, 23 Jun 2023 22:55:55 +0000 (UTC) X-FDA: 80935521870.25.DAED2E3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 41041C000A for ; Fri, 23 Jun 2023 22:55:51 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="SVkhoZ4/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560952; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WiURs0vKXpYUCqXgawYZgqdOEVHMSUaWINzZV5vrdeY=; b=CsXg9ByTgtUOO6ZNMXvBriqOmCFMLOqZh3yJyvxp7gS+2JwkHZMBqyX6osrSnpdsTolhXc QuZ8CHVm2mW2Bn9fykcDTFEDKN3c8CkoElgMSoNMyEDntcOktfQzTCQCVNcM2RmHaOlyLV h/66QhTfFt3G+pFrb11ci8hD4nzUkws= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="SVkhoZ4/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560952; a=rsa-sha256; cv=none; b=gfjiW7PQto5MklQTA1y0Gji6QLJPXGmtyExP9Xi6hUmb4czDUFW3TYIEy/x/kqJ8bokVw9 So1MCy3fh5lb4RXElgZqa4VdXr6Di8R+vHAd1/XIiTJJEwKEqMaUbAE2ecqcpw1MtK+MUP 7V4oC/mcsySaOHoI82BiAHJq8/ostPU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WiURs0vKXpYUCqXgawYZgqdOEVHMSUaWINzZV5vrdeY=; b=SVkhoZ4/bhSFk+9dgCco3zYfeZ8J8Mwxihu+s3JYXhG8ZYsI7K6Tzf9gqMKyW932/Jj0kT rT+6eSMK+Ma00ipqOY9IRJZu/2gpj7Yp97PIG1+21dkcs4CZrGZSnRQuUHnre5Xvue/Npq gLkw2lVP9WrPXhjtb3DXrNZ+taAxwHc= 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-195--BFW1w5BP0WNexEK9_ZAZQ-1; Fri, 23 Jun 2023 18:55:46 -0400 X-MC-Unique: -BFW1w5BP0WNexEK9_ZAZQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43846810BB2; Fri, 23 Jun 2023 22:55:45 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56CA84087C6D; Fri, 23 Jun 2023 22:55:43 +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, Philipp Reisner , Lars Ellenberg , =?utf-8?q?Christoph_B=C3=B6hmwa?= =?utf-8?q?lder?= , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org Subject: [PATCH net-next v5 10/16] drbd: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage() Date: Fri, 23 Jun 2023 23:55:07 +0100 Message-ID: <20230623225513.2732256-11-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.2 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 41041C000A X-Stat-Signature: 6j8kpgu8q8epiby9r8g1e1hme7x6snz9 X-Rspam-User: X-HE-Tag: 1687560951-844698 X-HE-Meta: U2FsdGVkX1//MOFE32TmrObCTEJyFd3l0mFqxxooy3+tqxEGVw65TJjnnPzva4gR1zjs0w2eaL93Cq0T3OYcqwYwY/n5bYLoM8h429N4LxQpi7F9qCWKLo0WxijhAUpfZ7OJxn90DtQmmrgvY40tGtX7IIyXQD5kaPH3DasldmkKS6hoBB2Dm5USyGvBDCOUz6ZQRwLC81Rzh/9soyPA8chBDe4Hup/EP+nfr97b7nUNIRvBAU32rVb9W1gq1w9cyoijiVdq2CGiqTcfVw1aongwn8nswx7BhiqX82LnOYtrc5rgYsBx5yUs3wLT6jNUKM5caWQ9auoktY41NhfNJiQmca1frqovvgTD6jHOGYJGhTXfsQ5+nI34kL3bOYRBsI/XxTYCztAWuEUB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cyfmNFkwIAlvqg== 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: Use sendmsg() conditionally with MSG_SPLICE_PAGES in _drbd_send_page() rather than calling sendpage() or _drbd_no_send_page(). Signed-off-by: David Howells cc: Philipp Reisner cc: Lars Ellenberg cc: "Christoph Böhmwalder" cc: Jens Axboe cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: drbd-dev@lists.linbit.com cc: linux-block@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #4) - Don't look at msg.msg_iter after calling sendmsg. There's no guarantee it has changed. ver #2) - Wrap lines at 80. drivers/block/drbd/drbd_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 83987e7a5ef2..ea82d6733313 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -1540,6 +1540,8 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa int offset, size_t size, unsigned msg_flags) { struct socket *socket = peer_device->connection->data.socket; + struct msghdr msg = { .msg_flags = msg_flags, }; + struct bio_vec bvec; int len = size; int err = -EIO; @@ -1549,15 +1551,17 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa * put_page(); and would cause either a VM_BUG directly, or * __page_cache_release a page that would actually still be referenced * by someone, leading to some obscure delayed Oops somewhere else. */ - if (drbd_disable_sendpage || !sendpage_ok(page)) - return _drbd_no_send_page(peer_device, page, offset, size, msg_flags); + if (!drbd_disable_sendpage && sendpage_ok(page)) + msg.msg_flags |= MSG_NOSIGNAL | MSG_SPLICE_PAGES; - msg_flags |= MSG_NOSIGNAL; drbd_update_congested(peer_device->connection); do { int sent; - sent = socket->ops->sendpage(socket, page, offset, len, msg_flags); + bvec_set_page(&bvec, page, offset, len); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + + sent = sock_sendmsg(socket, &msg); if (sent <= 0) { if (sent == -EAGAIN) { if (we_should_drop_the_connection(peer_device->connection, socket)) From patchwork Fri Jun 23 22:55:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291449 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 37243EB64D7 for ; Fri, 23 Jun 2023 22:55:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AC1F8D000C; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6378B8D0001; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 439398D000C; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 28C568D0001 for ; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D461C140350 for ; Fri, 23 Jun 2023 22:55:54 +0000 (UTC) X-FDA: 80935521828.25.5D7371F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 3D06E100003 for ; Fri, 23 Jun 2023 22:55:53 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WXgHJBr8; spf=pass (imf14.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=1687560953; 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=3eD9cwJhfzpjqArgDx6+FQer5AVxYbVfQjKZhNYJ+UE=; b=WLnszgopBn0AGaBxxpVOqrjq2QEXsKaQFNt5PKPsltHPri/OevJGPPTtYcHsm7BRhX/5OF BXt2faq8f2rRlGKou+ZolWACpqv8OT/RstGSEmymRASA1lVoDa7ffJvOeiJaRUQhWhKzhK WC1cg+ufXuopaFDPTwCv0q8lyD/qAvo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560953; a=rsa-sha256; cv=none; b=aIhbVQ3RLmRPzsaH0LsW6AEllPpVPJiDgjZRWTRFSq2qrKd/4atbbQTivtDt+XWlNkmTyT pVVPc8Uepiac9gWBz/E3IXHEGcXbV62OmRAKURwGABdNp4NkDS/h71rMUcrxM/DLHZU/35 JXuzb6MFbH8A63eGDAz1y4tVj9b+74s= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WXgHJBr8; spf=pass (imf14.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=1687560952; 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=3eD9cwJhfzpjqArgDx6+FQer5AVxYbVfQjKZhNYJ+UE=; b=WXgHJBr8ZTgmwztLr9R18HkFzWlrphe4gtwMCq9LhcX7o0uW8yPXJKynruzAjtnHMC9Nuz XFaRbLRyUkykxPg5nGNmUM0SPP6LnwKIl1Ig0+k+rQLkQVvXrrPFiYHvejWs8nRbU9XjWn PtoyoQwjGtbj9xMxNfWCGX4IqEf0Wic= 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-632-PTJ_wQD9ObaVu43jKmpMaw-1; Fri, 23 Jun 2023 18:55:49 -0400 X-MC-Unique: PTJ_wQD9ObaVu43jKmpMaw-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 17CAE3C0BE35; Fri, 23 Jun 2023 22:55:48 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CEDA91400C35; Fri, 23 Jun 2023 22:55:45 +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, Mike Christie , Lee Duncan , Chris Leech , "James E.J. Bottomley" , "Martin K. Petersen" , Al Viro , open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH net-next v5 11/16] scsi: iscsi_tcp: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 23 Jun 2023 23:55:08 +0100 Message-ID: <20230623225513.2732256-12-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.7 X-Rspamd-Queue-Id: 3D06E100003 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: w6hhnu634hg7mhnudp3iu17c31uz148k X-HE-Tag: 1687560953-767150 X-HE-Meta: U2FsdGVkX1+Pz+T8iFeb+Rj68DyPHGVPhSG7dzaL7ue6/Z3JcRH6OlMRjthP0WuZsaaGCwOtuXNWoa40QERM3B0fsc1aWNLIGpqGAODMrKcxvf08P3jUNVzrUsD+LRg/Ai3Gf2mEQvlhYxw+KiksIF/PQAcwn1J+gC2K0ULW+HFRSfxKwVpSXpGN860ab38metZy6vkFCGdcEATHAmh07GcRYsUAoJTzNUYy5bLPfQQPmL8Ww7t4UyRgnpZYo6oBvwmA1kTP9C2hYhVNFc/cxo0qDNoQwbKh4ojVRCdGEM7RKPCVfSsC1baBhJYkjSItll3aeLBAXlMb5AbcjqbWrYKEf46ryGaOT2NMizu3y8UD8ZgRTkXQSf0gNdTjP7uy/acHZ3uAvmlBfl+WWode3C6KkmGfyzxk/cUT7vlJJeUY3pP4TKYZwjvbc5vfcpBf1IMuPBT3Cu7fI7nqCZTFIWLYQi5VOVYzco9JtcSWyFlhnBou/bfywqB4xKjj6iP1BVjJbVVkO3+MaxxQr9B+wtjo6hdPVTiJyFB4ruXOLGBH1ybIoXACtJyUAFyiUBgiHfpAEkV6aAOf4MlEFb6DvpFP/Rxqi2RTmLB6APJ8/yToeMtVqxmseMI8jK89zJcxK8yB8xeJfshow8kQDo0Z8qCeBjl5EVFWiTHmfcSdfpQzPNHSFLdjFeafbWRL3545oVrqs28/CYwO4Xfrhn6naULCZ9yMG2ywoh8JDFbW4PNd5EF7lNZGBMtiRIqa6BTqJc0MXMDlY0RKzbeY2d4B+INyxAIoOe0nJT7liP7iCmO9gQqWO0zb7rfir29AFEPLPJFmuwBHFOYAKUI7ySlEEsNb3CUVoYQS2PG85D3ojE5oQw03Y19QfcWE3Ceneu7oALcHvAe7Dqj+p7slN25m9URPRtfmuiynCCE/gsdtPqy+ifS47EoKIkuVzxI5qDiQ2wxKPJLrCVzCVNkfhHm 6wUc7gfj Mt2GjlI+vzEkirW9zIXqClUr8BYJl9zJpI+RItnEb+M0z/A/dqcPIY+Dkqa5f2FOEz4V6aNKi/sH2QSxlgIA5BbAtALHKJLZalr20BBOLA/wH+CeI9PS5HChYEebED5F4rC7+bIZXe+gpryPHumW73qIdfXfMEm3yCvtmTBb2TLfeN5aTZYx3W5ZTbLycmwSq/PPbruHEkf4c9vngRzJm84EKo3xLt3uQlF40MkBz4EksVMk1rhJW8HeHi2HIj3mUWwaGjrYgQQntMj8LkfDytzCuv8V0yLy4EtyNnWNgTJavO33dLFlnP2DHHbylHoioULTZnByfsjznu01ZfzxDzVjlBna3S+l+pTLglgMl81EYqLJMNo+JQaYMRKHnPfv2Re8Q5imfYYqDeirDkNEyrh6QmXKftbKGXiJcB8dxVv9FUolERMw0eZDdnI5JdDmeOlw4VbBJXvs6EUYMN7Px2gJagCMoUKTamxc/BmErqRGiTl8z8MH9nKNVXb28UyifKp3Ffn9JtTkRV2xSkbnipCfzZnYdzgcF6+JEF0dwtd21H5exI26KY2kQvX7dnTXL0NwL5soZqSbXb8VjmnKnhKW+dcGHlxlK78cUocZbfFQp4uiIqZK92sMI+BJf1jQycqak2r6sAJdgTqG9QYkXCk8ATE5YrkHzsSsUIf0XFEZyPMOTjS3k+20PxztOQRTugSnHuj1ovHOAZBtjXx2hxpZOTQ== 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: Use sendmsg() with MSG_SPLICE_PAGES rather than sendpage. This allows multiple pages and multipage folios to be passed through. Signed-off-by: David Howells Reviewed-by: Mike Christie cc: Lee Duncan cc: Chris Leech cc: "James E.J. Bottomley" cc: "Martin K. Petersen" cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: Al Viro cc: open-iscsi@googlegroups.com cc: linux-scsi@vger.kernel.org cc: target-devel@vger.kernel.org cc: netdev@vger.kernel.org Reviewed-by: Chris Leech --- Notes: ver #5) - Split iscsi changes into client and target patches drivers/scsi/iscsi_tcp.c | 26 ++++++++++---------------- drivers/scsi/iscsi_tcp.h | 2 -- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 9637d4bc2bc9..9ab8555180a3 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -301,35 +301,32 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn, while (!iscsi_tcp_segment_done(tcp_conn, segment, 0, r)) { struct scatterlist *sg; + struct msghdr msg = {}; + struct bio_vec bv; unsigned int offset, copy; - int flags = 0; r = 0; offset = segment->copied; copy = segment->size - offset; if (segment->total_copied + segment->size < segment->total_size) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; if (tcp_sw_conn->queue_recv) - flags |= MSG_DONTWAIT; + msg.msg_flags |= MSG_DONTWAIT; - /* Use sendpage if we can; else fall back to sendmsg */ if (!segment->data) { + if (!tcp_conn->iscsi_conn->datadgst_en) + msg.msg_flags |= MSG_SPLICE_PAGES; sg = segment->sg; offset += segment->sg_offset + sg->offset; - r = tcp_sw_conn->sendpage(sk, sg_page(sg), offset, - copy, flags); + bvec_set_page(&bv, sg_page(sg), copy, offset); } else { - struct msghdr msg = { .msg_flags = flags }; - struct kvec iov = { - .iov_base = segment->data + offset, - .iov_len = copy - }; - - r = kernel_sendmsg(sk, &msg, &iov, 1, copy); + bvec_set_virt(&bv, segment->data + offset, copy); } + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bv, 1, copy); + r = sock_sendmsg(sk, &msg); if (r < 0) { iscsi_tcp_segment_unmap(segment); return r; @@ -746,7 +743,6 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session, sock_no_linger(sk); iscsi_sw_tcp_conn_set_callbacks(conn); - tcp_sw_conn->sendpage = tcp_sw_conn->sock->ops->sendpage; /* * set receive state machine into initial state */ @@ -777,8 +773,6 @@ static int iscsi_sw_tcp_conn_set_param(struct iscsi_cls_conn *cls_conn, return -ENOTCONN; } iscsi_set_param(cls_conn, param, buf, buflen); - tcp_sw_conn->sendpage = conn->datadgst_en ? - sock_no_sendpage : tcp_sw_conn->sock->ops->sendpage; mutex_unlock(&tcp_sw_conn->sock_lock); break; case ISCSI_PARAM_MAX_R2T: diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h index 68e14a344904..89a6fc552f0b 100644 --- a/drivers/scsi/iscsi_tcp.h +++ b/drivers/scsi/iscsi_tcp.h @@ -47,8 +47,6 @@ struct iscsi_sw_tcp_conn { /* MIB custom statistics */ uint32_t sendpage_failures_cnt; uint32_t discontiguous_hdr_cnt; - - ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int); }; struct iscsi_sw_tcp_host { From patchwork Fri Jun 23 22:55:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291458 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 C0619EB64D7 for ; Fri, 23 Jun 2023 22:56:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BD6B8D000F; Fri, 23 Jun 2023 18:56:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 71EDA8D0001; Fri, 23 Jun 2023 18:56:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54D218D000F; Fri, 23 Jun 2023 18:56:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 386CF8D0001 for ; Fri, 23 Jun 2023 18:56:01 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0AB1912036E for ; Fri, 23 Jun 2023 22:56:01 +0000 (UTC) X-FDA: 80935522122.18.E5E7CE3 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 5892540016 for ; Fri, 23 Jun 2023 22:55:59 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Kh7J2tYb; 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=1687560959; 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=aZHrq272u78M4jQRc62xjzOjs56TE9G5qctmKlgdkdo=; b=2DHFomMC63ltBJtrU2uZsl+D7t2aLXXuQKXdz10RbRPBZfmkE1E3dZ4PwOejjRa2qd2NzO tpsaPGLnYx7aAVdcXarrwnO8lsexuWVqzAVHIFT/iuMmwmTPF74ogDxA9Mo/r2KNZA0cQ6 H/kKtpxzzqU5RDQmC4iwCaTfKapuzhM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560959; a=rsa-sha256; cv=none; b=Pz3OP06pQS2pHUySUKVwrpQP1rTkU/2Iv/PFwZX1lvYtjX/tjQoGaLiri+wLjh/Q4nWSar Mn/qLumvDWvT7tkcbDxnudOWVLhGIPz9bM0D3LSj10p0AqJiRF9CvOgru18+EcvPMVQPPK 8Lp4iOq6S3XwQP+9IEG6hD+GCoB4r+o= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Kh7J2tYb; 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=1687560958; 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=aZHrq272u78M4jQRc62xjzOjs56TE9G5qctmKlgdkdo=; b=Kh7J2tYbxh4f9Lhj2mCsWXMV+WCv7BPl6/mAZZJ05tn9NTo2pDwYZ4PLmIbKTHedjWsYEr q3UEHFp8mrYJ0wOqlSpzycW2lV2iIUtGl34dHi4I5KE6aRGMGknP/f9QtW+z2qySxIFxEw +HCAS3Ak4ON6xLsZdqtG9lL/sm15Y5Y= 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-90-ADNZXf0mNHmnFJ3WbtgVaQ-1; Fri, 23 Jun 2023 18:55:52 -0400 X-MC-Unique: ADNZXf0mNHmnFJ3WbtgVaQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA1AE2A2AD56; Fri, 23 Jun 2023 22:55:50 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6FB340C2063; Fri, 23 Jun 2023 22:55:48 +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, Mike Christie , Maurizio Lombardi , "James E.J. Bottomley" , "Martin K. Petersen" , Al Viro , open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH net-next v5 12/16] scsi: target: iscsi: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 23 Jun 2023 23:55:09 +0100 Message-ID: <20230623225513.2732256-13-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.1 X-Rspamd-Queue-Id: 5892540016 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: r84nctci1ea16djbzf84yx7n7ts6bw53 X-HE-Tag: 1687560959-314836 X-HE-Meta: U2FsdGVkX1+2KRf9SkPOVoEd9FdPvb39seBukMuRWSqOGM4bQ8WYRZY18Jb2B8Lbvg37Udis07TQE2nUsqdqKHOzRmx/n+Om9RyF19VBklNBiP7q8vb6yQns5qVUkqJZRNfxZyLza1s2x+9Ikobxx6ZT0M9UlJShHmzj+GmMBs6w9y7JBl3B47igBosadU1gt7jt3hXWIG0wAZ5d8QPgJVlxH0vnMzgZ7RSiMntcnFcDbtb7e0DOiG2ESlF2md7PyTVwGS3obXqg6koFQ5NWES4Y8fMyHrik2NFehcq5mTPIpVI3Pe/EodINXltwOOubD5fobFUvy2jgFu1MPyHoG2fmVPV3eZJJ05S9YNu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s+vQ9Gq15z5RRoZ1ETmQis6A6r5+XH470U9M5V2+hY5JrhE19gT1bVhwwQS/2ymq1LUHAR/4uEca1T4hLYo3Qo+dG8AriXvg9DVN7yz61e6vUdMPJud29cWS1Ur34LuTU+nxkJh4q1VvSIzV0mUwItpjg9DZfj3xxp5pNrdd+QykLhZMCe500qnVjOr7ua0Ahq/+8vHZJcqEygjgvC34xQD3gi/sKQ== 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: Use sendmsg() with MSG_SPLICE_PAGES rather than sendpage. This allows multiple pages and multipage folios to be passed through. TODO: iscsit_fe_sendpage_sg() should perhaps set up a bio_vec array for the entire set of pages it's going to transfer plus two for the header and trailer and page fragments to hold the header and trailer - and then call sendmsg once for the entire message. Signed-off-by: David Howells cc: Mike Christie cc: Maurizio Lombardi cc: "James E.J. Bottomley" cc: "Martin K. Petersen" cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: Al Viro cc: open-iscsi@googlegroups.com cc: linux-scsi@vger.kernel.org cc: target-devel@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #5) - Split iscsi changes into client and target patches ver #2) - Wrap lines at 80. drivers/target/iscsi/iscsi_target_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index b14835fcb033..6231fa4ef5c6 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -1129,6 +1129,8 @@ int iscsit_fe_sendpage_sg( struct iscsit_conn *conn) { struct scatterlist *sg = cmd->first_data_sg; + struct bio_vec bvec; + struct msghdr msghdr = { .msg_flags = MSG_SPLICE_PAGES, }; struct kvec iov; u32 tx_hdr_size, data_len; u32 offset = cmd->first_data_sg_off; @@ -1172,17 +1174,18 @@ int iscsit_fe_sendpage_sg( u32 space = (sg->length - offset); u32 sub_len = min_t(u32, data_len, space); send_pg: - tx_sent = conn->sock->ops->sendpage(conn->sock, - sg_page(sg), sg->offset + offset, sub_len, 0); + bvec_set_page(&bvec, sg_page(sg), sub_len, sg->offset + offset); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, sub_len); + + tx_sent = conn->sock->ops->sendmsg(conn->sock, &msghdr, + sub_len); if (tx_sent != sub_len) { if (tx_sent == -EAGAIN) { - pr_err("tcp_sendpage() returned" - " -EAGAIN\n"); + pr_err("sendmsg/splice returned -EAGAIN\n"); goto send_pg; } - pr_err("tcp_sendpage() failure: %d\n", - tx_sent); + pr_err("sendmsg/splice failure: %d\n", tx_sent); return -1; } From patchwork Fri Jun 23 22:55:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291457 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 5520DEB64DD for ; Fri, 23 Jun 2023 22:56:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD7358D000E; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D616E8D0001; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDC0B8D000E; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A93928D0001 for ; Fri, 23 Jun 2023 18:56:00 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6E2E5120363 for ; Fri, 23 Jun 2023 22:56:00 +0000 (UTC) X-FDA: 80935522080.22.57CA687 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 920CDC000B for ; Fri, 23 Jun 2023 22:55:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZG3JSP6Z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560958; 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=DznK2AUeRuZJq7eWmkzDsLOFPhbrN3vu6EuXAdMNepE=; b=qKBQBExe4oenjtgRMdj+rYbRy0m5edn7pLuO1Sg7BQCmozQrWcHocdJZzEj8NgU9uPEJtd H+jbtDjghPoL50NKaIc0jQR0w0sqCGGIbLHKxu4D6d32mC+EHKy+cjLa7Z+l1Z5Dc5f9ee rE4U1ZiKfXbmEy1o35Utx2K/vsTJFjo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZG3JSP6Z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560958; a=rsa-sha256; cv=none; b=t8kgQ9vEsmAQXsxGgwsxqcJuoYRVEHPyAwQGpyQNepIf5KQGuI6CEdUopZzCOfsiDNyqI/ XZxS0u+SqIKZRRniki+Ictab0OPI8RHRxAngBiBXTNIAZAOiDrLfsfzsrvb3MYQwJjj0oh PduxcfB+c664F2nMv7Nd7g4XZ7P6+LY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560957; 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=DznK2AUeRuZJq7eWmkzDsLOFPhbrN3vu6EuXAdMNepE=; b=ZG3JSP6ZUeHVqA7r+JNZ0VcHokhKWfxGdkCkFSZ4xohgnS0S479xhNIWGytlgoVsxTZSx5 C5EKOM65Ywe0xhh3ldOT7tZ27CPy3ydNrXCH8rUT2JPosMIh/VheRoSGs+FnXhSvhNtY6y WaPjV4+KY0rTCrXJcxKpz4jTrd1bnDI= 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-91-scLXM6p0PSyn60UPmGbLlg-1; Fri, 23 Jun 2023 18:55:54 -0400 X-MC-Unique: scLXM6p0PSyn60UPmGbLlg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DCC862A2AD53; Fri, 23 Jun 2023 22:55:53 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8918B40C2063; Fri, 23 Jun 2023 22:55:51 +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, Mark Fasheh , Kurt Hackel , Joel Becker , Joseph Qi , ocfs2-devel@oss.oracle.com Subject: [PATCH net-next v5 13/16] ocfs2: Fix use of slab data with sendpage Date: Fri, 23 Jun 2023 23:55:10 +0100 Message-ID: <20230623225513.2732256-14-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.1 X-Rspamd-Queue-Id: 920CDC000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5mftsekdt6kfmknt8z3wwxhi4r69bqtc X-HE-Tag: 1687560958-526326 X-HE-Meta: U2FsdGVkX190XwC1uAfVhm3NMtUNMf9Ch6CASQNvHwK98MVj1BgN+mYkaRzy3P11G2PZ9yVMyU77fy8zrCsQS784f9X1CUQk9Nex/yMFj446JR2igv+WmaLI7/Xy8u8NgVPAa2VfHEUKBUwX2YnsZUywb0amfXBFFPjjf5AecXyzIvYoIHuX/yEFgynnXBqcJ5Bsjuwo82fgJtRTdUpx6QmJ2LQk4sEivVHHwziJnrbFMFhvsRuiDDfMyk8DaFQS4ndLWUqJzR2zPwrcqRlB7ZC0YHJqsQKEk3+8wJ0hmpOc7DRxjoSd00+n/UvM1UwpskRH/ajQihNzhN2LHJzeR4nx7HYZyk28/zAoxpS8D5oLhQejRdpNBCR/7oZRgL4lnCbrCQWSrOu7xBfuxFlcnXrqPDgp8HCzYcIxB3wsskY5hcUJj0amoZ2s5JFgqlhIOSoAgrGQCaUEeJ6k72wLEI8VFxwJKcJDOo+p5T/fdF2/8H6w01umLtt3he+Fbt4008kbWE1rnhC47yOFOvoAlEAuCK5tY/KX6IMTqewpGUD71vLnml54WIaAe4F2WAFIOvmQcQ2ctDfdxzYmJaQqGLKqJyed+uCzJ/Aql19DKWfNO9I9iUmGF3vDZUL1GerN9+2ZElVid9ZGhUxiyhHZa823Af0oUhDt/VJmCTtDkLSiB85eNeIIKr+MmGJqp9BMyhzPA34bDQT14zjuM1arBHlUasRB2V9QAIhnuJFRrQw2tmwvipua2Wjdgh7ehw3xA1DzCNNMyCwH5u++2+AmvYOfA91BR+OV9IDMkJkw7MR9mbp499VNYByIrDYIoedsOqB7SAxsjkK+F7z5leI77oDUyAU0TayBnCiR/b1vGvUYjN2SopHex34yBCCTkaIt95ZHX7guuSl9HTX7twTTBdqz6d2M5GvGzIiD9SgsjiKBZaZWlghxW3nkK52bJGuo7TNf0qfC4DrcF/t06/o Q/XhorXn eDkFkY+P+Ynh8kK4O8PRJNInMiR0FrShzBjNx2Yayy3/lPGx+4hS1JBuPiRUDw47q+we1gg3EYGfSwWfk9XfsfiCH6lq5P+BQ1flrjSJfiB5wxmtNTpkgGtCSJjlk4uVRXi1rKiWeNddSA5oos4yxQLHni2jKHGW0hVhGgZQiCUB592WbAzux1wSPu3PyRxBeHmKyiHhLNKwJtvna4fKQwgBBHH890XZYcws/+jUPvX69wO7+j7eIZhkMVe4yE7rRKka1TVwMYtjkKC+a2DSAtMHcwPyO/xvJSlEyVY+wSg77hfuK9pX9f3vWComzVlwzdKVvlmW3uSb1UPt4oUg+8jzXYa7XKyzli3riF3OMEMzk5t1KJX4l9fDA/ArAmkjSHRaJ7ZrM3+o45i+tYiBzdr2VrNjlmsd2YwJjCuBxj2vz6If8W77PN/0Tie1wrGwaF1DgN4WFC7cFlg2xcmBlbhco3hqjP2M9orJ1Ab89jR2kzW3NImoT2auypzJ8Qir8GWxNL6HG7TrJPVJpTamMprJqWrFWo2FSPkZCc/dcjiT5k2I= 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: ocfs2 uses kzalloc() to allocate buffers for o2net_hand, o2net_keep_req and o2net_keep_resp and then passes these to sendpage. This isn't really allowed as the lifetime of slab objects is not controlled by page ref - though in this case it will probably work. sendmsg() with MSG_SPLICE_PAGES will, however, print a warning and give an error. Fix it to use folio_alloc() instead to allocate a buffer for the handshake message, keepalive request and reply messages. Fixes: 98211489d414 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem") Signed-off-by: David Howells cc: Mark Fasheh cc: Kurt Hackel cc: Joel Becker cc: Joseph Qi cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: ocfs2-devel@oss.oracle.com cc: netdev@vger.kernel.org --- fs/ocfs2/cluster/tcp.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index aecbd712a00c..929a1133bc18 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -2087,18 +2087,24 @@ void o2net_stop_listening(struct o2nm_node *node) int o2net_init(void) { + struct folio *folio; + void *p; unsigned long i; o2quo_init(); - o2net_debugfs_init(); - o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL); - o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - o2net_keep_resp = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) + folio = folio_alloc(GFP_KERNEL | __GFP_ZERO, 0); + if (!folio) goto out; + p = folio_address(folio); + o2net_hand = p; + p += sizeof(struct o2net_handshake); + o2net_keep_req = p; + p += sizeof(struct o2net_msg); + o2net_keep_resp = p; + o2net_hand->protocol_version = cpu_to_be64(O2NET_PROTOCOL_VERSION); o2net_hand->connector_id = cpu_to_be64(1); @@ -2124,9 +2130,6 @@ int o2net_init(void) return 0; out: - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); o2net_debugfs_exit(); o2quo_exit(); return -ENOMEM; @@ -2135,8 +2138,6 @@ int o2net_init(void) void o2net_exit(void) { o2quo_exit(); - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); o2net_debugfs_exit(); + folio_put(virt_to_folio(o2net_hand)); } From patchwork Fri Jun 23 22:55: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: 13291459 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 9AC77C0015E for ; Fri, 23 Jun 2023 22:56:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39F7B8D0010; Fri, 23 Jun 2023 18:56:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 326E58D0001; Fri, 23 Jun 2023 18:56:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A1288D0010; Fri, 23 Jun 2023 18:56:06 -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 041CB8D0001 for ; Fri, 23 Jun 2023 18:56:06 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CB71A80368 for ; Fri, 23 Jun 2023 22:56:05 +0000 (UTC) X-FDA: 80935522290.23.36604E1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 00F4A140019 for ; Fri, 23 Jun 2023 22:56:03 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=guRayiJk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687560964; 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=6qW7QONKdXKQCe18ckz4PBDuqjad2A9AyVw+035R3zM=; b=x5qTRLRlRetdiYRR054vUIjEDwu52a+3b3LZkIvNocvrGjKCB8N7oS6IHOWfCIoj2jXqPV cJejqf5swW2bnLkWQvRyo6HaO2h8vwQdillkwvKNimz2I9+H8rXxZqoEgEzcL7KL5C+i3z Lu4JC3E9ZmZk89RhGua0xNMdxtHVSfU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=guRayiJk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560964; a=rsa-sha256; cv=none; b=zMZYzO7Ho/GL5+Dsf93rt3Mlxtb+/h47WisTjW7gvtaK++qTc6f2MWRDcMFzjs37iVOyLq BDTznd7JpY//MyvOmQtkfIeMK//BXPTInVOgg3KPYCNlbETsYdkwDwYPa5ADg3FfsBca4l YPbQiRJMhK2r6bbCzu1zThvwHOZ/0lM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560963; 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=6qW7QONKdXKQCe18ckz4PBDuqjad2A9AyVw+035R3zM=; b=guRayiJkGWDUKe8cvDufQG8DB0p50TtKJIkUyNQ+1UoLoaFcNGJUzvB6wxOSeN7jujFyDJ vpZU4HdczMuYAbVq5h/8zYGf90VjBHzcBoIRy8x9npSZSONZQ9/yPE/I5JZiBTrkS8qHrX II6zgPnXmvx2qSgxASdiqgU4bp7VPLI= 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-306-a9340YSgPS-PNmqg9L7xcg-1; Fri, 23 Jun 2023 18:55:57 -0400 X-MC-Unique: a9340YSgPS-PNmqg9L7xcg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 548C490ED21; Fri, 23 Jun 2023 22:55:56 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89A49C1ED97; Fri, 23 Jun 2023 22:55:54 +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, Mark Fasheh , Joel Becker , Joseph Qi , ocfs2-devel@oss.oracle.com Subject: [PATCH net-next v5 14/16] ocfs2: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage() Date: Fri, 23 Jun 2023 23:55:11 +0100 Message-ID: <20230623225513.2732256-15-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.8 X-Rspamd-Server: rspam09 X-Rspamd-Queue-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34aokD8j/279Nm03nv75eTbMgFZHOMDODQ2qtm96A2dV+a91+NuRghz5gWeg1oBoiO3k77fWhhSimJaCV25FkyA4KRmn796qutmil1gmFkxMM2aKHmGYKU0rJF8I0wvbme14ej4nGqRJY6XtAd840EnlxuNwRgaCEMzP7rPaHuMvGVRJ7t1r2M/HQFptTScD3nhr0skCgfQaY/78Ok6kOoNgLCkF2NJhsvvOcOe/F6Mdqu9JaaNxYAddxMsE9hua6+0WmXAHWOZSq59fHjQIO+mRMbZBvDb9FknTKY+qLtiUe4/BRvnUG/SlKQU1pvHfC3/hNLwnbbpTXHTQSTNVS9O/+8kUTDo81tIOzKtFG2S4AFuXETIertBMK82Q0Ndr7bKyOw1K4DscIz2mOurkjNqTzCz4mqKurZaPy5uT0oBHSyVvYWRYfQuIBCPmQ4CkogqdcDivvRpqlW3L6rLSgSSLMJ8aJazAzBQvXKnxsVBFf0MHy3g6RwVmtqlmSROsWdqWF6SO9Kl3VMykEG8SkaGT4MMUGDpMQLxOqddZGQNZG2IOVp0WmObtECSaYWzEwl7w8Y3e62E143mdaIkPw57 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: Switch ocfs2 from using sendpage() to using sendmsg() + MSG_SPLICE_PAGES so that sendpage can be phased out. Signed-off-by: David Howells cc: Mark Fasheh cc: Joel Becker cc: Joseph Qi cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: ocfs2-devel@oss.oracle.com cc: netdev@vger.kernel.org --- Notes: ver #4) - Use folio_alloc() for o2net_hand, o2net_keep_req and o2net_keep_resp. ver #2) - Wrap lines at 80. fs/ocfs2/cluster/tcp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 929a1133bc18..960080753d3b 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -930,19 +930,22 @@ static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec, } static void o2net_sendpage(struct o2net_sock_container *sc, - void *kmalloced_virt, - size_t size) + void *virt, size_t size) { struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); + struct msghdr msg = {}; + struct bio_vec bv; ssize_t ret; + bvec_set_virt(&bv, virt, size); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bv, 1, size); + while (1) { + msg.msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES; mutex_lock(&sc->sc_send_lock); - ret = sc->sc_sock->ops->sendpage(sc->sc_sock, - virt_to_page(kmalloced_virt), - offset_in_page(kmalloced_virt), - size, MSG_DONTWAIT); + ret = sock_sendmsg(sc->sc_sock, &msg); mutex_unlock(&sc->sc_send_lock); + if (ret == size) break; if (ret == (ssize_t)-EAGAIN) { From patchwork Fri Jun 23 22:55:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291460 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 836C5EB64D7 for ; Fri, 23 Jun 2023 22:56:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F02B8D0011; Fri, 23 Jun 2023 18:56:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 179E38D0001; Fri, 23 Jun 2023 18:56:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F35B38D0011; Fri, 23 Jun 2023 18:56:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DFD358D0001 for ; Fri, 23 Jun 2023 18:56:11 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4914DB0EE2 for ; Fri, 23 Jun 2023 22:56:11 +0000 (UTC) X-FDA: 80935522542.15.FD0B4AE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id A520A2000C for ; Fri, 23 Jun 2023 22:56:09 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=egn52Y3i; spf=pass (imf13.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=1687560969; 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=xQVg0pnXVfTxPUpA8yd29SmocczyZN6S+xS0BIA8ljI=; b=d+ceQDUWFD1iw1W0komnCigQvz3w7xdun2mIjo6LMC/BlDonxWXEIpTmmpqFI67uUHE1AR nWcHTv9rpDB9uKVun019IAnC8FuirvhkWNcq6JZ4kXznzXefyhOFywVGebJ18lEemtSHxp QKiK6ZFF9GtWN78OykFenJtNQdSowko= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=egn52Y3i; spf=pass (imf13.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560969; a=rsa-sha256; cv=none; b=sljw8v8llghGRBuncOVdq2pdGTrNfVUWzALRqwCPn8yuBEzLx+OweCgdynq4JDPECi53px iw7jt3SyMWKm7uxJ0USsTHxctL9yqq/n2EgWOlkGg+AXXAe803ba7CD/W9T3659q+/a0Oh aTjrL/ySwWTMw+ZDWO3HyBqP0s9tTF4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560969; 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=xQVg0pnXVfTxPUpA8yd29SmocczyZN6S+xS0BIA8ljI=; b=egn52Y3iCc4T0jlkJXlN7JGbq84m7ec2h/QiterIF+76BA64CPcxAL/YUq63+B6hETzQQW Y23Nv3JgKm3XXjvwgRx1rpg8w9PHpB/JNV1Dxt/2Z3zjpGTcG6DYPahiRCM1PBT0nSPfLw IOpZNh1wPBkJqAqvVq9KVgceB6tOI9U= 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-392-ui08z6zkOsOzsb7oEUVtzw-1; Fri, 23 Jun 2023 18:56:05 -0400 X-MC-Unique: ui08z6zkOsOzsb7oEUVtzw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2C7B7185A78B; Fri, 23 Jun 2023 22:56:04 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 240AF492C13; Fri, 23 Jun 2023 22:56:01 +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, bpf@vger.kernel.org, dccp@vger.kernel.org, linux-afs@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-can@vger.kernel.org, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-hams@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-rdma@vger.kernel.org, linux-sctp@vger.kernel.org, linux-wpan@vger.kernel.org, linux-x25@vger.kernel.org, mptcp@lists.linux.dev, rds-devel@oss.oracle.com, tipc-discussion@lists.sourceforge.net, virtualization@lists.linux-foundation.org Subject: [PATCH net-next v5 16/16] net: Kill MSG_SENDPAGE_NOTLAST Date: Fri, 23 Jun 2023 23:55:13 +0100 Message-ID: <20230623225513.2732256-17-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.10 X-Rspamd-Queue-Id: A520A2000C X-Rspam-User: X-Stat-Signature: 8d94tsc4w687tedwui74jgydrstm5n34 X-Rspamd-Server: rspam01 X-HE-Tag: 1687560969-510534 X-HE-Meta: U2FsdGVkX1+KHYRkz4MOOQcrUtHBcyemvD8IC+9iJ8gTe/Fx598Vr2T3bypPEZ6Gib35KSz/dKK6jL5x8YRUDK4BLLoHVsfn0mO80VY1oJifBI+4fCh4lWWmznhpB6Li9gOce6qJfFJpWNz5u5YNgKdrKZCkV9azVB9m5wp14pP95yt8rK6WE01JGbm1twOLSIXilq0S6s9g/u5KxXiv/P1XUSfbyCcyciufj+POsQcgr+SkxS9Ckcp1QHlZvHk3NZ6kqfaJik+mKo7X9snPiZaDgDR9zhPugzoOf4Regv5Wd8YpOWe2la/KbFdVAA16RXm3AJrgmsQiZ7pYFnwQm+GA0o9I3EBncXgW10HY5nRlGvke+LuaIYofk04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qFQcjyfuSgNyhR9fFdIF70xSA/H7qLUa9pKT3oNXCrMYSL/FdSunMyQ3ZmdhkPlaUgYmymRw5dRAL8X49vbqolxnlMCFlcRL/9OzswKsX09BYvrfmcQY/Z5EfP5WfY2MrnhkNKAWdqwoI7n52OP/ 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: Now that ->sendpage() has been removed, MSG_SENDPAGE_NOTLAST can be cleaned up. Things were converted to use MSG_MORE instead, but the protocol sendpage stubs still convert MSG_SENDPAGE_NOTLAST to MSG_MORE, which is now unnecessary. Signed-off-by: David Howells cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: bpf@vger.kernel.org cc: dccp@vger.kernel.org cc: linux-afs@lists.infradead.org cc: linux-arm-msm@vger.kernel.org cc: linux-can@vger.kernel.org cc: linux-crypto@vger.kernel.org cc: linux-doc@vger.kernel.org cc: linux-hams@vger.kernel.org cc: linux-perf-users@vger.kernel.org cc: linux-rdma@vger.kernel.org cc: linux-sctp@vger.kernel.org cc: linux-wpan@vger.kernel.org cc: linux-x25@vger.kernel.org cc: mptcp@lists.linux.dev cc: netdev@vger.kernel.org cc: rds-devel@oss.oracle.com cc: tipc-discussion@lists.sourceforge.net cc: virtualization@lists.linux-foundation.org --- Notes: ver #3) - tcp_bpf is now handled by an earlier patch. include/linux/socket.h | 4 +--- net/tls/tls_device.c | 3 +-- net/tls/tls_main.c | 2 +- net/tls/tls_sw.c | 2 +- tools/perf/trace/beauty/include/linux/socket.h | 1 - tools/perf/trace/beauty/msg_flags.c | 5 +---- 6 files changed, 5 insertions(+), 12 deletions(-) diff --git a/include/linux/socket.h b/include/linux/socket.h index 58204700018a..39b74d83c7c4 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -319,7 +319,6 @@ struct ucred { #define MSG_MORE 0x8000 /* Sender will send more */ #define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */ #define MSG_SENDPAGE_NOPOLICY 0x10000 /* sendpage() internal : do no apply policy */ -#define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */ #define MSG_BATCH 0x40000 /* sendmmsg(): more messages coming */ #define MSG_EOF MSG_FIN #define MSG_NO_SHARED_FRAGS 0x80000 /* sendpage() internal : page frags are not shared */ @@ -341,8 +340,7 @@ struct ucred { /* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */ #define MSG_INTERNAL_SENDMSG_FLAGS \ - (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_NOTLAST | \ - MSG_SENDPAGE_DECRYPTED) + (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_DECRYPTED) /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ #define SOL_IP 0 diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 840ee06f1708..2021fe557e50 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -441,8 +441,7 @@ static int tls_push_data(struct sock *sk, long timeo; if (flags & - ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SENDPAGE_NOTLAST | - MSG_SPLICE_PAGES)) + ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SPLICE_PAGES)) return -EOPNOTSUPP; if (unlikely(sk->sk_err)) diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index d5ed4d47b16e..b6896126bb92 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -127,7 +127,7 @@ int tls_push_sg(struct sock *sk, { struct bio_vec bvec; struct msghdr msg = { - .msg_flags = MSG_SENDPAGE_NOTLAST | MSG_SPLICE_PAGES | flags, + .msg_flags = MSG_SPLICE_PAGES | flags, }; int ret = 0; struct page *p; diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 9b3aa89a4292..53f944e6d8ef 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -1194,7 +1194,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_CMSG_COMPAT | MSG_SPLICE_PAGES | - MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY)) + MSG_SENDPAGE_NOPOLICY)) return -EOPNOTSUPP; ret = mutex_lock_interruptible(&tls_ctx->tx_lock); diff --git a/tools/perf/trace/beauty/include/linux/socket.h b/tools/perf/trace/beauty/include/linux/socket.h index 13c3a237b9c9..3bef212a24d7 100644 --- a/tools/perf/trace/beauty/include/linux/socket.h +++ b/tools/perf/trace/beauty/include/linux/socket.h @@ -318,7 +318,6 @@ struct ucred { #define MSG_MORE 0x8000 /* Sender will send more */ #define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */ #define MSG_SENDPAGE_NOPOLICY 0x10000 /* sendpage() internal : do no apply policy */ -#define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */ #define MSG_BATCH 0x40000 /* sendmmsg(): more messages coming */ #define MSG_EOF MSG_FIN #define MSG_NO_SHARED_FRAGS 0x80000 /* sendpage() internal : page frags are not shared */ diff --git a/tools/perf/trace/beauty/msg_flags.c b/tools/perf/trace/beauty/msg_flags.c index ea68db08b8e7..5cdebd7ece7e 100644 --- a/tools/perf/trace/beauty/msg_flags.c +++ b/tools/perf/trace/beauty/msg_flags.c @@ -8,9 +8,6 @@ #ifndef MSG_WAITFORONE #define MSG_WAITFORONE 0x10000 #endif -#ifndef MSG_SENDPAGE_NOTLAST -#define MSG_SENDPAGE_NOTLAST 0x20000 -#endif #ifndef MSG_FASTOPEN #define MSG_FASTOPEN 0x20000000 #endif @@ -50,7 +47,7 @@ static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, P_MSG_FLAG(NOSIGNAL); P_MSG_FLAG(MORE); P_MSG_FLAG(WAITFORONE); - P_MSG_FLAG(SENDPAGE_NOTLAST); + P_MSG_FLAG(SPLICE_PAGES); P_MSG_FLAG(FASTOPEN); P_MSG_FLAG(CMSG_CLOEXEC); #undef P_MSG_FLAG