Commit af046fd1 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'for-uring-ubufops' into HEAD

Pavel Begunkov says:

====================
implement io_uring notification (ubuf_info) stacking (net part)

To have per request buffer notifications each zerocopy io_uring send
request allocates a new ubuf_info. However, as an skb can carry only
one uarg, it may force the stack to create many small skbs hurting
performance in many ways.

The patchset implements notification, i.e. an io_uring's ubuf_info
extension, stacking. It attempts to link ubuf_info's into a list,
allowing to have multiple of them per skb.

liburing/examples/send-zerocopy shows up 6 times performance improvement
for TCP with 4KB bytes per send, and levels it with MSG_ZEROCOPY. Without
the patchset it requires much larger sends to utilise all potential.

bytes  | before | after (Kqps)
1200   | 195    | 1023
4000   | 193    | 1386
8000   | 154    | 1058
====================

Link: https://lore.kernel.org/all/cover.1713369317.git.asml.silence@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 65f1df11 65bada80
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -754,7 +754,7 @@ static ssize_t tap_get_user(struct tap_queue *q, void *msg_control,
		skb_zcopy_init(skb, msg_control);
	} else if (msg_control) {
		struct ubuf_info *uarg = msg_control;
		uarg->callback(NULL, uarg, false);
		uarg->ops->complete(NULL, uarg, false);
	}

	dev_queue_xmit(skb);
+1 −1
Original line number Diff line number Diff line
@@ -1906,7 +1906,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
		skb_zcopy_init(skb, msg_control);
	} else if (msg_control) {
		struct ubuf_info *uarg = msg_control;
		uarg->callback(NULL, uarg, false);
		uarg->ops->complete(NULL, uarg, false);
	}

	skb_reset_network_header(skb);
+2 −3
Original line number Diff line number Diff line
@@ -390,9 +390,8 @@ bool xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb);

void xenvif_carrier_on(struct xenvif *vif);

/* Callback from stack when TX packet can be released */
void xenvif_zerocopy_callback(struct sk_buff *skb, struct ubuf_info *ubuf,
			      bool zerocopy_success);
/* Callbacks from stack when TX packet can be released */
extern const struct ubuf_info_ops xenvif_ubuf_ops;

static inline pending_ring_idx_t nr_pending_reqs(struct xenvif_queue *queue)
{
+1 −1
Original line number Diff line number Diff line
@@ -593,7 +593,7 @@ int xenvif_init_queue(struct xenvif_queue *queue)

	for (i = 0; i < MAX_PENDING_REQS; i++) {
		queue->pending_tx_info[i].callback_struct = (struct ubuf_info_msgzc)
			{ { .callback = xenvif_zerocopy_callback },
			{ { .ops = &xenvif_ubuf_ops },
			  { { .ctx = NULL,
			      .desc = i } } };
		queue->grant_tx_handle[i] = NETBACK_INVALID_HANDLE;
+8 −3
Original line number Diff line number Diff line
@@ -1157,7 +1157,7 @@ static int xenvif_handle_frag_list(struct xenvif_queue *queue, struct sk_buff *s
	uarg = skb_shinfo(skb)->destructor_arg;
	/* increase inflight counter to offset decrement in callback */
	atomic_inc(&queue->inflight_packets);
	uarg->callback(NULL, uarg, true);
	uarg->ops->complete(NULL, uarg, true);
	skb_shinfo(skb)->destructor_arg = NULL;

	/* Fill the skb with the new (local) frags. */
@@ -1279,7 +1279,8 @@ static int xenvif_tx_submit(struct xenvif_queue *queue)
	return work_done;
}

void xenvif_zerocopy_callback(struct sk_buff *skb, struct ubuf_info *ubuf_base,
static void xenvif_zerocopy_callback(struct sk_buff *skb,
				     struct ubuf_info *ubuf_base,
				     bool zerocopy_success)
{
	unsigned long flags;
@@ -1313,6 +1314,10 @@ void xenvif_zerocopy_callback(struct sk_buff *skb, struct ubuf_info *ubuf_base,
	xenvif_skb_zerocopy_complete(queue);
}

const struct ubuf_info_ops xenvif_ubuf_ops = {
	.complete = xenvif_zerocopy_callback,
};

static inline void xenvif_tx_dealloc_action(struct xenvif_queue *queue)
{
	struct gnttab_unmap_grant_ref *gop;
Loading