From patchwork Fri Jun 23 22:55:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13291456 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 BC6ABC001DE for ; Fri, 23 Jun 2023 22:55:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C0A8D000D; Fri, 23 Jun 2023 18:55:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DE2C8D0001; Fri, 23 Jun 2023 18:55:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E24948D000D; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C6EED8D0001 for ; Fri, 23 Jun 2023 18:55:55 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 946164036C for ; Fri, 23 Jun 2023 22:55:55 +0000 (UTC) X-FDA: 80935521870.25.DAED2E3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 41041C000A for ; Fri, 23 Jun 2023 22:55:51 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="SVkhoZ4/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1687560952; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WiURs0vKXpYUCqXgawYZgqdOEVHMSUaWINzZV5vrdeY=; b=CsXg9ByTgtUOO6ZNMXvBriqOmCFMLOqZh3yJyvxp7gS+2JwkHZMBqyX6osrSnpdsTolhXc QuZ8CHVm2mW2Bn9fykcDTFEDKN3c8CkoElgMSoNMyEDntcOktfQzTCQCVNcM2RmHaOlyLV h/66QhTfFt3G+pFrb11ci8hD4nzUkws= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="SVkhoZ4/"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687560952; a=rsa-sha256; cv=none; b=gfjiW7PQto5MklQTA1y0Gji6QLJPXGmtyExP9Xi6hUmb4czDUFW3TYIEy/x/kqJ8bokVw9 So1MCy3fh5lb4RXElgZqa4VdXr6Di8R+vHAd1/XIiTJJEwKEqMaUbAE2ecqcpw1MtK+MUP 7V4oC/mcsySaOHoI82BiAHJq8/ostPU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WiURs0vKXpYUCqXgawYZgqdOEVHMSUaWINzZV5vrdeY=; b=SVkhoZ4/bhSFk+9dgCco3zYfeZ8J8Mwxihu+s3JYXhG8ZYsI7K6Tzf9gqMKyW932/Jj0kT rT+6eSMK+Ma00ipqOY9IRJZu/2gpj7Yp97PIG1+21dkcs4CZrGZSnRQuUHnre5Xvue/Npq gLkw2lVP9WrPXhjtb3DXrNZ+taAxwHc= 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-195--BFW1w5BP0WNexEK9_ZAZQ-1; Fri, 23 Jun 2023 18:55:46 -0400 X-MC-Unique: -BFW1w5BP0WNexEK9_ZAZQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43846810BB2; Fri, 23 Jun 2023 22:55:45 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56CA84087C6D; Fri, 23 Jun 2023 22:55:43 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Philipp Reisner , Lars Ellenberg , =?utf-8?q?Christoph_B=C3=B6hmwa?= =?utf-8?q?lder?= , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org Subject: [PATCH net-next v5 10/16] drbd: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage() Date: Fri, 23 Jun 2023 23:55:07 +0100 Message-ID: <20230623225513.2732256-11-dhowells@redhat.com> In-Reply-To: <20230623225513.2732256-1-dhowells@redhat.com> References: <20230623225513.2732256-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 41041C000A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3yu/r4BTqlTI7vzsRCOeQKM/nrfd9k2FKRAHz3WWVUSMLOTFBUGHceQlOVxmrNKUOulk4fONGfOuRb+ES1BCutuZBc7/0vyXx7RV7QY6mWqfkJquvuZEbSYDU+F2Wpwzy40umJ2JbPo2pmqdE6vivkg3gxZ3NUA/n4WZyBSMth+poX346En2qIpVROJCSl0QrS9puA0B9zjXn11d/H0EyUy9wzSGEDVlMweeXz+v3BSqPwZhuAVOkgF3oW0E3gouDniZAbltWxHMgV5Ap0inJR4RN4i/ncCiOFJmbvXBakNJdZEWHThd+0tfoPvbftm7CB/DctbOwzqm9KxluHKo/m32ub1rev3NCIitjQuLx9hWhbQ77uwcvMU4BI9X3GMFIqt1e7KL1qgIEChACgRYYliElaYyzqcfDM3KMIlixOB7VSLEq/41C7lbxrhjdZt1fE+r1FQ0/pYr1EA5U2IH9L/AoRGma44XlcyfmNFkwIAlvqg== 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() conditionally with MSG_SPLICE_PAGES in _drbd_send_page() rather than calling sendpage() or _drbd_no_send_page(). Signed-off-by: David Howells cc: Philipp Reisner cc: Lars Ellenberg cc: "Christoph Böhmwalder" cc: Jens Axboe cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: drbd-dev@lists.linbit.com cc: linux-block@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #4) - Don't look at msg.msg_iter after calling sendmsg. There's no guarantee it has changed. ver #2) - Wrap lines at 80. drivers/block/drbd/drbd_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 83987e7a5ef2..ea82d6733313 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -1540,6 +1540,8 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa int offset, size_t size, unsigned msg_flags) { struct socket *socket = peer_device->connection->data.socket; + struct msghdr msg = { .msg_flags = msg_flags, }; + struct bio_vec bvec; int len = size; int err = -EIO; @@ -1549,15 +1551,17 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa * put_page(); and would cause either a VM_BUG directly, or * __page_cache_release a page that would actually still be referenced * by someone, leading to some obscure delayed Oops somewhere else. */ - if (drbd_disable_sendpage || !sendpage_ok(page)) - return _drbd_no_send_page(peer_device, page, offset, size, msg_flags); + if (!drbd_disable_sendpage && sendpage_ok(page)) + msg.msg_flags |= MSG_NOSIGNAL | MSG_SPLICE_PAGES; - msg_flags |= MSG_NOSIGNAL; drbd_update_congested(peer_device->connection); do { int sent; - sent = socket->ops->sendpage(socket, page, offset, len, msg_flags); + bvec_set_page(&bvec, page, offset, len); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + + sent = sock_sendmsg(socket, &msg); if (sent <= 0) { if (sent == -EAGAIN) { if (we_should_drop_the_connection(peer_device->connection, socket))