From patchwork Tue Apr 11 16:08:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13207807 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 0D98EC76196 for ; Tue, 11 Apr 2023 16:09:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C07A900004; Tue, 11 Apr 2023 12:09:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 948E6900002; Tue, 11 Apr 2023 12:09:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C1FC900004; Tue, 11 Apr 2023 12:09:18 -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 67877900002 for ; Tue, 11 Apr 2023 12:09:18 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3D80B80472 for ; Tue, 11 Apr 2023 16:09:18 +0000 (UTC) X-FDA: 80669594796.25.DBD2973 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 67627C002B for ; Tue, 11 Apr 2023 16:09:15 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Lc3jxrvB; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1681229355; 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=QAACn2mr7ooi1DdUlemHLPNq4itk2LGg3Qvic6fgj7U=; b=wr5637dTeDBhvNUQMb4DyV7GopDYUDN4DJIYoDIf1lWFq1yiExsGbNbeUSnXS9pRpVyY7j xL+BazQOMHiCedlW7BfxAFE6wKbAefonN1QvEBC4gAnDIRkI/bZYYjCJAdJ9m6jLaXkoYT 3oNBgZ0aDevilWlbzSgr5WRqEcPcoFM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Lc3jxrvB; spf=pass (imf22.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1681229355; a=rsa-sha256; cv=none; b=KJv0dQinoZJjmuhEkE+wk95rbduTEhuiytEoYmTes/IDvC+1N6l7QSRopYCNYmUnEWGYdc Wy7xxT/akrDSpSbMwSiC5PUs7dF4J6OWbkkqJtQGapZ4FXkqKvIrfMY0nIDe5l1SdeyoE2 V4WLWag7qlSLE0amsjAjOVjCENq3RD4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229354; 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=QAACn2mr7ooi1DdUlemHLPNq4itk2LGg3Qvic6fgj7U=; b=Lc3jxrvBuCRV0OTew0l+PO9MKhGeM5EAFfV5sFtKyBmwBvVPAoMJkV0t0ZMQyEpLbK1GyZ YI1OCJ91kk8ADNntgQsS7nl7/v3TiF7gC5MarIy5eYp53WU2mKMYQgE6H+MwwRJLBjQuZa IyRPKRvljXZIOGjdtDUGrWnmuunJDVw= 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-425-m3bGLW3zMRuPyvCVdlDU1g-1; Tue, 11 Apr 2023 12:09:11 -0400 X-MC-Unique: m3bGLW3zMRuPyvCVdlDU1g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77C5083DE48; Tue, 11 Apr 2023 16:09:10 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4197440C20FA; Tue, 11 Apr 2023 16:09:08 +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, Willem de Bruijn Subject: [PATCH net-next v6 01/18] net: Declare MSG_SPLICE_PAGES internal sendmsg() flag Date: Tue, 11 Apr 2023 17:08:45 +0100 Message-Id: <20230411160902.4134381-2-dhowells@redhat.com> In-Reply-To: <20230411160902.4134381-1-dhowells@redhat.com> References: <20230411160902.4134381-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 67627C002B X-Stat-Signature: a4yybqkokhptu9xosjnw4so64buhsk5z X-HE-T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/6U+zEGFFwypxARwWFX+JuU4v4eLK5AGH6hG4h3pEHXoYY7BDYqkx9NFbSXjBrEIKBdRVfU997fDfGemdTxFTHvn07UzyA2NNvLzeivaN/xWtu9woLwao4vEMzSI/Hil16eYUa26+ePENSgShjeE20xvbUQXQZtyLuinN+BveeuOzL+JGQyW4+fOmcKHFZa9WwctwipIVvht5+QDazspaZQMGSjKyxwSqHHJ3BwpfSFXKWEOFmOOJ1kc/1F1Ck04/UIKZ4RRVKcTAU0WZ4XCaopaHoOGAFgYpyAg0MFKFW8LQ7cscFwfy6rcds5sFSfVa4NaBzHXfFiKbQ2ikjiQrIYNIt7jFL7oiZRVDDwJtbUchMxcW2j3Mo05J5KyUvIY6GxymLj2jWHVDBASBU0PMMKXLuP2ajEZ6rTFXYgJW4faQSxcmh8an5SI8X7PhRlNIwZl14Iub1da 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: Declare MSG_SPLICE_PAGES, an internal sendmsg() flag, that hints to a network protocol that it should splice pages from the source iterator rather than copying the data if it can. This flag is added to a list that is cleared by sendmsg syscalls on entry. This is intended as a replacement for the ->sendpage() op, allowing a way to splice in several multipage folios in one go. Signed-off-by: David Howells Reviewed-by: Willem de Bruijn cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- include/linux/socket.h | 3 +++ net/socket.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/linux/socket.h b/include/linux/socket.h index 13c3a237b9c9..bd1cc3238851 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -327,6 +327,7 @@ struct ucred { */ #define MSG_ZEROCOPY 0x4000000 /* Use user data in kernel path */ +#define MSG_SPLICE_PAGES 0x8000000 /* Splice the pages from the iterator in sendmsg() */ #define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */ #define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exec for file descriptor received through @@ -337,6 +338,8 @@ struct ucred { #define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */ #endif +/* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */ +#define MSG_INTERNAL_SENDMSG_FLAGS (MSG_SPLICE_PAGES) /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ #define SOL_IP 0 diff --git a/net/socket.c b/net/socket.c index 73e493da4589..b3fd3f7f7e03 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2136,6 +2136,7 @@ int __sys_sendto(int fd, void __user *buff, size_t len, unsigned int flags, msg.msg_name = (struct sockaddr *)&address; msg.msg_namelen = addr_len; } + flags &= ~MSG_INTERNAL_SENDMSG_FLAGS; if (sock->file->f_flags & O_NONBLOCK) flags |= MSG_DONTWAIT; msg.msg_flags = flags; @@ -2483,6 +2484,7 @@ static int ____sys_sendmsg(struct socket *sock, struct msghdr *msg_sys, } msg_sys->msg_flags = flags; + flags &= ~MSG_INTERNAL_SENDMSG_FLAGS; if (sock->file->f_flags & O_NONBLOCK) msg_sys->msg_flags |= MSG_DONTWAIT; /*