From patchwork Thu May 18 13:07: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: 13246763 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 E11CBC7EE22 for ; Thu, 18 May 2023 13:09:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FE2E900006; Thu, 18 May 2023 09:09:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D282900003; Thu, 18 May 2023 09:09:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 699DD900006; Thu, 18 May 2023 09:09:35 -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 56C10900003 for ; Thu, 18 May 2023 09:09:35 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 30CFB1607EB for ; Thu, 18 May 2023 13:09:35 +0000 (UTC) X-FDA: 80803407510.09.63D51BF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 66C8840054 for ; Thu, 18 May 2023 13:08:11 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XCUeT6b0; spf=pass (imf01.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=1684415291; 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=tEe6KsGIUg5Ug9eymZUK4cq5L1lxhWlwpIXxPsGo3ck=; b=Gtbrj4V9fGY8ezu/RBjlHMvpa0NvvPym15rrNXPjm6H8HDNoOW2TM70XeJ4ycFq4z+bvl0 ufixvowgDPQ26xNDA9SQeCpL+yiXxDjYH8yew/AS68LCtB4md2jmqEpTSoUktipxSRy0Cc R2XLVhud0m+Ps6xeoU4CLFXHxB62EII= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XCUeT6b0; spf=pass (imf01.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=1684415291; a=rsa-sha256; cv=none; b=gdAUc0hnELHJOSmb5krFi7a/XqS5kn2ZaKPRnswpmuGyYQpTP9IzwdUaMxKks0HsCL86PH +VBTiQgwmlLO3B2p9MOcx2T/bX8+1Mk8CqPrJc3ooHPCddEzAR7jUhhWN6cHth1HxSnZg/ wBtH/mDF34uKK8pdIRoFIO1IedgdqlU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684415290; 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=tEe6KsGIUg5Ug9eymZUK4cq5L1lxhWlwpIXxPsGo3ck=; b=XCUeT6b0Tp8is9iTB0w181Crn2QgYjMfVB6U55XRZ36yejHqAmhSYBiN7o+K65thiNlR2T sfblU74xQ5nZnD3Jz+MBngR40S1G60htz5U/F80p6Uvt5qwqweYf2qciYx6d48AQFewIsA PjVDQd5uvPVMUWP8jdTawBWnsCFkoFY= 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-159-rWJ6E0svM2ScwbkcEaLtzw-1; Thu, 18 May 2023 09:08:03 -0400 X-MC-Unique: rWJ6E0svM2ScwbkcEaLtzw-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 CE5503815F79; Thu, 18 May 2023 13:08:01 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DF3B492B01; Thu, 18 May 2023 13:07:57 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Chuck Lever III , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Bernard Metzler , Tom Talpey , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org Subject: [PATCH net-next v9 09/16] siw: Inline do_tcp_sendpages() Date: Thu, 18 May 2023 14:07:06 +0100 Message-Id: <20230518130713.1515729-10-dhowells@redhat.com> In-Reply-To: <20230518130713.1515729-1-dhowells@redhat.com> References: <20230518130713.1515729-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 66C8840054 X-Stat-Signature: wkypfeycbj43ex4g8eysxwjp1ajxbdgt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1nL4BtHt6bblCT2ltIFM6NiW8LdmuhWu8Q5ICxq0reUgaDtndqG/pvqOD3ApmRbbBcLwk43/oOLHQ1v4IRQL2++viW0KWE8WOEWQ3Zm/6CXosJt/0mLaLyJhdJjAkY75H2TQ6WJG2ojKmpDyJQLplCmgjI60UXUSH5R+MmLs02DBhBvBldMDkDSh4kcsu0BJGTj1DjdZKKPw9UatBouxTGtcMBKjZ3AmrvCuFdN4BSvNaTkVN8Co6lI0rpG57edTBmj0Ayeflv2zWZaRLkalbjukW9JhpdGCtb+HEV+v43fsGTjdUoK/XvfxLLQE9Jl2wfy/CyfjkXumrh2F7Ub3qidel85/J+4T9azigtlO51y8cvDv0Bh5MvLNbsXQi3KVukuka0zh79zcM/GRKiXWHCpAtqPSyWduskAVSlMqDsdnRiB04a+QIK35COF809J9p9akdXrIXk/tE7YWKj5lt0mfDcmeBwFRc4xkf5QBtw34Lpg72JSlLEvoBEn/HwXXvAQDSnLB084pU+uIzU4w0fZXHZdubA9ulxyT5etIbqyQmcOjZeDCIFpYkVyS/Si 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: do_tcp_sendpages() is now just a small wrapper around tcp_sendmsg_locked(), so inline it, allowing do_tcp_sendpages() to be removed. This is part of replacing ->sendpage() with a call to sendmsg() with MSG_SPLICE_PAGES set. Signed-off-by: David Howells Reviewed-by: Bernard Metzler Reviewed-by: Tom Talpey cc: Jason Gunthorpe cc: Leon Romanovsky 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: netdev@vger.kernel.org --- Notes: ver #6) - Don't clear MSG_SPLICE_PAGES on the last page. drivers/infiniband/sw/siw/siw_qp_tx.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c index 4b292e0504f1..ffb16beb6c30 100644 --- a/drivers/infiniband/sw/siw/siw_qp_tx.c +++ b/drivers/infiniband/sw/siw/siw_qp_tx.c @@ -312,7 +312,7 @@ static int siw_tx_ctrl(struct siw_iwarp_tx *c_tx, struct socket *s, } /* - * 0copy TCP transmit interface: Use do_tcp_sendpages. + * 0copy TCP transmit interface: Use MSG_SPLICE_PAGES. * * Using sendpage to push page by page appears to be less efficient * than using sendmsg, even if data are copied. @@ -323,20 +323,27 @@ static int siw_tx_ctrl(struct siw_iwarp_tx *c_tx, struct socket *s, static int siw_tcp_sendpages(struct socket *s, struct page **page, int offset, size_t size) { + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = (MSG_MORE | MSG_DONTWAIT | MSG_SENDPAGE_NOTLAST | + MSG_SPLICE_PAGES), + }; struct sock *sk = s->sk; - int i = 0, rv = 0, sent = 0, - flags = MSG_MORE | MSG_DONTWAIT | MSG_SENDPAGE_NOTLAST; + int i = 0, rv = 0, sent = 0; while (size) { size_t bytes = min_t(size_t, PAGE_SIZE - offset, size); if (size + offset <= PAGE_SIZE) - flags = MSG_MORE | MSG_DONTWAIT; + msg.msg_flags &= ~MSG_SENDPAGE_NOTLAST; tcp_rate_check_app_limited(sk); + bvec_set_page(&bvec, page[i], bytes, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); + try_page_again: lock_sock(sk); - rv = do_tcp_sendpages(sk, page[i], offset, bytes, flags); + rv = tcp_sendmsg_locked(sk, &msg, size); release_sock(sk); if (rv > 0) {