Skip to content

Commit eb1723a

Browse files
David Vrabeldavem330
authored andcommitted
xen-netback: refactor guest rx
Refactor the to-guest (rx) path to: 1. Push responses for completed skbs earlier, reducing latency. 2. Reduce the per-queue memory overhead by greatly reducing the maximum number of grant copy ops in each hypercall (from 4352 to 64). Each struct xenvif_queue is now only 44 kB instead of 220 kB. 3. Make the code more maintainable. Signed-off-by: David Vrabel <[email protected]> [re-based] Signed-off-by: Paul Durrant <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fedbc8c commit eb1723a

File tree

2 files changed

+215
-384
lines changed

2 files changed

+215
-384
lines changed

drivers/net/xen-netback/common.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,6 @@ struct xenvif_rx_meta {
9191
*/
9292
#define MAX_XEN_SKB_FRAGS (65536 / XEN_PAGE_SIZE + 1)
9393

94-
/* It's possible for an skb to have a maximal number of frags
95-
* but still be less than MAX_BUFFER_OFFSET in size. Thus the
96-
* worst-case number of copy operations is MAX_XEN_SKB_FRAGS per
97-
* ring slot.
98-
*/
99-
#define MAX_GRANT_COPY_OPS (MAX_XEN_SKB_FRAGS * XEN_NETIF_RX_RING_SIZE)
100-
10194
#define NETBACK_INVALID_HANDLE -1
10295

10396
/* To avoid confusion, we define XEN_NETBK_LEGACY_SLOTS_MAX indicating
@@ -133,6 +126,14 @@ struct xenvif_stats {
133126
unsigned long tx_frag_overflow;
134127
};
135128

129+
#define COPY_BATCH_SIZE 64
130+
131+
struct xenvif_copy_state {
132+
struct gnttab_copy op[COPY_BATCH_SIZE];
133+
RING_IDX idx[COPY_BATCH_SIZE];
134+
unsigned int num;
135+
};
136+
136137
struct xenvif_queue { /* Per-queue data for xenvif */
137138
unsigned int id; /* Queue ID, 0-based */
138139
char name[QUEUE_NAME_SIZE]; /* DEVNAME-qN */
@@ -189,12 +190,7 @@ struct xenvif_queue { /* Per-queue data for xenvif */
189190
unsigned long last_rx_time;
190191
bool stalled;
191192

192-
struct gnttab_copy grant_copy_op[MAX_GRANT_COPY_OPS];
193-
194-
/* We create one meta structure per ring request we consume, so
195-
* the maximum number is the same as the ring size.
196-
*/
197-
struct xenvif_rx_meta meta[XEN_NETIF_RX_RING_SIZE];
193+
struct xenvif_copy_state rx_copy;
198194

199195
/* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */
200196
unsigned long credit_bytes;
@@ -358,6 +354,7 @@ int xenvif_dealloc_kthread(void *data);
358354

359355
irqreturn_t xenvif_ctrl_irq_fn(int irq, void *data);
360356

357+
void xenvif_rx_action(struct xenvif_queue *queue);
361358
void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb);
362359

363360
void xenvif_carrier_on(struct xenvif *vif);

0 commit comments

Comments
 (0)