From patchwork Wed Apr 5 16:53:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13202255 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 D0991C7619A for ; Wed, 5 Apr 2023 16:54:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D4606B0075; Wed, 5 Apr 2023 12:54:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 684596B0078; Wed, 5 Apr 2023 12:54:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 525296B007B; Wed, 5 Apr 2023 12:54:01 -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 40C006B0075 for ; Wed, 5 Apr 2023 12:54:01 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E10A0120BBD for ; Wed, 5 Apr 2023 16:54:00 +0000 (UTC) X-FDA: 80647934640.10.30E4951 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 296C080015 for ; Wed, 5 Apr 2023 16:53:57 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=B4J+1nL3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.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=1680713638; 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=eHpYCj1QwJSXdaMBiF2FHiBKMKPyanw8iBuLHxRyN09NxtwbFi1g9KyknfRAKFj3gQ8v4u f1Isje2IpSAA7y2bPsrUNbNNNUMmip6/88BkhV6v0TkeexeqB5mfXeVveZiW5Fxonwj715 5LCxj0+c/JmET+vbcWeXWitr1ee2Znc= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=B4J+1nL3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.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=1680713638; a=rsa-sha256; cv=none; b=F0KrCA76280LMLC1cmwEHujo8zY+r82w4QbEwjk4z2UZFgiO4NxgWeRSTzk/IdLn1+9Hvk rsFv3O8k24Pv5m52o60V8ykrjdlM0yKP+JdBes6f+ySIQB6+5umXduxCklXIQCjGE9qVJV WzMhKtCjqWxrzgVw4hJuuB1WcbY3d1g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680713637; 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=B4J+1nL3MJU3iT6BoHQibEvlGCPkt1Tzg2w2G7NM6HSH1XQb+kp0U0FEWyXa/6/kHb/g5u Ogu7fq4BmxuVSa+UXkKqP/6Yjot1psSJAx8KgS/mPCRnsxjzIoGDTmuqUGJbyJlnukcwAc Bp/Xw7X+y1VlcYbKIMZtrWRid8QB1vs= 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-86-CL3O1Pd0MuC9cMWkPeSHyw-1; Wed, 05 Apr 2023 12:53:51 -0400 X-MC-Unique: CL3O1Pd0MuC9cMWkPeSHyw-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 82003185A791; Wed, 5 Apr 2023 16:53:50 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A251400F57; Wed, 5 Apr 2023 16:53:48 +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 v4 02/20] net: Declare MSG_SPLICE_PAGES internal sendmsg() flag Date: Wed, 5 Apr 2023 17:53:21 +0100 Message-Id: <20230405165339.3468808-3-dhowells@redhat.com> In-Reply-To: <20230405165339.3468808-1-dhowells@redhat.com> References: <20230405165339.3468808-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 296C080015 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: web1frmhoekunwqeej83xp8pzsr1317n X-HE-Tag: 1680713637-631409 X-HE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imT7fchouXCVB7aeEi2AIbVATXMgULyki4SxOKRYLAPe0FU+LZgcqkHu91adoT8c5LfML7QJU3g1wosN/VZ4KC537UkLThwE/1iLBkYnEeF9EQAoxFnuGO7VwxeY3BxTSHi6igQ+8doemvAHH9A9YxkqWhHN3YXxVW7OIEuhtqSNJFcyOh7EBQHvb75i2Sb9iUIkeGE3WKtnnLFMdbX42nDSx7wvbOwYECpPVpGJ2EELDiIKqzwJSeHn1iPsJlVuXjBUN+tTcG4cqIp2dnRinIWDOLGGh/++aDjclrRS2VaAQQoCal+iUdj3MAocczwxYpdq+WTWwYj/q9xhnyFAh5NZg8BMd0rgyMlYfPguJDF+PfaKwSS80pmQNXGMeQimWR8jDAg3HPyT3yDnkFOSrgtHiGkHJUC5OoXka/V6chP2AATb 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; /*