From patchwork Thu Mar 16 15:26:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13177823 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 D0062C7618D for ; Thu, 16 Mar 2023 15:27:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67FF0940012; Thu, 16 Mar 2023 11:27:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6086894000A; Thu, 16 Mar 2023 11:27:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D077940012; Thu, 16 Mar 2023 11:27:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3DFA294000A for ; Thu, 16 Mar 2023 11:27:35 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0637A81442 for ; Thu, 16 Mar 2023 15:27:35 +0000 (UTC) X-FDA: 80575140870.27.15DAB1C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 4FC2B4001B for ; Thu, 16 Mar 2023 15:27:33 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UKS4AMgT; spf=pass (imf17.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=1678980453; 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=cqdl8fmtEvVwpgPJdtUvP824my58WFWl8Wp/Vt/z1XI=; b=aK+RzZmWt9PnltsivbteD8FdohleBno1QVqOHfwe+puJVCeUhEcIRLh65rHeJZyZplVbQG aV8erqVWqj7qRVHWyit/l5nB0PxL/Tz/w4sEGOloXW2wuYBvu6LV4G7XCN7Iyc+XzEAbUF qHJL+S7ay80gz30LZpGArpDn+ZwoGNY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UKS4AMgT; spf=pass (imf17.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=1678980453; a=rsa-sha256; cv=none; b=KKkA44EbUqo85QgrBTpV49r2ZB6CNqkz3RmCXvwxO2ROkLhTPDvaj2mZm4v5eEpWXptr4Z 2vS9h+9vojnq2TlriDvv/k+8KXXuCynKRgo5i7oQefkyGd7TKXAVXfZ3q7TW372bJh+dWh b/bAQoNmRoXl8rkel3X+6ri7VXS1XkE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678980452; 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=cqdl8fmtEvVwpgPJdtUvP824my58WFWl8Wp/Vt/z1XI=; b=UKS4AMgTmDX4aGS/5f48Hd0GpunzLUJayFXbjTcp4Y84/Ue+dykGoE3vzUykMjbUoFtQPp 1FQy5wRUQx/YCn5w4LPFhRy8yALte6I+FXZtBEI67o7VYSNAPqddFj3J2PpiYc90TSuGaV XMmHyMk7/j4h3UXb/eRasedTwcYyQlI= 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-644-1WZJi73lMMOMNIGU82y0ZA-1; Thu, 16 Mar 2023 11:27:22 -0400 X-MC-Unique: 1WZJi73lMMOMNIGU82y0ZA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5D4E185A78F; Thu, 16 Mar 2023 15:27:15 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C1A1140EBF4; Thu, 16 Mar 2023 15:27:13 +0000 (UTC) From: David Howells To: Matthew Wilcox , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: David Howells , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Linus Torvalds , netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [RFC PATCH 20/28] iscsi: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Thu, 16 Mar 2023 15:26:10 +0000 Message-Id: <20230316152618.711970-21-dhowells@redhat.com> In-Reply-To: <20230316152618.711970-1-dhowells@redhat.com> References: <20230316152618.711970-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4FC2B4001B X-Stat-Signature: dr7nsmfp786otrp61gaawfob836ksz6q X-Rspam-User: X-HE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Y9VGRUMZWOoyTE4rJwVbK23x4LsgN++UJaVgaC9+o8gSsYOeU+2N0/3dlnJA2DawqCplWSxrD2UCDCruxOznkVx/g7DpWwZJr7lwZ52mPGLbhxQluQEYYnkQUN9OuRSf8z/2YmR836ijtY/fwwMeLs5J98DbRLhuoLZgiNA8Kxzxjqoe8UY1ObIXQ0KpkmXrlu0FgdihHqwqTdkuKPgZiq6OgEP+mH125X3OKllUaP3uS8bdYCVhpwWsTqaxalsA9m6IXdegtDd83Wy4rgDGSSHEUyWoThX3Mepvyh7g4qKUL2qwofRI/YtEImJZg3uC08LINP4KEsy9Owc9WS/cJLdvaOYWb5t39EXtQk+8eyS7pIJKOzZftf4wibmajskmLIQvF04MEQWM05qPRfL1UaiA== 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: Use sendmsg() with MSG_SPLICE_PAGES rather than sendpage. This allows multiple pages and multipage folios to be passed through. TODO: iscsit_fe_sendpage_sg() should perhaps set up a bio_vec array for the entire set of pages it's going to transfer plus two for the header and trailer and use zcopy_alloc() to allocate the header and trailer - and then call sendmsg once for the entire message. Signed-off-by: David Howells cc: "Martin K. Petersen" cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-scsi@vger.kernel.org cc: target-devel@vger.kernel.org cc: netdev@vger.kernel.org --- drivers/target/iscsi/iscsi_target_util.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 26dc8ed3045b..c7d58e41ac3b 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -1078,6 +1078,8 @@ int iscsit_fe_sendpage_sg( struct iscsit_conn *conn) { struct scatterlist *sg = cmd->first_data_sg; + struct bio_vec bvec; + struct msghdr msghdr = { .msg_flags = MSG_SPLICE_PAGES, }; struct kvec iov; u32 tx_hdr_size, data_len; u32 offset = cmd->first_data_sg_off; @@ -1121,17 +1123,17 @@ int iscsit_fe_sendpage_sg( u32 space = (sg->length - offset); u32 sub_len = min_t(u32, data_len, space); send_pg: - tx_sent = conn->sock->ops->sendpage(conn->sock, - sg_page(sg), sg->offset + offset, sub_len, 0); + bvec_set_page(&bvec, sg_page(sg), sub_len, sg->offset + offset); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, sub_len); + + tx_sent = conn->sock->ops->sendmsg(conn->sock, &msghdr, sub_len); if (tx_sent != sub_len) { if (tx_sent == -EAGAIN) { - pr_err("tcp_sendpage() returned" - " -EAGAIN\n"); + pr_err("sendmsg/splice returned -EAGAIN\n"); goto send_pg; } - pr_err("tcp_sendpage() failure: %d\n", - tx_sent); + pr_err("sendmsg/splice failure: %d\n", tx_sent); return -1; }