From patchwork Fri Jun 23 11:44:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13290409 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 A5E05EB64D7 for ; Fri, 23 Jun 2023 11:45:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44FC08D000C; Fri, 23 Jun 2023 07:45:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4001C8D0001; Fri, 23 Jun 2023 07:45:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C8E78D000C; Fri, 23 Jun 2023 07:45:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1E8898D0001 for ; Fri, 23 Jun 2023 07:45:19 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E8EEAB0BF2 for ; Fri, 23 Jun 2023 11:45:18 +0000 (UTC) X-FDA: 80933831916.27.99B9653 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 EEE9C40014 for ; Fri, 23 Jun 2023 11:45:16 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U1KpF3eI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1687520717; 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=q+cASt33kWZUufsvLJgS/fy0vLRTmGchfVl8mFYseECD4SBpaHKR2weihuZEyxuDIGRHG2 4xqtiEFHhcVdEg9T6sJr/G2G4K5zUMFX8lMUavdUlVbyDFJeRbpgVKaUS9CwSxS1ycCiWr ZJveq5mV08bzpXAEIl4gKZtT/5XDjnU= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U1KpF3eI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687520717; a=rsa-sha256; cv=none; b=K4tZe1eBT0a84WWMF6wsAAgJe7FYAwrXNz9xj0/lBrTRdt1BpSQug2OtkF2VxL13hvrnRd 6ujVZnSqccVWGJERzk4uvEt4aczltcMNO+Kppo2NH/W3wvk+QBfIpnt9CAw4AwDq1Ueb38 t/Y7fN2mFa6t1GgBRfO1an5c3D1/cjM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687520716; 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=U1KpF3eIYPgO2VEJNO5QriSaf4Kd89WZoctq9Gq/toVA6Fo3ZqRRYtfPByXHeWrka7iIrM XuMx85eel/a5B9+xMS+8eeeyzoyYgVib/YADhH5bAl+0Inv9mowNDUWA6J0PGaBiStvZvl kbrR/DpoPgc8isj6jjHvh+6BjVnppMw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-X_gMScNrP0Wfu8HM0-rlVQ-1; Fri, 23 Jun 2023 07:45:12 -0400 X-MC-Unique: X_gMScNrP0Wfu8HM0-rlVQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D9733C15FC2; Fri, 23 Jun 2023 11:45:08 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B4EB200B402; Fri, 23 Jun 2023 11:44:53 +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 v4 10/15] drbd: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage() Date: Fri, 23 Jun 2023 12:44:20 +0100 Message-ID: <20230623114425.2150536-11-dhowells@redhat.com> In-Reply-To: <20230623114425.2150536-1-dhowells@redhat.com> References: <20230623114425.2150536-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspamd-Queue-Id: EEE9C40014 X-Rspam-User: X-Rspamd-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fm2/xysfh0pOygpW0uHz3mlPZDxGKYaQ6n7nVo5jiUGvEGAA1Noiz05mowGffoD331j2tGq4TSN5fj2//ObobmHaB8rWPcuswoKlso/Xr2WxVRDWZPVE9T/AlvY+ExufmTNmVv9bCxBCfr9I0C7YoVPewEo9Cm3+/4oEA1950MhJjSWkOIX6hnuN6nzPAbxuprpAc8KFL2VYhxhPihRvBx4v7W+ynVWhqRgdafZPhhgeCCddTKuQyGic3A4Zzwh6ut+1kQSQu/DEd+Y4D2V01pKwNt5LTB1R0f9/nwxBii5X2SV2DESiXuXipPCjeF9c6ISnppdgOF5AM0mtbvxuNLzGG4Lv2YyWWOY4MUknfn3lzEmg2MMeU2oedD5GeS4EeOZXrwpvSdNkYCY3vtfQ5hQu9nGM19mxN5PA9oTBagnvZQOdZA0ROMHnoiLRQ7RokAR937ynGkovisNbPuI/sgGwVBtya5TAdoLi2JzOSlAPatMiw== 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))