From patchwork Thu May 18 11:34:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13246570 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 8D06DC77B7A for ; Thu, 18 May 2023 11:35:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 31166280006; Thu, 18 May 2023 07:35:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C134900003; Thu, 18 May 2023 07:35:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 188F290000D; Thu, 18 May 2023 07:35:51 -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 08D5E900003 for ; Thu, 18 May 2023 07:35:51 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 90AC3A081E for ; Thu, 18 May 2023 11:35:50 +0000 (UTC) X-FDA: 80803171260.20.03CB947 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id A475380011 for ; Thu, 18 May 2023 11:35:48 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SiJDKULR; spf=pass (imf30.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=1684409748; 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=Cj+Fpv0LQNhPPzvttl67HM01GX1KmlTGfn3vyCHI8mM9cyfn+VayUe2ULLcRXqcgNQyzk/ vxd8OcirG9J2kWQhS/iELy7ahnOZBhk250NkEmtDhC2zR9FdxvDM+V4QdaLduPG2+/CYKf PZvAzlYei3DexkcS1X3Y5EhgTm4a6Mc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684409748; a=rsa-sha256; cv=none; b=DaW0tin5hzmggMXvgXe0P5+rYDTn3F+/VUuRYeedPyeBDlFmpdWXKo0uOMoEm5rP2priOl DoBE3SGKJU7Na/fwbgY99Z4MfYunBJmQCGS9WuXpqjc/vQX0OaFNl30XgzLMEF3qvNoydP ZXhF0H7CIAcZw4/UuQQgr5gGwQiGsmI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SiJDKULR; spf=pass (imf30.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=1684409748; 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=SiJDKULRY4pVNSIqdnDURgtwkZNATMrf7S57oVVXI4TXBjr9Rs2Mq1RMjsM5ADvmqqcx9b 2Se0/DHKh/91Vp59XrTSU6RlfbKKIZPd7GbXZacV1R4hDRETU+FjdGuNnF3dogc/+n0JPk tZpQvleFXCOVmFLU0pCIevxPGTHxO2Y= 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-146-D-Rd9ENnNDKPveHNDxPUbw-1; Thu, 18 May 2023 07:35:43 -0400 X-MC-Unique: D-Rd9ENnNDKPveHNDxPUbw-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 B38E010146F8; Thu, 18 May 2023 11:35:42 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1878240C2063; Thu, 18 May 2023 11:35:39 +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 v8 09/16] siw: Inline do_tcp_sendpages() Date: Thu, 18 May 2023 12:34:46 +0100 Message-Id: <20230518113453.1350757-10-dhowells@redhat.com> In-Reply-To: <20230518113453.1350757-1-dhowells@redhat.com> References: <20230518113453.1350757-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Stat-Signature: ps1bq8hk5wog5miz1sp8oqdkzzfxtmyg X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: A475380011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Ev74K2SX2IfBt+uxpozXbxyX3OpAhnsNcx9FIchNq/XoUxC7cz4XykYgi9IQEszt4uayGMODaJg5tMBWJxvEXepmv3AjbFMhr6I0GpRHU9Mr/a1CnRvuwMOntUrnbEXLZ7gIYm0Uxt58RhW1KevqPXZfsQvv1VpB/oToBkIW1C9/abe5+OQcRnDtYeBcaLwP0r+Mm/SShErBtFVhkKF36n7xp+K1sXAJKgYzDZRgGm+IBdTfYqbAUuMoSsMB9rYi2Sx4dpwwKIG1s0vDuKF/dIUfiqO1L7d7LOHr1p0c9Tq2YVjje/mcxGXTZqn2uUdXnnpXtMhdLcG4FRqhajeX0TShqv4JGwKWYXo0NuohIhIIZCv0t9rKplNMAV68K619oBZwmjhP0rKpPPjk6CehXVh+kmfVpq9df8XaZreiCain/OxlIPLYntwAK4d2Z4sKX/zLOV77SHFrJfpAJQ3iHHg2L5SpL+a9SzcZ/T7q/KRczjFPQfLd8yGqsS/W2yZ5KzDzoCFLJqMzsJDC2wi/01W+wyOOUYupsm/kHXmwjGzNG7mI4D0tc/DCIjSAWWE2niERODD1Ro1VLs 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) {