Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13100995rwd; Fri, 23 Jun 2023 15:58:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DbqZJ4uX+g6YJNDmCm5HXSGcM09Xi0ZSSujXxGx6WxKXxnZHw/dPdggiOUY1Vka3zinLf X-Received: by 2002:a17:90a:d996:b0:25b:dd3c:a463 with SMTP id d22-20020a17090ad99600b0025bdd3ca463mr22392213pjv.16.1687561105454; Fri, 23 Jun 2023 15:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687561105; cv=none; d=google.com; s=arc-20160816; b=yn7c6Qi9kc5K4e7zbeSdZcS5jmAF0eOQX8CbcT2ZoV+JwVS9X0tPrbXKXO2lpwIgKL p8WztKBAuDcEnbz4OGmksFBRmUpV9EgA2SRbUcAP9RaZk5FKM0Asftlfo495qacfIWMq 8gvS9egyRjjdtCJj5g87RCVD27BH9QTO2gT/U82JdNPXEI3C3XmetoLJ2rz+PJOlQo43 e7Tca4uzShcnWDbrO6tmDa8JWBcjMPfR3/FpoQhnZ/xIMUMg65oDzlfRAQff9tCGXsa0 SyX+cyiZBIJq70rUikXmFD/jMh6Z0VsXt0gdvJl+R/6Rvq6aTu5xhDyQD5uDU8iS+1Nz cbvQ== 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=WiURs0vKXpYUCqXgawYZgqdOEVHMSUaWINzZV5vrdeY=; fh=XzbI6MrGd6EB0wDIIeiHFFnSKkgkqRBXw/R99NullEQ=; b=00pZV4QE+6jzua6aUnhZCk96UtdDwtCLIUnh64l4ACxvHvO2AWAaO40oCaOuE4lJx6 nwDzKMeuTYC8lLQJHvh4QffVLNSKe07lGmH+y/6ThOGnAcb8YWmltTFOZ2jaenoLeSr4 KtMcuLIfjmjmmfhkj2r7yIVVH70CujgGsFqd/XPjIEUNi65ehZr+x1piG/s/rsYreu0s xWlGBQC0oaCCMT3WlxUcPax8JKZyIgjTZXDkJyoIo9OH5yP+90Gw9u9LbODIyvlxAsEW rwdgT7Qm8liZHc/4sqmPpcB8dcGveiaujvXA3OdGIhQoRbXP9363zQcja9OD3V0aWQMt cOPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NnzBFSsD; 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 k18-20020a6568d2000000b00557848bf4d7si355311pgt.798.2023.06.23.15.58.12; Fri, 23 Jun 2023 15:58:25 -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=NnzBFSsD; 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 S232244AbjFWW5C (ORCPT + 99 others); Fri, 23 Jun 2023 18:57:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbjFWW5B (ORCPT ); Fri, 23 Jun 2023 18:57:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44F992941 for ; Fri, 23 Jun 2023 15:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687560949; 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=NnzBFSsD21LmvjXJ5eNMokofQtHixWWBtMamiA4tJsRNqta7191Tnpp6cktmkWhsmaLwkQ poBJBttsrZVL5cSxaID5VVty9cTCLgracSW1AZlTU19oBe/F5L6VQNj3Xh5TUTD7cUNvwJ IYMgPkpWno0rdqNLj5o9aTiGe2PdnPM= 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=20B=C3=B6hmwalder?= , 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 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))