From patchwork Fri Mar 31 16:08:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13196164 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 4AEB4C761A6 for ; Fri, 31 Mar 2023 16:09:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D42E86B0078; Fri, 31 Mar 2023 12:09:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCBBB6B007B; Fri, 31 Mar 2023 12:09:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B93FC6B007D; Fri, 31 Mar 2023 12:09:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AB8106B0078 for ; Fri, 31 Mar 2023 12:09:42 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7600116100D for ; Fri, 31 Mar 2023 16:09:42 +0000 (UTC) X-FDA: 80629679004.02.F8B1D0D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id A42AA18000E for ; Fri, 31 Mar 2023 16:09:38 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hAA9wneD; spf=pass (imf06.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=1680278978; 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=2Rqs8gKWnfX7IQPFFFiE2mTLNitfAQsbWxPFIoMuGvc=; b=Ey15jeWYcVZL4+6pP1KyGFaUDwBYTlzoO+PUBr5GZVOyFK1eCeG3lO1mfra6p6YFXC2/C7 y/w95ZpBKfoWzcNNxWSR8TGKFJd8veaGcMh9P+zgfriDe9m6rwCwKS4gheohytzsUwWE5F RX+/dyMd0lkmreQ5x3g7mowfaeLc2WE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hAA9wneD; spf=pass (imf06.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=1680278978; a=rsa-sha256; cv=none; b=v95Tu7r6gb+46wwxykYIFNldB6FIsIvQyqMI9kcSCeDA3Jbmq1+hGlHuEpHuc7eKu1P3nv sYdekD+YAML0fBYR/BzGgf+BH8vcb2Yqdb807vB9+EUG587SF5mAlGM/UdPRK3R28pQeD9 fSyFdVpjIYVaSFRJJval+fQYkQySPug= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680278978; 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=2Rqs8gKWnfX7IQPFFFiE2mTLNitfAQsbWxPFIoMuGvc=; b=hAA9wneDvHVU1ZIDDvOVUg1NyfOkB2EusPX9UYEQiAvjxN0k+CECFkIhxU7SxQ1xsM5Y55 QMcTVwmh8ENl4fDH2afhgTuiwev2bELyOA+r+8+UsCbC5UbVV60pAdnjkLgRPgSExceSdW Ks1jboZahUW6nZlnhiWks+lrv1jFOCQ= 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-543-0AgUVjoEOGGNrIUOLBBj-A-1; Fri, 31 Mar 2023 12:09:30 -0400 X-MC-Unique: 0AgUVjoEOGGNrIUOLBBj-A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4A9029ABA19; Fri, 31 Mar 2023 16:09:29 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A92CCC15BB8; Fri, 31 Mar 2023 16:09:27 +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 , Chuck Lever III , Linus Torvalds , netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Willem de Bruijn Subject: [PATCH v3 03/55] net: Declare MSG_SPLICE_PAGES internal sendmsg() flag Date: Fri, 31 Mar 2023 17:08:22 +0100 Message-Id: <20230331160914.1608208-4-dhowells@redhat.com> In-Reply-To: <20230331160914.1608208-1-dhowells@redhat.com> References: <20230331160914.1608208-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A42AA18000E X-Stat-Signature: 5ogwkzzhed75rmtsz54dzmejttzrse1u X-Rspam-User: X-HE-Tag: 1680278978-512485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jwp0EBqcQHsB4oL+PueH1mYRpqiEmfOSyurzKB8BlrmJWcVhW6Fni4o2MTbPBzc03rtlWmyl3bhw0Eh+w65PfNdxnuhYKT+kCtIMhKEB0FYzOnxTSQmV+EYslEVxfZsx7PSbNl7YyK1A2PyLHc7G+2RaPkLci+iosvo+bLtkeRIaeVIh3CRwmqEPf9dDyCfD4v6oMqcFBAqchVY7vQWc3ggHsh0uyOMgHagew5Y9aj4xj+cMkRtnNd9uRcVhtceB91hTHAqI6yKhDN5p4wN9zLJoFDvswemGHA0UWVHFXuDuBxmqhX0IZG5R2JBLwVVeABwPLXfMSBYJPtEdZq0Jm3SXbssXHB4CPxNFZnrsayIiYo6uV3SYeH7Benkvmfxn9ih+YpZ7EmoZ5XzuWV6+QPgbdnhqyw2uCmBR9Kc8Q6jpZP/Kv5vo6aCHgKrI4b7S71jrAXrR1wR7ce1RqMUA== 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 and recvmsg 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 cc: 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 Reviewed-by: Willem de Bruijn --- 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 6bae8ce7059e..0c39ce57d603 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2139,6 +2139,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; @@ -2486,6 +2487,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; /*