From patchwork Mon May 22 12:11:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250302 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 B9A99C7EE2A for ; Mon, 22 May 2023 12:12:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 960F1900009; Mon, 22 May 2023 08:12:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8737790000C; Mon, 22 May 2023 08:12:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DA1D900009; Mon, 22 May 2023 08:12:09 -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 4309990000A for ; Mon, 22 May 2023 08:12:09 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1B2D61C6F1F for ; Mon, 22 May 2023 12:12:09 +0000 (UTC) X-FDA: 80817777978.09.1D5DC30 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 478E7A0007 for ; Mon, 22 May 2023 12:12:07 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XIdQ5fH5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.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=1684757527; a=rsa-sha256; cv=none; b=Yi3h+PNhW6APp/vZI+KGICb85DEL90swtvRJkL/wz6O5PjbwXugjM8wHLt3D+pkXglw3lD OYTRr2hqRet8Hk/G5hC2SSEVRcjVud8zIYCwty0CoRpesk1tnimnfxqVGz5X6/BY10Hcit vUOAvPzW/BPkGnyK4SggSZtSrLqVE9g= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XIdQ5fH5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.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=1684757527; 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=lZd5zsjSz6+cqMIrBiUaNBHdTaE4GerFR+elBp15KiBK42/rQpJIlcc4Q9Lv4H2sER4ueI N5HMzZ+uI1nvBa+UyE4Xjqv7u2d7WL3c0/Q0eVnWNhjlI3BNCAZuY3XzWDuwHFVWZv3dWo EBdTOfX9VZMMqQHx+nZG886audDhb/w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684757526; 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=XIdQ5fH50MoeriXh9fss1Wtc3cR9HXNxgHbTfFuA5NS5gb70CXcaF8CCKptIKySpCoxrrR Nnm97s6uN/lyR2zRJyFKmPkTZFhumwzsekSLiNzWwHnfSdez/Dkm2S78FIKrsBSzkqVb4x ARwrWMaOwyQdyLT8IeQI6JukjtcV+cg= 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-474-MWYfU8vlNOi-xXlJkHtgaw-1; Mon, 22 May 2023 08:12:04 -0400 X-MC-Unique: MWYfU8vlNOi-xXlJkHtgaw-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 6F58E858F14; Mon, 22 May 2023 12:12:03 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BC277B7C; Mon, 22 May 2023 12:12:00 +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 v10 09/16] siw: Inline do_tcp_sendpages() Date: Mon, 22 May 2023 13:11:18 +0100 Message-Id: <20230522121125.2595254-10-dhowells@redhat.com> In-Reply-To: <20230522121125.2595254-1-dhowells@redhat.com> References: <20230522121125.2595254-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 478E7A0007 X-Stat-Signature: g3i36mfcb7ttjo3cch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btbPkpJlDTCYw8xUUoSlAwR35R1AoaDZw/DlCVJg0pVOz/EFxDxbWAWZ7zdXGPpgPnRgMd1lc6SjXZrp8WoHup77yUhheohCE1r62jSrCtTCSd4vLbVttdu9qpy/90VMGdbDhjOHWGIGfApVTQcfW2J7noPLfLBM0MtpVaGPRUZdJpUaizPLcOKGOHjPn580pPOHeLdke1GU4kpDBgutmQZS3Cq0h8En3OmOxV4p/kRRmpfAwdFpDK5ZQud6ZeNicabD7+NZeAiuG6FlhXkyLtkM4ytqkgt746w6u6Xi/8A4ucgjopC5uQOWS6tjjbNeUq/Pz1KZW7DkSZDxrhp7Tr25P7HPC0huRwoaLdgVwJsoJpaGSYUyzXlAT3WEifCIdAy29TZc9TTkv1tef09kclk51SxD2hai0lVvYz4ooYTawlFJIOMRDl1uYMnI8fdkL6MnqJ9xbEAxojmAiqmWdsqlmbzM+GfggBHWt1GSbsv8WReiyfv8WkYjzCclotF2i8wUjRjud2Pd+e+I/FskYi9LFKacpXHpUgWg45t8DrkGddbggwaUDlWDB/ihYVvEmxre92/tG1G7hBVg43hW53xsqizx5f 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) {