[PATCH net-next v2 16/17] sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)

2023-06-17 Thread David Howells
Remove ->sendpage() and ->sendpage_locked().  sendmsg() with
MSG_SPLICE_PAGES should be used instead.  This allows multiple pages and
multipage folios to be passed through.

Signed-off-by: David Howells 
Acked-by: Marc Kleine-Budde  # for net/can
cc: "David S. Miller" 
cc: Eric Dumazet 
cc: Jakub Kicinski 
cc: Paolo Abeni 
cc: Jens Axboe 
cc: Matthew Wilcox 
cc: b...@vger.kernel.org
cc: d...@vger.kernel.org
cc: linux-...@lists.infradead.org
cc: linux-arm-...@vger.kernel.org
cc: linux-...@vger.kernel.org
cc: linux-cry...@vger.kernel.org
cc: linux-...@vger.kernel.org
cc: linux-fsde...@vger.kernel.org
cc: linux-h...@vger.kernel.org
cc: linux-...@vger.kernel.org
cc: linux-r...@vger.kernel.org
cc: linux-s...@vger.kernel.org
cc: linux-w...@vger.kernel.org
cc: linux-...@vger.kernel.org
cc: mp...@lists.linux.dev
cc: net...@vger.kernel.org
cc: rds-de...@oss.oracle.com
cc: tipc-discuss...@lists.sourceforge.net
cc: virtualization@lists.linux-foundation.org
---

Notes:
ver #2)
 - Removed duplicate word in comment.

 Documentation/bpf/map_sockmap.rst | 10 ++--
 Documentation/filesystems/locking.rst |  2 -
 Documentation/filesystems/vfs.rst |  1 -
 Documentation/networking/scaling.rst  |  4 +-
 crypto/af_alg.c   | 28 ---
 crypto/algif_aead.c   | 22 ++---
 crypto/algif_rng.c|  2 -
 crypto/algif_skcipher.c   | 14 --
 .../chelsio/inline_crypto/chtls/chtls.h   |  2 -
 .../chelsio/inline_crypto/chtls/chtls_io.c| 14 --
 .../chelsio/inline_crypto/chtls/chtls_main.c  |  1 -
 fs/nfsd/vfs.c |  2 +-
 include/crypto/if_alg.h   |  2 -
 include/linux/net.h   |  8 
 include/net/inet_common.h |  2 -
 include/net/sock.h|  6 ---
 include/net/tcp.h |  4 --
 net/appletalk/ddp.c   |  1 -
 net/atm/pvc.c |  1 -
 net/atm/svc.c |  1 -
 net/ax25/af_ax25.c|  1 -
 net/caif/caif_socket.c|  2 -
 net/can/bcm.c |  1 -
 net/can/isotp.c   |  1 -
 net/can/j1939/socket.c|  1 -
 net/can/raw.c |  1 -
 net/core/sock.c   | 35 +-
 net/dccp/ipv4.c   |  1 -
 net/dccp/ipv6.c   |  1 -
 net/ieee802154/socket.c   |  2 -
 net/ipv4/af_inet.c| 21 
 net/ipv4/tcp.c| 43 ++---
 net/ipv4/tcp_bpf.c| 23 +
 net/ipv4/tcp_ipv4.c   |  1 -
 net/ipv4/udp.c| 15 --
 net/ipv4/udp_impl.h   |  2 -
 net/ipv4/udplite.c|  1 -
 net/ipv6/af_inet6.c   |  3 --
 net/ipv6/raw.c|  1 -
 net/ipv6/tcp_ipv6.c   |  1 -
 net/kcm/kcmsock.c | 20 
 net/key/af_key.c  |  1 -
 net/l2tp/l2tp_ip.c|  1 -
 net/l2tp/l2tp_ip6.c   |  1 -
 net/llc/af_llc.c  |  1 -
 net/mctp/af_mctp.c|  1 -
 net/mptcp/protocol.c  |  2 -
 net/netlink/af_netlink.c  |  1 -
 net/netrom/af_netrom.c|  1 -
 net/packet/af_packet.c|  2 -
 net/phonet/socket.c   |  2 -
 net/qrtr/af_qrtr.c|  1 -
 net/rds/af_rds.c  |  1 -
 net/rose/af_rose.c|  1 -
 net/rxrpc/af_rxrpc.c  |  1 -
 net/sctp/protocol.c   |  1 -
 net/socket.c  | 48 ---
 net/tipc/socket.c |  3 --
 net/tls/tls.h |  6 ---
 net/tls/tls_device.c  | 17 ---
 net/tls/tls_main.c|  7 ---
 net/tls/tls_sw.c  | 35 --
 net/unix/af_unix.c| 19 
 net/vmw_vsock/af_vsock.c  |  3 --
 net/x25/af_x25.c  |  1 -
 net/xdp/xsk.c |  1 -
 66 files changed, 20 insertions(+), 442 deletions(-)

