From patchwork Tue Apr 11 16:08:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13207818 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 1D6C1C77B6F for ; Tue, 11 Apr 2023 16:09:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A85EF90000A; Tue, 11 Apr 2023 12:09:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0E03900002; Tue, 11 Apr 2023 12:09:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8870090000A; Tue, 11 Apr 2023 12:09:54 -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 72416900002 for ; Tue, 11 Apr 2023 12:09:54 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4D6C8120DA5 for ; Tue, 11 Apr 2023 16:09:54 +0000 (UTC) X-FDA: 80669596308.24.B7AAA79 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id D93654001A for ; Tue, 11 Apr 2023 16:09:50 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Bg46C7SU; spf=pass (imf11.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=1681229390; 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=rMhKzvuG7s1VjfB4heYphcINA7j4rSAbIEKmxFNidXY=; b=GosgysCVytl5bXQ0OWPYdrAnpop9n5XE99mQOe3wM3c699kC8WErkUcAbllF0lblPHsvnP 7FNfT7+o1LINxKWqn8PuvTwxpwfOKhiNg6/WThmDsP1M2bQOn0PJkpLoknEr9+YcNpR6vy oRo0dK/Fqm/nIBRJoPNgvKQ6MOjR1r8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Bg46C7SU; spf=pass (imf11.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=1681229390; a=rsa-sha256; cv=none; b=2ntiTvRxkFMcj7oCq1XqOrb556bMMnMiGXhzVWxOfeLbLlQFUfBt2Kr6A/xQ9kJRZ/E1Dw n6vBQzTzJkaIKFi7XGk5shg+48leXg5Tq3mqJeS6a6Qbuq2h+qQw+YT86O5nEb0auSoR7x Ed17uMH01rU3+t5UYP43B5xx0+SIURM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229390; 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=rMhKzvuG7s1VjfB4heYphcINA7j4rSAbIEKmxFNidXY=; b=Bg46C7SUgV/OdaFKIDQ1M25tlYJAcRUQmwNd0/2nWQWvREF8NJK4Gchgoq5omK3V9zxZ3s rawl5095LXzqzSFMPK5bwkB89MeQK58UgHplr3/CNYjsTQdGVWkBYfEZDD8wK3/Xr3jt30 z8dtb6hhRJUbGsvfSSxdw28jscTb3Xc= 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-552-Zov1PRTBPSW9DUg0cv7v9g-1; Tue, 11 Apr 2023 12:09:48 -0400 X-MC-Unique: Zov1PRTBPSW9DUg0cv7v9g-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 794D6185A7A2; Tue, 11 Apr 2023 16:09:47 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3F9D47CDC; Tue, 11 Apr 2023 16:09:44 +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 , Jason Gunthorpe , Leon Romanovsky , Tom Talpey , linux-rdma@vger.kernel.org Subject: [PATCH net-next v6 12/18] siw: Inline do_tcp_sendpages() Date: Tue, 11 Apr 2023 17:08:56 +0100 Message-Id: <20230411160902.4134381-13-dhowells@redhat.com> In-Reply-To: <20230411160902.4134381-1-dhowells@redhat.com> References: <20230411160902.4134381-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: rspam04 X-Rspamd-Queue-Id: D93654001A X-Stat-Signature: gb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SMxIXVEZCqPu0vH08eYsb0R1JAGt5sljCyP2OingYg/9DAs1Ub7mnje/kFucjNNZ8K9t3hSsCB3EXGql0ApWjWBTHADIg2X2UUWdB0PwZIQ44jEsZhoqDc2G4gdeqfNd/Sg6b3s4+V/dG0y2J0MBgtPWSuvd1SCU4Xdsn9PhKH0iCLZpxC4KVqDp/RI2x253k5kjWfBeZt8HjKnew80XhsPX3PkjvsgZgDvnW9iFfU9409cceAkE4r2bsyTwN6BTuSB5lxHLM3kLFgO4OLI1wBDjcguh/kK7ONcr4u5tWZkzE+9bodukV78P1031MMiGuAtmD/VRtGD+v1cPSlbWkGVxwMwfbLQ86on2icyUXXCu8bOCnja0tRrC2WvYadQ+eWax0p6j3L6pVNc4pAClbWMWUz38UfU5b4HQhTL8qi8aPS/VIdgay4T0mBr3dSlFAEb9L4ojRlECLicGwnkTguuCYOCmszs4mIeRQusYwi6rGGjzVeaA70gQSBJHihNqP+7ULKPqey4N49hbMjVJRTXxOUFFrswBzsPcddkSezjHrgzIXCzT5UlWQfomQH7z9c0pCGVWZPtcrhNdHYn0XI1mN9ZOswaK14VBsjKE1QUjoX2IC/OYw= 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 cc: Jason Gunthorpe cc: Leon Romanovsky cc: Tom Talpey 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 Reviewed-by: Tom Talpey --- 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 05052b49107f..5552e60bb927 100644 --- a/drivers/infiniband/sw/siw/siw_qp_tx.c +++ b/drivers/infiniband/sw/siw/siw_qp_tx.c @@ -313,7 +313,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. @@ -324,20 +324,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) {