Message ID | 20230411160902.4134381-15-dhowells@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 50FB6C76196 for <linux-mm@archiver.kernel.org>; Tue, 11 Apr 2023 16:10:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E538590000B; Tue, 11 Apr 2023 12:10:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDBFA900002; Tue, 11 Apr 2023 12:10:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7CEC90000B; Tue, 11 Apr 2023 12:10:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B70BD900002 for <linux-mm@kvack.org>; Tue, 11 Apr 2023 12:10:02 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 62A3240E95 for <linux-mm@kvack.org>; Tue, 11 Apr 2023 16:10:02 +0000 (UTC) X-FDA: 80669596644.19.74FD634 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 7CFCB18000F for <linux-mm@kvack.org>; Tue, 11 Apr 2023 16:10:00 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WuaAYZ3N; spf=pass (imf24.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1681229400; a=rsa-sha256; cv=none; b=wdqZ6hX/DhhNHMpdr6oht2tF2kQxHCA9arwnhY5u0nljSnDgyAd6qiCEVC2BVcjU19GqfH rV/dL3VczSKIqSGq0+fZ/yUnflm6vFjppV0pJQH4rgb4sNXhoCTInwVNshBMrEHFUMCwIN 3cbcWQG0XhuBCmIPLnx3rqXnMHVD7ug= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WuaAYZ3N; spf=pass (imf24.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1681229400; 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=ixYp8U9bxWbRy0uTYM5jwtBZUcxG981BMDx6Mvgz/Cw=; b=QQ5+oICtlrAHCOBPxnTnatesWjYxqvUh9W69o4nS7XdJISwXOqsCfz906mf+gIgAWRgb/A CsKEUoNE35rsz9/pmiQMCfF9biF9Wu4I4KbsoITrxU9XV9AwYHNMDHD6ixXovaAE1L18GS vlD5071AIFmbOLvIglJqv9cphLB1uSQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229399; 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=ixYp8U9bxWbRy0uTYM5jwtBZUcxG981BMDx6Mvgz/Cw=; b=WuaAYZ3NT7WFuCW+k+XLr9wmf0D7M7rxm1AGwjNWkuOWwQ8Hhm3ZPNGVTBw1ugBOVaHh1G h2VIOgcGvBETvusSdPq0nxiZBc8rvWo4+rWccoU+A11/B298lxijsnViUqux2kaRvKn3x0 r5Su1OvsAe8JMMaltE4oMMrhMoYvKGo= 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-668-6XnKugzfOdqRWqhI-2hRlw-1; Tue, 11 Apr 2023 12:09:54 -0400 X-MC-Unique: 6XnKugzfOdqRWqhI-2hRlw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0FCA51C05143; Tue, 11 Apr 2023 16:09:53 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6A1A2027040; Tue, 11 Apr 2023 16:09:50 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: netdev@vger.kernel.org Cc: David Howells <dhowells@redhat.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Willem de Bruijn <willemdebruijn.kernel@gmail.com>, David Ahern <dsahern@kernel.org>, Matthew Wilcox <willy@infradead.org>, Al Viro <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@infradead.org>, Jens Axboe <axboe@kernel.dk>, Jeff Layton <jlayton@kernel.org>, Christian Brauner <brauner@kernel.org>, Chuck Lever III <chuck.lever@oracle.com>, Linus Torvalds <torvalds@linux-foundation.org>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH net-next v6 14/18] ip, udp: Support MSG_SPLICE_PAGES Date: Tue, 11 Apr 2023 17:08:58 +0100 Message-Id: <20230411160902.4134381-15-dhowells@redhat.com> In-Reply-To: <20230411160902.4134381-1-dhowells@redhat.com> References: <20230411160902.4134381-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspam-User: X-Rspamd-Queue-Id: 7CFCB18000F X-Rspamd-Server: rspam01 X-Stat-Signature: uuzby5bcmj19tnz4ekg38o37s8coinnm X-HE-Tag: 1681229400-777937 X-HE-Meta: U2FsdGVkX19mXgRh2Mg4N+Vgd38cH9pSTttUIpxaP6LLFDwtjID+fzXzHXZECYQy9c+rKQsYBjk85O48zlP9sz1D1KXynJXEzZBztTPH/wc9csTsre9XDn2jdKaKFjd02oOd8ap6xNoYSWilxgC5c7J427p7TFQBMC1/Ul76ONQLcQnx4kJgsNkETSqdJkqP1OVUhc6loKq2m85tbOKfzPB963Yn1zDTpLAbNWp+MJrqF9S96jYnZfIZxQrhfvZJSz/Z7VbYS5EfEVSkSY15uvvL+KfvKsUefEBdhzEyS2STyGF0/XVtfTqQ5p3nJWV8Q4fKt4IY1BJDJPzgOJbbtRR6NCupveP0OYK4e+w5VnKol0ff+7DABWHDecPHjxzbiJWQazAoePXDOvbTthYFJ5u0zhkMKOvwHiF0EenyWB9b4XpdTyz0XQxzLwMSZQFYNjFbvSERMy/1jl9epUzl+Jai5YIZSLIk06nwLPUmJMe/JRkxNJWC+loMlQpB00c2YO5DtNMEX8beZpI471Z8G0mkjkeBYJGYQC31u1YUVuYB6vWEq56px/pibdPIHl2q2cKwvnNU+PSJoLMnLhh4y+6gWUfqjMu7eNpqU1viOq6mbU75JXjjNAP0af6yhYsRJ5vE/jCbxLBYgNgdOCvKCjIUiDVnCwuBDd5fRxb19NtyWmu7znL45rmoLpAyrH7lfpdZZ6f8pMJX1rp7c+jBEmVm990kwdoF1Mq5EIwSbsxYA7OOQLVaOpryYAolPwkq7XbjvIxEjKcvKfNrREb3v8DLQXJQcl+aCKXqbrMP91ypQjtnKUe3vMYMeu1yHiuy3ccSHXxrjyC5s/i9u9Vl6qfK371M257yy+qOZuWq25o5y5DbGbjlJRS889phzcCg7NaTggGzVZ6A+EtAgcMv7AbNo3Wrs5Qm/2Hajii1zKFwacnYm/yoLWxtGe0AgchLb07v78+4kZtXhKK7I+m rq5fifuo q9O8+A0NT8BlZomFw2rzcd4UYCtgmSqiQFX8S+9k/0KW+4eFh4zm3ZiT1TG10JHi7AVOjL1Y8c5uxgVI6AxzQyG6pYwS5v7yhZTsyERzXK3FHot4RbLczfmxy2QETCZFBi8+zLzUHl9iInHlxQpSIO9g6sxr+VOqGdossOgzqXSB6hpb9dGGBoR1nXMLWXfOBmjwbLun8RYrzpIZIZ6dQvnqRCoCacF5MR9nLYQevLTmSSUTQb+FD2HQBbU8Rcz+ow7pu8ho9JeGzdZwa5gBzBf3ncspFntors+ItkVKvIxZSs5naVsiUQg2Zp9oWD26zkuiVz/eC44yoCIzZ7/daWKO7KcEi6UkgEWtHtmvqSFJ3166Br5QfhaZ1zZyjHE6tEgzaDKZjKW7WBe/lKDINUv0JkfLfDb8t2Rt2SENnwgXtaJVbLyuZQQ+Au4wozUWeJK8X7sFQMqZWSOATTqCOlcD6w4rPPA0n5x9dsEQYYDIw6uW9wlwaCxI1Hy1w+ufFeXTVj1rXGDcgUQO9Nwuq8EWhJQ== 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: <linux-mm.kvack.org> |
Series |
splice, net: Replace sendpage with sendmsg(MSG_SPLICE_PAGES), part 1
|
expand
|
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index bd002222cf2d..b594da6d6bc1 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1048,6 +1048,14 @@ static int __ip_append_data(struct sock *sk, skb_zcopy_set(skb, uarg, &extra_uref); } } + } else if ((flags & MSG_SPLICE_PAGES) && length) { + if (inet->hdrincl) + return -EPERM; + if (rt->dst.dev->features & NETIF_F_SG) + /* We need an empty buffer to attach stuff to */ + paged = true; + else + flags &= ~MSG_SPLICE_PAGES; } cork->length += length; @@ -1207,6 +1215,15 @@ static int __ip_append_data(struct sock *sk, err = -EFAULT; goto error; } + } else if (flags & MSG_SPLICE_PAGES) { + struct msghdr *msg = from; + + err = skb_splice_from_iter(skb, &msg->msg_iter, copy, + sk->sk_allocation); + if (err < 0) + goto error; + copy = err; + wmem_alloc_delta += copy; } else if (!zc) { int i = skb_shinfo(skb)->nr_frags;
Make IP/UDP sendmsg() support MSG_SPLICE_PAGES. This causes pages to be spliced from the source iterator. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells <dhowells@redhat.com> cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com> cc: David Ahern <dsahern@kernel.org> cc: "David S. Miller" <davem@davemloft.net> cc: Eric Dumazet <edumazet@google.com> cc: Jakub Kicinski <kuba@kernel.org> cc: Paolo Abeni <pabeni@redhat.com> cc: Jens Axboe <axboe@kernel.dk> cc: Matthew Wilcox <willy@infradead.org> cc: netdev@vger.kernel.org --- Notes: ver #6) - Use common helper. net/ipv4/ip_output.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)