diff --git a/Documentation/bpf/map_sockmap.rst 
b/Documentation/bpf/map_sockmap.rst
index cc92047c6630..2d630686a00b 100644
--- a/Documentation/bpf/map_sockmap.rst
+++ b/Documentation/bpf/map_sockmap.rst
@@ 

[PATCH net-next v2 17/17] net: Kill MSG_SENDPAGE_NOTLAST

2023-06-17 Thread David Howells
Now that ->sendpage() has been removed, MSG_SENDPAGE_NOTLAST can be cleaned
up.  Things were converted to use MSG_MORE instead, but the protocol
sendpage stubs still convert MSG_SENDPAGE_NOTLAST to MSG_MORE, which is now
unnecessary.

Signed-off-by: David Howells 
cc: "David S. Miller" 
cc: Eric Dumazet 
cc: Jakub Kicinski 
cc: Paolo Abeni 
cc: Jens Axboe 
cc: Matthew Wilcox 
cc: b...@vger.kernel.org
cc: d...@vger.kernel.org
cc: linux-...@lists.infradead.org
cc: linux-arm-...@vger.kernel.org
cc: linux-...@vger.kernel.org
cc: linux-cry...@vger.kernel.org
cc: linux-...@vger.kernel.org
cc: linux-h...@vger.kernel.org
cc: linux-perf-us...@vger.kernel.org
cc: linux-r...@vger.kernel.org
cc: linux-s...@vger.kernel.org
cc: linux-w...@vger.kernel.org
cc: linux-...@vger.kernel.org
cc: mp...@lists.linux.dev
cc: net...@vger.kernel.org
cc: rds-de...@oss.oracle.com
cc: tipc-discuss...@lists.sourceforge.net
cc: virtualization@lists.linux-foundation.org
---
 include/linux/socket.h | 4 +---
 net/ipv4/tcp_bpf.c | 4 +++-
 net/tls/tls_device.c   | 3 +--
 net/tls/tls_main.c | 2 +-
 net/tls/tls_sw.c   | 2 +-
 tools/perf/trace/beauty/include/linux/socket.h | 1 -
 tools/perf/trace/beauty/msg_flags.c| 3 ---
 7 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/include/linux/socket.h b/include/linux/socket.h
