From patchwork Mon May 15 09:33:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13241089 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 CB390C7EE24 for ; Mon, 15 May 2023 09:34:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 524D790000C; Mon, 15 May 2023 05:34:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AC76900002; Mon, 15 May 2023 05:34:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34D0790000C; Mon, 15 May 2023 05:34:37 -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 1D7AE900002 for ; Mon, 15 May 2023 05:34:37 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DAF1281381 for ; Mon, 15 May 2023 09:34:36 +0000 (UTC) X-FDA: 80791979352.21.CCD95AE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 25C7F100012 for ; Mon, 15 May 2023 09:34:34 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OdPxdO8D; spf=pass (imf05.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=1684143275; a=rsa-sha256; cv=none; b=bQ1purf9QgzHj5YzHhSTAB1sI7KFKO9wU2pwyDn4EBQ58Tj6KeMt0rcWR4ad1AjJrwY0kW DsIzZDzBhR/6z16TZXACPn2NcEa1Emqqxz/5KFDGSMNI8PwlAcqZ8eaSrotjUoEMlnXUwx dASpQRaY/suEKZsGMibc4K+f9INpoJA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OdPxdO8D; spf=pass (imf05.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=1684143275; 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=Zt5BwGD1X6vtlqkgQBdguh8pwbJrz7VpVFMxJwlVpGWtMIHA+RXXiefl7El1b25nzehJbn 6w1dAiQF4T05pZgGJ1DMlVjGJ/3eztfCtYBAxkaryUAVYnnrT1oxdF7FnQgTi/FNG1pd7C 40ONy8zjWEfPWCQSAnk8kyVgB5X1DFc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684143274; 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=OdPxdO8DFhPRe+KQNXGqPz0goIuh6Cz24y23ZnczbWxojkORWecMZaWZjrXSgqAl2Akw0m AuoA1yKaNgU3IwilzM5kExlNAObSlvd2FMJyLdcUimszQRSlAOOqHRvdW7UWtg715DoP/B BpGpSdjXIwBEOS8pLlVPYJX2g1f4LR0= 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-428-lT4Ao4tgPxOf3GaRnh_sfA-1; Mon, 15 May 2023 05:34:31 -0400 X-MC-Unique: lT4Ao4tgPxOf3GaRnh_sfA-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 02F81185A790; Mon, 15 May 2023 09:34:30 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 270BD492B00; Mon, 15 May 2023 09:34:25 +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 v7 09/16] siw: Inline do_tcp_sendpages() Date: Mon, 15 May 2023 10:33:38 +0100 Message-Id: <20230515093345.396978-10-dhowells@redhat.com> In-Reply-To: <20230515093345.396978-1-dhowells@redhat.com> References: <20230515093345.396978-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Stat-Signature: kmyhwpftdfodxcrrymwk7pdedfyoe1n8 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 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mhkdlPMjuNrRIJAP5Vw65//DuHPDO7iBlQ8AqEDQ3nHUx+dy3+5ZC5mcjMHGjzKzljwIFhTRC6S8KFQVRXoOXRSiVEFTAxznidw+QzplKtUlsbK1Q4tNlRJkgWx1bjA8Uqs87zm872733U8KywREsWkyFImBFZAal0/5RLUuBWRh2CRZ4youb210xPGD7XSIpJUPlFwOtSK5pJvgIxfif1wa8LweeXZJ0IoC9MsqfXt7sl1NtjH/+PaNwfjIpS3RFdgCEVFnzK577JW/wnK+35bHL1eBSyhlDXDa1wojmMdoVtfJkaQK2JaV0wkgFZuCkjkq8aMvoNnE8apAzlHBbQdNQdpQuNG5Ct9dQevd5Z1wkABHJwTtgV+HRS0NodZ9z2dWZkl0wrZn/p5EWg645G2kQe3ZBsWx1FRqLRJn/rULsEkPnys1bMxJ+8d44CG2tkp17x/6C9j4DzLQ0cUPCNWxYgGO4JBluZxegFezoT+zpuXplD6x9o0QVd89S2L/0512s3rUv+tgwwWO+lSXTywrR7NXVLC79bUtM02E+nK2hMZpE9yVN5FwFSfxhsStZzjDqzYut 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) {