Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5731983rwl; Tue, 11 Apr 2023 09:12:41 -0700 (PDT) X-Google-Smtp-Source: AKy350Ys4C+fiUM+DV/CcLCdqMyCSLk3C1KuGA2jl+5ojL3KpqkjGM3Ye03ZU21x76SUohi3lCvS X-Received: by 2002:a17:903:284e:b0:1a5:3056:3c95 with SMTP id kq14-20020a170903284e00b001a530563c95mr8455879plb.68.1681229560777; Tue, 11 Apr 2023 09:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681229560; cv=none; d=google.com; s=arc-20160816; b=dVYyx0hXeAopqn5bi5oID2xxr12QwL89B24bSUqHOK22hHaK9ohCo5tjmi4xrRp/yT iaTJFlJA9DxERQbN03b27iSO7bvRFwmWlIvz+34ylbU8IT8iuJ5T2ygi1Jm76TFSSxnQ p1gCSCNKcAzm7b4rnrDQjy64bcFO5HKF+9Aj9agb0bLs4s0/feUdKErNbeiMKzG3FoQx 8nSGSdgmwHATuWfeZXwCZrlBQxLwhjRPh5beD8TxxNWUrSC9OL11elrplTrdeIUaSWMf mDN0ELQAw6NcIs7zayGnXGJkejmLOwUhb8P0XiIeVqer+/C3OnZh4i6nW2QcOZKX8dn0 5c7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rMhKzvuG7s1VjfB4heYphcINA7j4rSAbIEKmxFNidXY=; b=jNfvyEW47wedFXHcHUPHoYLMd/tLx28qHbnh2TC5O1BcjleZRZv7vCyO9zOZFy32Qi fo/qOLVMpFuRK7s4fypwbNmSdYvCk9cimZU4zIWMAjI7qbRv56VgjCjYmKTPAT0AAWT8 kD4yzjFjC7aERv8lVJI8X1OR9EQFFvNh1x4GQ2GmPBala5AI+DvIUTym1s74NCZ6iWgX lwlC1xPKc7y4VI1WUPmF3sud0QjOk3vCuYcYNvOhhMZgSSJ+UMwGbDuyUwe0eSVbDRrI 1LnjWvmUotBxqpbF47/pV0F9k1fouOeFrTooLFfYZw+6sEH9PEsouczkvPJSfvGjj0vN xjhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LAipuDez; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020a170902d48200b0019931c82e24si15468804plg.195.2023.04.11.09.12.28; Tue, 11 Apr 2023 09:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LAipuDez; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbjDKQLc (ORCPT + 99 others); Tue, 11 Apr 2023 12:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbjDKQLH (ORCPT ); Tue, 11 Apr 2023 12:11:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D40D45588 for ; Tue, 11 Apr 2023 09:09:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229393; 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=LAipuDez8CWPWUzqKk+HuOE9m0QM97tR9l8vwq0ycBedBj1dly/ZsmuA381VfAQyplpRf+ 8XfeDNWAYrQ5RazFSUCoAXGb4yfMPu6D8h3DlpRyCoiui+k31sjQZCuA6Zx1r+Im8R7EWa MEk2NN75IkUNt6W3fWwYez9XcwNcy7Q= 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) {