index 58204700018a..39b74d83c7c4 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -319,7 +319,6 @@ struct ucred {
 #define MSG_MORE   0x8000  /* Sender will send more */
 #define MSG_WAITFORONE 0x1 /* recvmmsg(): block until 1+ packets avail */
 #define MSG_SENDPAGE_NOPOLICY 0x1 /* sendpage() internal : do no apply 
policy */
-#define MSG_SENDPAGE_NOTLAST 0x2 /* sendpage() internal : not the last 
page */
 #define MSG_BATCH  0x4 /* sendmmsg(): more messages coming */
 #define MSG_EOF MSG_FIN
 #define MSG_NO_SHARED_FRAGS 0x8 /* sendpage() internal : page frags are 
not shared */
@@ -341,8 +340,7 @@ struct ucred {
 
 /* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */
 #define MSG_INTERNAL_SENDMSG_FLAGS \
-   (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_NOTLAST | \
-MSG_SENDPAGE_DECRYPTED)
+   (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_DECRYPTED)
 
 /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
 #define SOL_IP 0
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 870c1cde4010..8f535e436ea3 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -90,7 +90,9 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, 
u32 apply_bytes,
 {
bool apply = apply_bytes;
struct scatterlist *sge;
-   struct msghdr msghdr = { .msg_flags = flags | MSG_SPLICE_PAGES, };
+   struct msghdr msghdr = {
+   .msg_flags = flags | MSG_SPLICE_PAGES | MSG_MORE,
+   };
struct page *page;
int size, ret = 0;
u32 off;
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 840ee06f1708..2021fe557e50 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -441,8 +441,7 @@ static int tls_push_data(struct sock *sk,
long timeo;
 
if (flags &
-   ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SENDPAGE_NOTLAST |
- MSG_SPLICE_PAGES))
+   ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SPLICE_PAGES))
return -EOPNOTSUPP;
 
if (unlikely(sk->sk_err))
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index d5ed4d47b16e..b6896126bb92 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -127,7 +127,7 @@ int tls_push_sg(struct sock *sk,
 {
struct bio_vec bvec;
struct msghdr msg = {
-   .msg_flags = MSG_SENDPAGE_NOTLAST | MSG_SPLICE_PAGES | flags,
+   .msg_flags = MSG_SPLICE_PAGES | flags,
};
int ret = 0;
struct page *p;
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 9b3aa89a4292..53f944e6d8ef 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1194,7 +1194,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, 
size_t size)
 
if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL |
   MSG_CMSG_COMPAT | MSG_SPLICE_PAGES |
-  MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY))
+  MSG_SENDPAGE_NOPOLICY))
return -EOPNOTSUPP;
 
ret = mutex_lock_interruptible(&tls_ctx->tx_lock);
diff --git a/tools/perf/trace/beauty/include/linux/socket.h 
b/tools/perf/trace/beauty/include/linux/socket.h
index 13c3a237b9c9..3bef212a24d7 100644
--- a/tools/perf/trace/beauty/include/linux/socket.h
+++ b/tools/perf/trace/beauty/include/linux/socket.h
@@ -318,7 +318,6 @@ struct ucred {
 #define MSG_MORE   0x8000  /* Sender will send m

Re: [RFC PATCH net 0/3] virtio-net: allow usage of small vrings

2023-06-17 Thread Michael S. Tsirkin
On Sun, Apr 30, 2023 at 04:15:15PM +0300, Alvaro Karsz wrote:
> At the moment, if a virtio network device uses vrings with less than
> MAX_SKB_FRAGS + 2 entries, the device won't be functional.
> 
> The following condition vq->num_free >= 2 + MAX_SKB_FRAGS will always
> evaluate to false, leading to TX timeouts.
> 
> This patchset attempts this fix this bug, and to allow small rings down
> to 4 entries.
> 
> The first patch introduces a new mechanism in virtio core - it allows to
> block features in probe time.
> 
> If a virtio drivers blocks features and fails probe, virtio core will
> reset the device, re-negotiate the features and probe again.
> 
> This is needed since some virtio net features are not supported with
> small rings.
> 
> This patchset follows a discussion in the mailing list [1].
> 
> This fixes only part of the bug, rings with less than 4 entries won't
> work.
> My intention is to split the effort and fix the RING_SIZE < 4 case in a
> follow up patchset.
> 
> Maybe we should fail probe if RING_SIZE < 4 until the follow up patchset?
> 
> I tested the patchset with SNET DPU (drivers/vdpa/solidrun), with packed
> and split VQs, with rings down to 4 entries, with and without
> VIRTIO_NET_F_MRG_RXBUF, with big MTUs.
> 
> I would appreciate more testing.
> Xuan: I wasn't able to test XDP with my setup, maybe you can help with
> that?
> 
> [1] 
> https://lore.kernel.org/lkml/20230416074607.292616-1-alvaro.ka...@solid-run.com/

the work is orphaned for now. Jason do you want to pick this up?
Related to all the hardening I guess ...

> Alvaro Karsz (3):
>   virtio: re-negotiate features if probe fails and features are blocked
>   virtio-net: allow usage of vrings smaller than MAX_SKB_FRAGS + 2
>   virtio-net: block ethtool from converting a ring to a small ring
> 
>  drivers/net/virtio_net.c | 161 +--
>  drivers/virtio/virtio.c  |  73 +-
>  include/linux/virtio.h   |   3 +
>  3 files changed, 212 insertions(+), 25 deletions(-)
> 
> -- 
> 2.34.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization