From patchwork Thu Apr 6 09:42:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13203049 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 4ED3CC77B6C for ; Thu, 6 Apr 2023 09:43:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C70166B007B; Thu, 6 Apr 2023 05:43:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1FB16B007D; Thu, 6 Apr 2023 05:43:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE7636B007E; Thu, 6 Apr 2023 05:43:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A15F56B007B for ; Thu, 6 Apr 2023 05:43:06 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 712611A0D34 for ; Thu, 6 Apr 2023 09:43:06 +0000 (UTC) X-FDA: 80650477572.27.7C3E54D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id BEF42180016 for ; Thu, 6 Apr 2023 09:43:04 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dDASBm9X; spf=pass (imf16.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=1680774184; 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=gZXkLhX0bPTLYTF+b+umP/LkrGCkdxFbqfP1eY5H5FNbQ4LScyAWTs+347GlmlQpkJdhLP PhhERu2zFZYa2iVF4k7D0/gOXa2wtKNCi7HGyuUKCkRUygR7Zoamml4xkZZXgnh8y2kvE7 C8XyRFEjtV2o8mmIWDHbSyKe8S7H03M= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dDASBm9X; spf=pass (imf16.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=1680774184; a=rsa-sha256; cv=none; b=L/8uxhVhmzp66PUdtFaNYWqk7tCpZy6xucbRbHYrclbINdKcSjQOQXBdwmZ9HEmgXcxqKv vz9awGzM2FkJ1yJI6DeBJ5+Fd2mm2d2kj4bWdZDGJnS2rIXx/aqx4Db3/yBc2s+N5RrGeZ F1X4TFyZtAImzhwhQhfIjnrHry96gaw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680774184; 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=dDASBm9XXEld27rIX5q3MIsbSoWgHLQBluwP3tYSzENIBldXIpKaIhVkr1Zhwgn3aLZ5RY ZSgIT9FSMa9UNaE9fSKJUrNoFZBk12DFn9L9uYYXUsCdZ9M978zUh2jcKAPIk4/mSwu3Tr sZ8GPRcdhtWGa2xYWZgJbyif0Y0Nmdc= 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-407-oFbn2Db-OmiMAeWnu6JDQg-1; Thu, 06 Apr 2023 05:42:53 -0400 X-MC-Unique: oFbn2Db-OmiMAeWnu6JDQg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16D458996E2; Thu, 6 Apr 2023 09:42:53 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06D00492C3E; Thu, 6 Apr 2023 09:42:50 +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 , 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 v5 01/19] net: Declare MSG_SPLICE_PAGES internal sendmsg() flag Date: Thu, 6 Apr 2023 10:42:27 +0100 Message-Id: <20230406094245.3633290-2-dhowells@redhat.com> In-Reply-To: <20230406094245.3633290-1-dhowells@redhat.com> References: <20230406094245.3633290-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Stat-Signature: tr4ecds4u3wti7tew3rtnwwq1wr5kedy X-Rspam-User: X-Rspamd-Queue-Id: BEF42180016 X-Rspamd-Server: rspam06 X-H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jEpKZd4P/AVxATWbo8J9tt1bBmmbxcOF29JadRcvx1GDNyQUwGhWqEzMPqu1RPjvv0anvXJ4W6G54HJu8f1R3nkcaduzHlIIPuyTxmL33BuqcNQezt37DhuytQHCaubqx+2FrXc94CIRUAsW/nTpFLIXEYp7PsC5wkcRLNF2WI2WpRFBXPCdXf9vZs7DmuhsJyRJce5mJfrkc7Qjpf3cNmz+xHzw38P5GdQ2JFT1Yzafqi9lQIle6AaP/82ciMoCNMyGmMbAMVOj1I3lWHQmO+x1sooF8dCw8nzMRBGvyVuf0M1PsFXJf6/+4S4rYxGq5gCchc6uPl/bbdBmYXW423dMVavwJ92Lt/yB0jfc4CiRszfj/IiVsYaEnAFO1VRxruQQYqNxb2O9zETAFPigi4juTXfJpnVk5/lj/4P6U/6KEDEfi5TI3NB81LW2FrZothC5ZhHHHo 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; /*