xen-netback: switch to NAPI + kthread 1:1 model
Subsystems (2)
v4 cover xen-netback: switch to NAPI + kthread 1:1 model
This series implements NAPI + kthread 1:1 model for Xen netback.
This model
- provides better scheduling fairness among vifs
- is prerequisite for implementing multiqueue for Xen network driver
The first two patches are ground work for the third patch. First one simplifies code in netback, second one can reduce memory footprint if we switch to 1:1 model.
The third patch has the real meat:
- make use of NAPI to mitigate interrupt
- kthreads are not bound to CPUs any more, so that we can take advantage of backend scheduler and trust it to do the right thing
Benchmark done on a Dell T3400 workstation with 4 cores, running 4 DomUs. Netserver running in Dom0. DomUs do netperf to Dom0 with following command: /root/netperf -H Dom0 -fm -l120
IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
* New model
%Cpu0 : 0.5 us, 20.3 sy, 0.0 ni, 28.9 id, 0.0 wa, 0.0 hi, 24.4 si, 25.9 st %Cpu1 : 0.5 us, 17.8 sy, 0.0 ni, 28.8 id, 0.0 wa, 0.0 hi, 27.7 si, 25.1 st %Cpu2 : 0.5 us, 18.8 sy, 0.0 ni, 30.7 id, 0.0 wa, 0.0 hi, 22.9 si, 27.1 st %Cpu3 : 0.0 us, 20.1 sy, 0.0 ni, 30.4 id, 0.0 wa, 0.0 hi, 22.7 si, 26.8 st
Throughputs: 2027.89 2025.95 2018.57 2016.23 aggregated: 8088.64
* Old model
%Cpu0 : 0.5 us, 68.8 sy, 0.0 ni, 16.1 id, 0.5 wa, 0.0 hi, 2.8 si, 11.5 st %Cpu1 : 0.4 us, 45.1 sy, 0.0 ni, 31.1 id, 0.4 wa, 0.0 hi, 2.1 si, 20.9 st %Cpu2 : 0.9 us, 44.8 sy, 0.0 ni, 30.9 id, 0.0 wa, 0.0 hi, 1.3 si, 22.2 st %Cpu3 : 0.8 us, 46.4 sy, 0.0 ni, 28.3 id, 1.3 wa, 0.0 hi, 2.1 si, 21.1 st
Throughputs: 1899.14 2280.43 1963.33 1893.47 aggregated: 8036.37
We can see that the impact is mainly on CPU usage. The new model moves processing from kthread to NAPI (software interrupt).
Changes since V3:
* rebase on top of net-next
* group TX and RX fields in different regions of the structure
* minor bugfix : use GFP_ATOMIC to avoid sleeping in SI context
* split functional changes and funcation renames into two patches
* minor coding style fixes
Wei Liu (3):
xen-netback: remove page tracking facility
xen-netback: switch to NAPI + kthread 1:1 model
xen-netback: rename functions
drivers/net/xen-netback/common.h | 127 ++++-- drivers/net/xen-netback/interface.c | 119 +++-- drivers/net/xen-netback/netback.c | 833 +++++++++++------------------------ 3 files changed, 406 insertions(+), 673 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v4 1/3 xen-netback: remove page tracking facility
The data flow from DomU to DomU on the same host in current copying scheme with tracking facility:
copy
DomU --------> Dom0 DomU
| ^ |____________________________|
copy
The page in Dom0 is a page with valid MFN. So we can always copy from page Dom0, thus removing the need for a tracking facility.
copy copy
DomU --------> Dom0 -------> DomU
Simple iperf test shows no performance regression (obviously we copy twice either way):
W/ tracking: ~5.3Gb/s
W/o tracking: ~5.4Gb/s
--- drivers/net/xen-netback/netback.c | 77 +------------------------------------ 1 file changed, 2 insertions(+), 75 deletions(-)
drivers/net/xen-netback/netback.c +2 -75
@@ -95,21 +95,6 @@ struct netbk_rx_meta {#define MAX_BUFFER_OFFSET PAGE_SIZE -/* extra field used in struct page */ -union page_ext { -struct { -#if BITS_PER_LONG <64 -#define IDX_WIDTH 8 -#define GROUP_WIDTH (BITS_PER_LONG - IDX_WIDTH) -unsigned int group:GROUP_WIDTH ; -unsigned int idx:IDX_WIDTH ; -#else -unsigned int group, idx; -#endif - } e; -void *mapping; -}; -struct xen_netbk {wait_queue_head_t wq;struct task_struct *task;
@@ -214,45 +199,6 @@ static inline unsigned long idx_to_kaddr(struct xen_netbk *netbk,return (unsigned long )pfn_to_kaddr (idx_to_pfn (netbk, idx)); } -/* extra field used in struct page */ -static inline void set_page_ext (struct page *pg,struct xen_netbk *netbk, -unsigned int idx) -{ -unsigned int group = netbk - xen_netbk; -union page_ext ext = { .e = { .group = group +1 , .idx = idx } }; - -BUILD_BUG_ON (sizeof (ext) >sizeof (ext.mapping)); - pg->mapping = ext.mapping; -} - -static int get_page_ext (struct page *pg, -unsigned int *pgroup,unsigned int *pidx) -{ -union page_ext ext = { .mapping = pg->mapping }; -struct xen_netbk *netbk; -unsigned int group, idx; - - group = ext.e.group -1 ; - -if (group <0 || group >= xen_netbk_group_nr) -return 0 ; - - netbk = &xen_netbk[group]; - - idx = ext.e.idx; - -if ((idx <0 ) || (idx >=MAX_PENDING_REQS )) -return 0 ; - -if (netbk->mmap_pages[idx] != pg) -return 0 ; - - *pgroup = group; - *pidx = idx; - -return 1 ; -} -/* * This is the amount of packet we copy rather than map, so that the * guest can't fiddle with the contents of the headers while we do
@@ -453,12 +399,6 @@ static void netbk_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb, {struct gnttab_copy *copy_gop;struct netbk_rx_meta *meta; -/* -* These variables are used iff get_page_ext returns true, -* in which case they are guaranteed to be initialized. -*/ -unsigned int uninitialized_var (group ),uninitialized_var (idx ); -int foreign =get_page_ext (page, &group, &idx);unsigned long bytes;/* Data must not cross a page boundary. */
@@ -494,20 +434,9 @@ static void netbk_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb, copy_gop = npo->copy + npo->copy_prod++; copy_gop->flags = GNTCOPY_dest_gref; -if (foreign) { -struct xen_netbk *netbk = &xen_netbk[group]; -struct pending_tx_info *src_pend; + copy_gop->source.domid =DOMID_SELF ; + copy_gop->source.u.gmfn =virt_to_mfn (page_address (page)); - src_pend = &netbk->pending_tx_info[idx]; - - copy_gop->source.domid = src_pend->vif->domid; - copy_gop->source.u.ref = src_pend->req.gref; - copy_gop->flags |= GNTCOPY_source_gref; - }else { -void *vaddr =page_address (page); - copy_gop->source.domid =DOMID_SELF ; - copy_gop->source.u.gmfn =virt_to_mfn (vaddr); - } copy_gop->source.offset = offset; copy_gop->dest.domid = vif->domid;
@@ -1047,7 +976,6 @@ static struct page *xen_netbk_alloc_page(struct xen_netbk *netbk, page =alloc_page (GFP_KERNEL |__GFP_COLD);if (!page)return NULL ; -set_page_ext (page, netbk, pending_idx); netbk->mmap_pages[pending_idx] = page;return page; }
@@ -1155,7 +1083,6 @@ static struct gnttab_copy *xen_netbk_get_requests(struct xen_netbk *netbk, first->req.offset =0 ; first->req.size = dst_offset; first->head = start_idx; -set_page_ext (page, netbk, head_idx); netbk->mmap_pages[head_idx] = page;frag_set_pending_idx (&frags[shinfo->nr_frags], head_idx); }
Signature · 1 line
1.7.10.4
PATCH v4 2/3 xen-netback: switch to NAPI + kthread 1:1 model
In reply to Wei LiuThis patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)
Xenvif and xen_netbk are made into one structure to reduce code size.
This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
--- drivers/net/xen-netback/common.h | 107 +++--- drivers/net/xen-netback/interface.c | 103 +++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 310 insertions(+), 507 deletions(-)
drivers/net/xen-netback/common.h +69 -38
@@ -45,31 +45,84 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +struct pending_tx_info { +struct xen_netif_tx_request req;/* coalesced tx request */ +pending_ring_idx_t head;/* head != INVALID_PENDING_RING_IDX +* if it is head of one or more tx +* reqs +*/ +}; + +#define XEN_NETIF_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE) +#define XEN_NETIF_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE) + +struct xenvif_rx_meta { +int id; +int size; +int gso_size; +}; + +/* Discriminate from any valid pending_idx value. */ +#define INVALID_PENDING_IDX 0xFFFF + +#define MAX_BUFFER_OFFSET PAGE_SIZE + +#define MAX_PENDING_REQS 256struct xenvif {/* Unique identifier for this interface. */ domid_t domid;unsigned int handle; -/* Reference to netback processing backend. */ -struct xen_netbk *netbk; +/* Use NAPI for guest TX */ +struct napi_struct napi; +/* When feature-split-event-channels = 0, tx_irq = rx_irq. */ +unsigned int tx_irq; +/* Only used when feature-split-event-channels = 1 */ +char tx_irq_name[IFNAMSIZ +4 ];/* DEVNAME-tx */ +struct xen_netif_tx_back_ring tx; +struct sk_buff_head tx_queue; +struct page *mmap_pages[MAX_PENDING_REQS ]; +pending_ring_idx_t pending_prod; +pending_ring_idx_t pending_cons; +u16 pending_ring[MAX_PENDING_REQS ]; +struct pending_tx_info pending_tx_info[MAX_PENDING_REQS ]; + +/* Coalescing tx requests before copying makes number of grant +* copy ops greater or equal to number of slots required. In +* worst case a tx request consumes 2 gnttab_copy. +*/ +struct gnttab_copy tx_copy_ops[2 *MAX_PENDING_REQS ]; -u8 fe_dev_addr[6 ]; +/* Use kthread for guest RX */ +struct task_struct *task; +wait_queue_head_t wq;/* When feature-split-event-channels = 0, tx_irq = rx_irq. */ -unsigned int tx_irq;unsigned int rx_irq;/* Only used when feature-split-event-channels = 1 */ -char tx_irq_name[IFNAMSIZ +4 ];/* DEVNAME-tx */ char rx_irq_name[IFNAMSIZ +4 ];/* DEVNAME-rx */ +struct xen_netif_rx_back_ring rx; +struct sk_buff_head rx_queue; -/* List of frontends to notify after a batch of frames sent. */ -struct list_head notify_list; +/* Allow xenvif_start_xmit() to peek ahead in the rx request +* ring. This is a prediction of what rx_req_cons will be +* once all queued skbs are put on the ring. +*/ +RING_IDX rx_req_cons_peek; + +/* Given MAX_BUFFER_OFFSET of 4096 the worst case is that each +* head/fragment page uses 2 copy operations because it +* straddles two buffers in the frontend. +*/ +struct gnttab_copy grant_copy_op[2 *XEN_NETIF_RX_RING_SIZE ]; +struct xenvif_rx_meta meta[2 *XEN_NETIF_RX_RING_SIZE ]; -/* The shared rings and indexes. */ -struct xen_netif_tx_back_ring tx; -struct xen_netif_rx_back_ring rx; + +u8 fe_dev_addr[6 ];/* Frontend feature information. */ u8 can_sg:1 ;
@@ -80,13 +133,6 @@ struct xenvif {/* Internal feature information. */ u8 can_queue:1; /* can queue packets for receiver? */ -/* -* Allow xenvif_start_xmit() to peek ahead in the rx request -* ring. This is a prediction of what rx_req_cons will be -* once all queued skbs are put on the ring. -*/ -RING_IDX rx_req_cons_peek; -/* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */ unsigned long credit_bytes;unsigned long credit_usec;
@@ -97,11 +143,7 @@ struct xenvif {unsigned long rx_gso_checksum_fixup;/* Miscellaneous private stuff. */ -struct list_head schedule_list; -atomic_t refcnt;struct net_device *dev; - -wait_queue_head_t waiting_to_free; };static inline struct xenbus_device *xenvif_to_xenbus_device (struct xenvif *vif)
@@ -109,9 +151,6 @@ static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif)return to_xenbus_device (vif->dev->dev.parent); } -#define XEN_NETIF_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE) -#define XEN_NETIF_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE) -struct xenvif *xenvif_alloc (struct device *parent,domid_t domid,unsigned int handle);
@@ -121,9 +160,6 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref, unsigned int rx_evtchn);void xenvif_disconnect (struct xenvif *vif); -void xenvif_get (struct xenvif *vif); -void xenvif_put (struct xenvif *vif); -int xenvif_xenbus_init (void );void xenvif_xenbus_fini (void );
@@ -139,18 +175,8 @@ int xen_netbk_map_frontend_rings(struct xenvif *vif,grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref); -/* (De)Register a xenvif with the netback backend. */ -void xen_netbk_add_xenvif (struct xenvif *vif); -void xen_netbk_remove_xenvif (struct xenvif *vif); - -/* (De)Schedule backend processing for a xenvif */ -void xen_netbk_schedule_xenvif (struct xenvif *vif); -void xen_netbk_deschedule_xenvif (struct xenvif *vif); -/* Check for SKBs from frontend and schedule backend processing */ void xen_netbk_check_rx_xenvif (struct xenvif *vif); -/* Receive an SKB from the frontend */ -void xenvif_receive_skb (struct xenvif *vif,struct sk_buff *skb);/* Queue an SKB for transmission to the frontend */ void xen_netbk_queue_tx_skb (struct xenvif *vif,struct sk_buff *skb);
@@ -163,6 +189,11 @@ void xenvif_carrier_off(struct xenvif *vif);/* Returns number of ring slots required to send an skb to the frontend */ unsigned int xen_netbk_count_skb_slots (struct xenvif *vif,struct sk_buff *skb); +int xen_netbk_tx_action (struct xenvif *vif,int budget); +void xen_netbk_rx_action (struct xenvif *vif); + +int xen_netbk_kthread (void *data); +extern bool separate_tx_rx_irq;#endif /* __XEN_NETBACK__COMMON_H__ */
drivers/net/xen-netback/interface.c +64 -39
225 lines not on this page · raw message
drivers/net/xen-netback/netback.c +177 -430
1,105 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v4 3/3 xen-netback: rename functions
In reply to Wei LiuAs we move to 1:1 model and melt xen_netbk and xenvif together, it would be better to use single prefix for all functions in xen-netback.
--- drivers/net/xen-netback/common.h | 24 ++-- drivers/net/xen-netback/interface.c | 20 ++-- drivers/net/xen-netback/netback.c | 223 ++++++++++++++++++----------------- 3 files changed, 134 insertions(+), 133 deletions(-)
drivers/net/xen-netback/common.h +12 -12
@@ -165,21 +165,21 @@ void xenvif_xenbus_fini(void);int xenvif_schedulable (struct xenvif *vif); -int xen_netbk_rx_ring_full (struct xenvif *vif); +int xenvif_rx_ring_full (struct xenvif *vif); -int xen_netbk_must_stop_queue (struct xenvif *vif); +int xenvif_must_stop_queue (struct xenvif *vif);/* (Un)Map communication rings. */ -void xen_netbk_unmap_frontend_rings (struct xenvif *vif); -int xen_netbk_map_frontend_rings (struct xenvif *vif, -grant_ref_t tx_ring_ref, -grant_ref_t rx_ring_ref); +void xenvif_unmap_frontend_rings (struct xenvif *vif); +int xenvif_map_frontend_rings (struct xenvif *vif, +grant_ref_t tx_ring_ref, +grant_ref_t rx_ring_ref);/* Check for SKBs from frontend and schedule backend processing */ -void xen_netbk_check_rx_xenvif (struct xenvif *vif); +void xenvif_check_rx_xenvif (struct xenvif *vif);/* Queue an SKB for transmission to the frontend */ -void xen_netbk_queue_tx_skb (struct xenvif *vif,struct sk_buff *skb); +void xenvif_queue_tx_skb (struct xenvif *vif,struct sk_buff *skb);/* Notify xenvif that ring now has space to send an skb to the frontend */ void xenvif_notify_tx_completion (struct xenvif *vif);
@@ -187,12 +187,12 @@ void xenvif_notify_tx_completion(struct xenvif *vif);void xenvif_carrier_off (struct xenvif *vif);/* Returns number of ring slots required to send an skb to the frontend */ -unsigned int xen_netbk_count_skb_slots (struct xenvif *vif,struct sk_buff *skb); +unsigned int xenvif_count_skb_slots (struct xenvif *vif,struct sk_buff *skb); -int xen_netbk_tx_action (struct xenvif *vif,int budget); -void xen_netbk_rx_action (struct xenvif *vif); +int xenvif_tx_action (struct xenvif *vif,int budget); +void xenvif_rx_action (struct xenvif *vif); -int xen_netbk_kthread (void *data); +int xenvif_kthread (void *data);extern bool separate_tx_rx_irq;
drivers/net/xen-netback/interface.c +10 -10
@@ -48,7 +48,7 @@ int xenvif_schedulable(struct xenvif *vif)static int xenvif_rx_schedulable (struct xenvif *vif) { -return xenvif_schedulable (vif) && !xen_netbk_rx_ring_full (vif); +return xenvif_schedulable (vif) && !xenvif_rx_ring_full (vif); }static irqreturn_t xenvif_tx_interrupt (int irq,void *dev_id)
@@ -66,7 +66,7 @@ static int xenvif_poll(struct napi_struct *napi, int budget) struct xenvif *vif = container_of(napi, struct xenvif, napi);int work_done; - work_done =xen_netbk_tx_action (vif, budget); + work_done =xenvif_tx_action (vif, budget);if (work_done < budget) {int more_to_do =0 ;
@@ -117,12 +117,12 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) goto drop;/* Reserve ring slots for the worst-case number of fragments. */ - vif->rx_req_cons_peek +=xen_netbk_count_skb_slots (vif, skb); + vif->rx_req_cons_peek +=xenvif_count_skb_slots (vif, skb); -if (vif->can_queue &&xen_netbk_must_stop_queue (vif)) +if (vif->can_queue &&xenvif_must_stop_queue (vif))netif_stop_queue (dev); -xen_netbk_queue_tx_skb (vif, skb); +xenvif_queue_tx_skb (vif, skb);return NETDEV_TX_OK ;
@@ -150,7 +150,7 @@ static void xenvif_up(struct xenvif *vif)enable_irq (vif->tx_irq);if (vif->tx_irq != vif->rx_irq)enable_irq (vif->rx_irq); -xen_netbk_check_rx_xenvif (vif); +xenvif_check_rx_xenvif (vif); }static void xenvif_down (struct xenvif *vif)
@@ -352,7 +352,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,__module_get (THIS_MODULE ); - err =xen_netbk_map_frontend_rings (vif, tx_ring_ref, rx_ring_ref); + err =xenvif_map_frontend_rings (vif, tx_ring_ref, rx_ring_ref);if (err <0 ) goto err;
@@ -389,7 +389,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref, }init_waitqueue_head (&vif->wq); - vif->task =kthread_create (xen_netbk_kthread, + vif->task =kthread_create (xenvif_kthread, (void *)vif, vif->dev->name);if (IS_ERR (vif->task)) {pr_warn ("Could not allocate kthread for %s\n" , vif->dev->name);
@@ -417,7 +417,7 @@ err_tx_unbind:unbind_from_irqhandler (vif->tx_irq, vif); vif->tx_irq =0 ; err_unmap: -xen_netbk_unmap_frontend_rings (vif); +xenvif_unmap_frontend_rings (vif); err:module_put (THIS_MODULE );return err;
@@ -465,7 +465,7 @@ void xenvif_disconnect(struct xenvif *vif)unregister_netdev (vif->dev); -xen_netbk_unmap_frontend_rings (vif); +xenvif_unmap_frontend_rings (vif);free_netdev (vif->dev);
drivers/net/xen-netback/netback.c +112 -111
613 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 4 lines · Wei Liu
IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
Hmm.. so with these patches applied is is *required* to do manual configuration in dom0 to get good performance?
Thanks,
-- Pasi
Quoted 8 lines · Pasi Kärkkäinen
Quoted 4 lines · Wei Liu
IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
Hmm.. so with these patches applied is is *required* to do manual configuration in dom0 to get good performance?
Sort of. But you can use irqbalance to do the job for you.
Wei.
Quoted 3 lines
Thanks,
-- Pasi
Quoted 7 lines · Pasi Kärkkäinen
Quoted 4 lines · Wei Liu
IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
Hmm.. so with these patches applied is is *required* to do manual configuration in dom0 to get good performance?
This should be irqbalanced's job. The existing version doesn't do a good enough job yet though. Andrew Bennieston may have more details.
David
I sent this patch right before Ian requested more comments in code. Now I've updated this one. Not going to resend the whole series as this is only changes in comments.
Sorry for my bad English, I don't know whether I've made them clear enough. Suggestions are welcomed.
Wei.
---8<---
Quoted 1 line
From
bb33027fe4bafeea546352cd3e409466f8bd7aa4Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Tue, 6 Aug 2013 06:59:15 +0100
Subject: [PATCH] xen-netback: switch to NAPI + kthread 1:1 model
This patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)
Xenvif and xen_netbk are made into one structure to reduce code size.
This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
--- drivers/net/xen-netback/common.h | 128 +++++--- drivers/net/xen-netback/interface.c | 119 ++++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 347 insertions(+), 507 deletions(-)
drivers/net/xen-netback/common.h +90 -38
@@ -45,31 +45,105 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +/* For the head field in pending_tx_info: It is used to indicate +* whether this tx info is the head of one or more coalesced requests. +* +* When head != INVALID_PENDING_RING_IDX, it means the start of a new +* tx requests queue and the end of previous queue. +* +* An example sequence of head fields (I = INVALID_PENDING_RING_IDX): +* +* ... 0 I I I 5 I 9 I I I ... +* +* After consming the first packet we have: +* +* ... V V V V 5 I 9 I I I ... +* +* where V stands for "valid pending ring index", any number other +* than INVALID_PENDING_RING_IDX is OK. In practice we use 0. +* +* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above +* example) number is the index into pending_tx_info and mmap_pages +* arrays. +*/ +struct pending_tx_info { +struct xen_netif_tx_request req;/* coalesced tx request */ +pending_ring_idx_t head;/* head != INVALID_PENDING_RING_IDX +* if it is head of one or more tx +* reqs +*/ +}; + +#define XEN_NETIF_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE) +#define XEN_NETIF_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE) + +struct xenvif_rx_meta { +int id; +int size; +int gso_size; +}; + +/* Discriminate from any valid pending_idx value. */ +#define INVALID_PENDING_IDX 0xFFFF + +#define MAX_BUFFER_OFFSET PAGE_SIZE + +#define MAX_PENDING_REQS 256struct xenvif {/* Unique identifier for this interface. */ domid_t domid;unsigned int handle; -/* Reference to netback processing backend. */ -struct xen_netbk *netbk; +/* Use NAPI for guest TX */ +struct napi_struct napi; +/* When feature-split-event-channels = 0, tx_irq = rx_irq. */ +unsigned int tx_irq; +/* Only used when feature-split-event-channels = 1 */ +char tx_irq_name[IFNAMSIZ +4 ];/* DEVNAME-tx */ +struct xen_netif_tx_back_ring tx; +struct sk_buff_head tx_queue; +struct page *mmap_pages[MAX_PENDING_REQS ]; +pending_ring_idx_t pending_prod; +pending_ring_idx_t pending_cons; +u16 pending_ring[MAX_PENDING_REQS ]; +struct pending_tx_info pending_tx_info[MAX_PENDING_REQS ]; + +/* Coalescing tx requests before copying makes number of grant +* copy ops greater or equal to number of slots required. In +* worst case a tx request consumes 2 gnttab_copy. +*/ +struct gnttab_copy tx_copy_ops[2 *MAX_PENDING_REQS ]; -u8 fe_dev_addr[6 ]; +/* Use kthread for guest RX */ +struct task_struct *task; +wait_queue_head_t wq;/* When feature-split-event-channels = 0, tx_irq = rx_irq. */ -unsigned int tx_irq;unsigned int rx_irq;/* Only used when feature-split-event-channels = 1 */ -char tx_irq_name[IFNAMSIZ +4 ];/* DEVNAME-tx */ char rx_irq_name[IFNAMSIZ +4 ];/* DEVNAME-rx */ +struct xen_netif_rx_back_ring rx; +struct sk_buff_head rx_queue; -/* List of frontends to notify after a batch of frames sent. */ -struct list_head notify_list; +/* Allow xenvif_start_xmit() to peek ahead in the rx request +* ring. This is a prediction of what rx_req_cons will be +* once all queued skbs are put on the ring. +*/ +RING_IDX rx_req_cons_peek; + +/* Given MAX_BUFFER_OFFSET of 4096 the worst case is that each +* head/fragment page uses 2 copy operations because it +* straddles two buffers in the frontend. +*/ +struct gnttab_copy grant_copy_op[2 *XEN_NETIF_RX_RING_SIZE ]; +struct xenvif_rx_meta meta[2 *XEN_NETIF_RX_RING_SIZE ]; -/* The shared rings and indexes. */ -struct xen_netif_tx_back_ring tx; -struct xen_netif_rx_back_ring rx; + +u8 fe_dev_addr[6 ];/* Frontend feature information. */ u8 can_sg:1 ;
@@ -80,13 +154,6 @@ struct xenvif {/* Internal feature information. */ u8 can_queue:1; /* can queue packets for receiver? */ -/* -* Allow xenvif_start_xmit() to peek ahead in the rx request -* ring. This is a prediction of what rx_req_cons will be -* once all queued skbs are put on the ring. -*/ -RING_IDX rx_req_cons_peek; -/* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */ unsigned long credit_bytes;unsigned long credit_usec;
@@ -97,11 +164,7 @@ struct xenvif {unsigned long rx_gso_checksum_fixup;/* Miscellaneous private stuff. */ -struct list_head schedule_list; -atomic_t refcnt;struct net_device *dev; - -wait_queue_head_t waiting_to_free; };static inline struct xenbus_device *xenvif_to_xenbus_device (struct xenvif *vif)
@@ -109,9 +172,6 @@ static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif)return to_xenbus_device (vif->dev->dev.parent); } -#define XEN_NETIF_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE) -#define XEN_NETIF_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE) -struct xenvif *xenvif_alloc (struct device *parent,domid_t domid,unsigned int handle);
@@ -121,9 +181,6 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref, unsigned int rx_evtchn);void xenvif_disconnect (struct xenvif *vif); -void xenvif_get (struct xenvif *vif); -void xenvif_put (struct xenvif *vif); -int xenvif_xenbus_init (void );void xenvif_xenbus_fini (void );
@@ -139,18 +196,8 @@ int xen_netbk_map_frontend_rings(struct xenvif *vif,grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref); -/* (De)Register a xenvif with the netback backend. */ -void xen_netbk_add_xenvif (struct xenvif *vif); -void xen_netbk_remove_xenvif (struct xenvif *vif); - -/* (De)Schedule backend processing for a xenvif */ -void xen_netbk_schedule_xenvif (struct xenvif *vif); -void xen_netbk_deschedule_xenvif (struct xenvif *vif); -/* Check for SKBs from frontend and schedule backend processing */ void xen_netbk_check_rx_xenvif (struct xenvif *vif); -/* Receive an SKB from the frontend */ -void xenvif_receive_skb (struct xenvif *vif,struct sk_buff *skb);/* Queue an SKB for transmission to the frontend */ void xen_netbk_queue_tx_skb (struct xenvif *vif,struct sk_buff *skb);
@@ -163,6 +210,11 @@ void xenvif_carrier_off(struct xenvif *vif);/* Returns number of ring slots required to send an skb to the frontend */ unsigned int xen_netbk_count_skb_slots (struct xenvif *vif,struct sk_buff *skb); +int xen_netbk_tx_action (struct xenvif *vif,int budget); +void xen_netbk_rx_action (struct xenvif *vif); + +int xen_netbk_kthread (void *data); +extern bool separate_tx_rx_irq;#endif /* __XEN_NETBACK__COMMON_H__ */
drivers/net/xen-netback/interface.c +80 -39
241 lines not on this page · raw message
drivers/net/xen-netback/netback.c +177 -430
1,105 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 47 lines · Wei Liu
I sent this patch right before Ian requested more comments in code. Now I've updated this one. Not going to resend the whole series as this is only changes in comments.
Sorry for my bad English, I don't know whether I've made them clear enough. Suggestions are welcomed.
Wei.
---8<---
Frombb33027fe4bafeea546352cd3e409466f8bd7aa4Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Tue, 6 Aug 2013 06:59:15 +0100
Subject: [PATCH] xen-netback: switch to NAPI + kthread 1:1 modelThis patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)Xenvif and
xen_netbkare made into one structure to reduce code size.This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
Signed-off-by Wei Liu <[email protected]>--- drivers/net/xen-netback/common.h | 128 +++++--- drivers/net/xen-netback/interface.c | 119 ++++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 347 insertions(+), 507 deletions(-)drivers/net/xen-netback/common.h +4
-1@@ -45,31 +45,105 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +/* For the head field in pending_tx_info: It is used to indicate
drivers/net/xen-netback/common.h line 61
Quoted 10 lines
drivers/net/xen-netback/common.h +10
-0+* whether this tx info is the head of one or more coalesced requests. +* +* When head != INVALID_PENDING_RING_IDX, it means the start of a new +* tx requests queue and the end of previous queue. +* +* An example sequence of head fields (I = INVALID_PENDING_RING_IDX): +* +* ... 0 I I I 5 I 9 I I I ... +* +* After consming the first packet we have:
"consuming"
The first packet here is "0 I I I"? Consisting of the head (0) and 3 extra data slots (the 3xI)?
drivers/net/xen-netback/common.h line 66
Quoted 5 lines
drivers/net/xen-netback/common.h +5
-0+* +* ... V V V V 5 I 9 I I I ... +* +* where V stands for "valid pending ring index", any number other +* than INVALID_PENDING_RING_IDX is OK. In practice we use 0.
OK, this is where I get confused, because 0 is also valid in a different state, this one:
drivers/net/xen-netback/common.h line 70
Quoted 3 lines
drivers/net/xen-netback/common.h +3
-0+* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above +* example) number is the index into pending_tx_info and mmap_pages +* arrays.
So what does V mean and how to you distinguish this from a non-INVALID_PENDING_RING_IDX which happens to correspond to the 0 you use in practice for V?
I'm also not sure how 0 is considered a "valid pending ring index". I suppose it is not INVALID_PENDING_RING_IDX but it appears that it doesn't have any actual meaning? So it's just an arbitrary valid but meaningless number perhaps?
Ian.
Quoted 7 lines · David Vrabel
Quoted 6 lines · Pasi Kärkkäinen
Quoted 4 lines · Wei Liu
IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
Quoted 7 lines
Quoted 1 line
Hmm.. so with these patches applied is is *required* to do manual configuration in dom0 to get good performance?
This should be irqbalanced's job. The existing version doesn't do a good enough job yet though. Andrew Bennieston may have more details.
David
irqbalance 1.0.6 [1] includes a patch [2] from Wei Liu [3] that adds support for balancing `xen-dyn-event' interrupts. When I have compiled this version and run it under Xen(Server) I noticed that the interrupts are indeed moving between cores, but not necessarily in what I would call an obvious or optimal way (e.g. several VIF interrupts are being grouped onto a single dom0 VCPU at times). I plan on investigating this further when time permits.
I also noticed that, from time to time, the irqbalance process disappears. I tracked this down to a segfault that occurs when a VM shuts down and an IRQ disappears during one of irqbalance's periodic rescans. I'm hoping to be able to narrow this down sufficiently to identify the cause and ideally fix it, but I don't have a lot of time to work on this at the moment.
As for the impact on Wei's patches, without irqbalance it would be trivial to automatically assign (via a script, on VM start) the interrupts for a particular VIF to a particular dom0 vCPU in a round-robin fashion, just as VIFs were previously assigned to netback kthreads. This would result in broadly the same performance as before, while an improved irqbalanced should give better performance and fairness when two different VIFs would otherwise be competing for the same resources.
Andrew.
[1] https://code.google.com/p/irqbalance/downloads
[2] https://code.google.com/p/irqbalance/source/detail?r=736a91b739018530c44e59d9b17252f88227fe51
[3] https://code.google.com/p/irqbalance/issues/detail?id=46
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 52 lines · Ian Campbell
Quoted 51 lines · Wei Liu
I sent this patch right before Ian requested more comments in code. Now I've updated this one. Not going to resend the whole series as this is only changes in comments.
Sorry for my bad English, I don't know whether I've made them clear enough. Suggestions are welcomed.
Wei.
---8<---
Frombb33027fe4bafeea546352cd3e409466f8bd7aa4Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Tue, 6 Aug 2013 06:59:15 +0100
Subject: [PATCH] xen-netback: switch to NAPI + kthread 1:1 modelThis patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)Xenvif and
xen_netbkare made into one structure to reduce code size.This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
Signed-off-by Wei Liu <[email protected]>--- drivers/net/xen-netback/common.h | 128 +++++--- drivers/net/xen-netback/interface.c | 119 ++++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 347 insertions(+), 507 deletions(-)drivers/net/xen-netback/common.h +8
-1@@ -45,31 +45,105 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +/* For the head field in pending_tx_info: It is used to indicate +* whether this tx info is the head of one or more coalesced requests. +* +* When head != INVALID_PENDING_RING_IDX, it means the start of a new +* tx requests queue and the end of previous queue.
Quoted 9 lines
drivers/net/xen-netback/common.h line 61
Quoted 6 lines
drivers/net/xen-netback/common.h +6
-0+* +* An example sequence of head fields (I = INVALID_PENDING_RING_IDX): +* +* ... 0 I I I 5 I 9 I I I ... +* +* After consming the first packet we have: "consuming"
Oops...
Quoted 3 lines
The first packet here is "0 I I I"? Consisting of the head (0) and 3 extra data slots (the 3xI)?
Yes. But the term "extra data slot" is not acurate. "0 I I I" means we've coalesced 3 more slots into the first slot. And the index of first slot into various arrays is 0.
Quoted 8 lines
drivers/net/xen-netback/common.h line 66
Quoted 5 lines
drivers/net/xen-netback/common.h +5
-0+* +* ... V V V V 5 I 9 I I I ... +* +* where V stands for "valid pending ring index", any number other +* than INVALID_PENDING_RING_IDX is OK. In practice we use 0. OK, this is where I get confused, because 0 is also valid in a different state, this one:
Quoted 8 lines
drivers/net/xen-netback/common.h line 70
Quoted 3 lines
drivers/net/xen-netback/common.h +3
-0+* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above +* example) number is the index into pending_tx_info and mmap_pages +* arrays. So what does V mean and how to you distinguish this from a non-INVALID_PENDING_RING_IDX which happens to correspond to the 0 you use in practice for V?
Oh, V is just another way of saying non-INVALID_PENDING_RING_IDX. :-/
The head field is always manipulated when coalescing slots and releasing slots. So if the routine sees 0 when processing a slot is actually means index 0.
Quoted 5 lines
I'm also not sure how 0 is considered a "valid pending ring index". I suppose it is not
INVALID_PENDING_RING_IDXbut it appears that it doesn't have any actual meaning? So it's just an arbitrary valid but meaningless number perhaps?
Yes. 0 is as good as any number other than INVALID_PENDING_RING_IDX.
Wei.
Quoted 1 line
Ian.
Quoted 65 lines · Wei Liu
Quoted 52 lines · Ian Campbell
Quoted 51 lines · Wei Liu
I sent this patch right before Ian requested more comments in code. Now I've updated this one. Not going to resend the whole series as this is only changes in comments.
Sorry for my bad English, I don't know whether I've made them clear enough. Suggestions are welcomed.
Wei.
---8<---
Frombb33027fe4bafeea546352cd3e409466f8bd7aa4Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Tue, 6 Aug 2013 06:59:15 +0100
Subject: [PATCH] xen-netback: switch to NAPI + kthread 1:1 modelThis patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)Xenvif and
xen_netbkare made into one structure to reduce code size.This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
Signed-off-by Wei Liu <[email protected]>--- drivers/net/xen-netback/common.h | 128 +++++--- drivers/net/xen-netback/interface.c | 119 ++++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 347 insertions(+), 507 deletions(-)drivers/net/xen-netback/common.h +8
-1@@ -45,31 +45,105 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +/* For the head field in pending_tx_info: It is used to indicate +* whether this tx info is the head of one or more coalesced requests. +* +* When head != INVALID_PENDING_RING_IDX, it means the start of a new +* tx requests queue and the end of previous queue. Quoted 9 lines
drivers/net/xen-netback/common.h line 61
Quoted 6 lines
drivers/net/xen-netback/common.h +6
-0+* +* An example sequence of head fields (I = INVALID_PENDING_RING_IDX): +* +* ... 0 I I I 5 I 9 I I I ... +* +* After consming the first packet we have: "consuming"
Oops...
Quoted 7 lines
Quoted 3 lines
The first packet here is "0 I I I"? Consisting of the head (0) and 3 extra data slots (the 3xI)?
Yes. But the term "extra data slot" is not acurate. "0 I I I" means we've coalesced 3 more slots into the first slot. And the index of first slot into various arrays is 0.
Got it, I think.
Quoted 18 lines
Quoted 9 lines
drivers/net/xen-netback/common.h line 66
Quoted 6 lines
drivers/net/xen-netback/common.h +5
-0+* +* ... V V V V 5 I 9 I I I ... +* +* where V stands for "valid pending ring index", any number other +* than INVALID_PENDING_RING_IDX is OK. In practice we use 0. OK, this is where I get confused, because 0 is also valid in a different state, this one:
Quoted 8 lines
drivers/net/xen-netback/common.h line 70
Quoted 3 lines
drivers/net/xen-netback/common.h +3
-0+* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above +* example) number is the index into pending_tx_info and mmap_pages +* arrays. So what does V mean and how to you distinguish this from a non-INVALID_PENDING_RING_IDX which happens to correspond to the 0 you use in practice for V?
Quoted 5 lines
Oh, V is just another way of saying non-INVALID_PENDING_RING_IDX. :-/
The head field is always manipulated when coalescing slots and releasing slots. So if the routine sees 0 when processing a slot is actually means index 0.
But you say "In practice we use 0", but you could use any arbitrary integer which is != INVALID_PENDING_RING_IDX?
Quoted 7 lines
Quoted 5 lines
I'm also not sure how 0 is considered a "valid pending ring index". I suppose it is not
INVALID_PENDING_RING_IDXbut it appears that it doesn't have any actual meaning? So it's just an arbitrary valid but meaningless number perhaps?Yes. 0 is as good as any number other than
INVALID_PENDING_RING_IDX.
So I still have this confusion between a 'V' entry and an entry which contains an actual index into various arrays. How are they different?
AIUI each entry can be one of three types:
a) Contains INVALID_PENDING_RING_IDX (is a coalesced into a previous head)
b) Contains an index into various arrays (an integer)
c) Contains 'V', a "valid pending ring index", usually 0.
So how are b) and c) distinguished? I think b) is the head, so what is c)?
Quoted 94 lines · Ian Campbell
Quoted 65 lines · Wei Liu
Quoted 52 lines · Ian Campbell
Quoted 51 lines · Wei Liu
I sent this patch right before Ian requested more comments in code. Now I've updated this one. Not going to resend the whole series as this is only changes in comments.
Sorry for my bad English, I don't know whether I've made them clear enough. Suggestions are welcomed.
Wei.
---8<---
Frombb33027fe4bafeea546352cd3e409466f8bd7aa4Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Tue, 6 Aug 2013 06:59:15 +0100
Subject: [PATCH] xen-netback: switch to NAPI + kthread 1:1 modelThis patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)Xenvif and
xen_netbkare made into one structure to reduce code size.This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
Signed-off-by Wei Liu <[email protected]>--- drivers/net/xen-netback/common.h | 128 +++++--- drivers/net/xen-netback/interface.c | 119 ++++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 347 insertions(+), 507 deletions(-)drivers/net/xen-netback/common.h +8
-1@@ -45,31 +45,105 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +/* For the head field in pending_tx_info: It is used to indicate +* whether this tx info is the head of one or more coalesced requests. +* +* When head != INVALID_PENDING_RING_IDX, it means the start of a new +* tx requests queue and the end of previous queue. Quoted 9 lines
drivers/net/xen-netback/common.h line 61
Quoted 6 lines
drivers/net/xen-netback/common.h +6
-0+* +* An example sequence of head fields (I = INVALID_PENDING_RING_IDX): +* +* ... 0 I I I 5 I 9 I I I ... +* +* After consming the first packet we have: "consuming"
Oops...
Quoted 7 lines
Quoted 3 lines
The first packet here is "0 I I I"? Consisting of the head (0) and 3 extra data slots (the 3xI)?
Yes. But the term "extra data slot" is not acurate. "0 I I I" means we've coalesced 3 more slots into the first slot. And the index of first slot into various arrays is 0.
Got it, I think.
Quoted 18 lines
Quoted 17 lines
drivers/net/xen-netback/common.h line 66
Quoted 6 lines
drivers/net/xen-netback/common.h +5
-0+* +* ... V V V V 5 I 9 I I I ... +* +* where V stands for "valid pending ring index", any number other +* than INVALID_PENDING_RING_IDX is OK. In practice we use 0. OK, this is where I get confused, because 0 is also valid in a different state, this one:
drivers/net/xen-netback/common.h line 70
Quoted 3 lines
drivers/net/xen-netback/common.h +3
-0+* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above +* example) number is the index into pending_tx_info and mmap_pages +* arrays. So what does V mean and how to you distinguish this from a non-INVALID_PENDING_RING_IDX which happens to correspond to the 0 you use in practice for V?
Quoted 9 lines
Quoted 5 lines
Oh, V is just another way of saying non-INVALID_PENDING_RING_IDX. :-/
The head field is always manipulated when coalescing slots and releasing slots. So if the routine sees 0 when processing a slot is actually means index 0.
But you say "In practice we use 0", but you could use any arbitrary integer which is !=
INVALID_PENDING_RING_IDX?
Yes. This is only useful when releasing slots. When the routine sees a number not equal to INVALID_PENDING_RING_IDX it knows the previous sequence has ended. So setting head to 0 is as good as any.
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
I'm also not sure how 0 is considered a "valid pending ring index". I suppose it is not
INVALID_PENDING_RING_IDXbut it appears that it doesn't have any actual meaning? So it's just an arbitrary valid but meaningless number perhaps?Yes. 0 is as good as any number other than
INVALID_PENDING_RING_IDX.So I still have this confusion between a 'V' entry and an entry which contains an actual index into various arrays. How are they different?
Quoted 8 lines
AIUI each entry can be one of three types:
a) Contains
INVALID_PENDING_RING_IDX(is a coalesced into a previous head)
b) Contains an index into various arrays (an integer)
c) Contains 'V', a "valid pending ring index", usually 0.So how are b) and c) distinguished? I think b) is the head, so what is c)?
c) state can only be reached *after* releasing a slot. When the slot is reused into b) state (after coalescing), the head field is then set to the actual number of the index. b) and c) are mutual exclusive.
Wei.
Quoted 126 lines · Wei Liu
Quoted 94 lines · Ian Campbell
Quoted 65 lines · Wei Liu
Quoted 52 lines · Ian Campbell
Quoted 51 lines · Wei Liu
I sent this patch right before Ian requested more comments in code. Now I've updated this one. Not going to resend the whole series as this is only changes in comments.
Sorry for my bad English, I don't know whether I've made them clear enough. Suggestions are welcomed.
Wei.
---8<---
Frombb33027fe4bafeea546352cd3e409466f8bd7aa4Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Tue, 6 Aug 2013 06:59:15 +0100
Subject: [PATCH] xen-netback: switch to NAPI + kthread 1:1 modelThis patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)Xenvif and
xen_netbkare made into one structure to reduce code size.This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
Signed-off-by Wei Liu <[email protected]>--- drivers/net/xen-netback/common.h | 128 +++++--- drivers/net/xen-netback/interface.c | 119 ++++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 347 insertions(+), 507 deletions(-)drivers/net/xen-netback/common.h +8
-1@@ -45,31 +45,105 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +/* For the head field in pending_tx_info: It is used to indicate +* whether this tx info is the head of one or more coalesced requests. +* +* When head != INVALID_PENDING_RING_IDX, it means the start of a new +* tx requests queue and the end of previous queue. Quoted 9 lines
drivers/net/xen-netback/common.h line 61
Quoted 6 lines
drivers/net/xen-netback/common.h +6
-0+* +* An example sequence of head fields (I = INVALID_PENDING_RING_IDX): +* +* ... 0 I I I 5 I 9 I I I ... +* +* After consming the first packet we have: "consuming"
Oops...
Quoted 7 lines
Quoted 3 lines
The first packet here is "0 I I I"? Consisting of the head (0) and 3 extra data slots (the 3xI)?
Yes. But the term "extra data slot" is not acurate. "0 I I I" means we've coalesced 3 more slots into the first slot. And the index of first slot into various arrays is 0.
Got it, I think.
Quoted 18 lines
Quoted 17 lines
drivers/net/xen-netback/common.h line 66
Quoted 6 lines
drivers/net/xen-netback/common.h +5
-0+* +* ... V V V V 5 I 9 I I I ... +* +* where V stands for "valid pending ring index", any number other +* than INVALID_PENDING_RING_IDX is OK. In practice we use 0. OK, this is where I get confused, because 0 is also valid in a different state, this one:
drivers/net/xen-netback/common.h line 70
Quoted 3 lines
drivers/net/xen-netback/common.h +3
-0+* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above +* example) number is the index into pending_tx_info and mmap_pages +* arrays. So what does V mean and how to you distinguish this from a non-INVALID_PENDING_RING_IDX which happens to correspond to the 0 you use in practice for V?
Quoted 9 lines
Quoted 5 lines
Oh, V is just another way of saying non-INVALID_PENDING_RING_IDX. :-/
The head field is always manipulated when coalescing slots and releasing slots. So if the routine sees 0 when processing a slot is actually means index 0.
But you say "In practice we use 0", but you could use any arbitrary integer which is !=
INVALID_PENDING_RING_IDX?Yes. This is only useful when releasing slots. When the routine sees a number not equal to
INVALID_PENDING_RING_IDXit knows the previous sequence has ended. So setting head to 0 is as good as any.Quoted 17 lines
Quoted 7 lines
Quoted 5 lines
I'm also not sure how 0 is considered a "valid pending ring index". I suppose it is not
INVALID_PENDING_RING_IDXbut it appears that it doesn't have any actual meaning? So it's just an arbitrary valid but meaningless number perhaps?Yes. 0 is as good as any number other than
INVALID_PENDING_RING_IDX.So I still have this confusion between a 'V' entry and an entry which contains an actual index into various arrays. How are they different?
AIUI each entry can be one of three types:
a) Contains
INVALID_PENDING_RING_IDX(is a coalesced into a previous head)
b) Contains an index into various arrays (an integer)
c) Contains 'V', a "valid pending ring index", usually 0.
Quoted 6 lines
Quoted 2 lines
So how are b) and c) distinguished? I think b) is the head, so what is c)?
c) state can only be reached *after* releasing a slot. When the slot is reused into b) state (after coalescing), the head field is then set to the actual number of the index. b) and c) are mutual exclusive.
Ah, so these 'V' entries are free entries, I think I've got it now.
So:
...|0 I I I|5 I|9 I I I|...
-->|<-INUSE----------------
Then you consume "0 I I I" and get:
...|V V V V|5 I|9 I I I|...
-----FREE->|<-INUSE--------
Ian.
Quoted 136 lines · Ian Campbell
Quoted 126 lines · Wei Liu
Quoted 94 lines · Ian Campbell
Quoted 65 lines · Wei Liu
Quoted 52 lines · Ian Campbell
Quoted 51 lines · Wei Liu
I sent this patch right before Ian requested more comments in code. Now I've updated this one. Not going to resend the whole series as this is only changes in comments.
Sorry for my bad English, I don't know whether I've made them clear enough. Suggestions are welcomed.
Wei.
---8<---
Frombb33027fe4bafeea546352cd3e409466f8bd7aa4Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Tue, 6 Aug 2013 06:59:15 +0100
Subject: [PATCH] xen-netback: switch to NAPI + kthread 1:1 modelThis patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)Xenvif and
xen_netbkare made into one structure to reduce code size.This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
Signed-off-by Wei Liu <[email protected]>--- drivers/net/xen-netback/common.h | 128 +++++--- drivers/net/xen-netback/interface.c | 119 ++++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 347 insertions(+), 507 deletions(-)drivers/net/xen-netback/common.h +8
-1@@ -45,31 +45,105 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +/* For the head field in pending_tx_info: It is used to indicate +* whether this tx info is the head of one or more coalesced requests. +* +* When head != INVALID_PENDING_RING_IDX, it means the start of a new +* tx requests queue and the end of previous queue. Quoted 9 lines
drivers/net/xen-netback/common.h line 61
Quoted 6 lines
drivers/net/xen-netback/common.h +6
-0+* +* An example sequence of head fields (I = INVALID_PENDING_RING_IDX): +* +* ... 0 I I I 5 I 9 I I I ... +* +* After consming the first packet we have: "consuming"
Oops...
Quoted 7 lines
Quoted 3 lines
The first packet here is "0 I I I"? Consisting of the head (0) and 3 extra data slots (the 3xI)?
Yes. But the term "extra data slot" is not acurate. "0 I I I" means we've coalesced 3 more slots into the first slot. And the index of first slot into various arrays is 0.
Got it, I think.
Quoted 18 lines
Quoted 17 lines
drivers/net/xen-netback/common.h line 66
Quoted 6 lines
drivers/net/xen-netback/common.h +5
-0+* +* ... V V V V 5 I 9 I I I ... +* +* where V stands for "valid pending ring index", any number other +* than INVALID_PENDING_RING_IDX is OK. In practice we use 0. OK, this is where I get confused, because 0 is also valid in a different state, this one:
drivers/net/xen-netback/common.h line 70
Quoted 3 lines
drivers/net/xen-netback/common.h +3
-0+* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above +* example) number is the index into pending_tx_info and mmap_pages +* arrays. So what does V mean and how to you distinguish this from a non-INVALID_PENDING_RING_IDX which happens to correspond to the 0 you use in practice for V?
Quoted 9 lines
Quoted 5 lines
Oh, V is just another way of saying non-INVALID_PENDING_RING_IDX. :-/
The head field is always manipulated when coalescing slots and releasing slots. So if the routine sees 0 when processing a slot is actually means index 0.
But you say "In practice we use 0", but you could use any arbitrary integer which is !=
INVALID_PENDING_RING_IDX?Yes. This is only useful when releasing slots. When the routine sees a number not equal to
INVALID_PENDING_RING_IDXit knows the previous sequence has ended. So setting head to 0 is as good as any.Quoted 17 lines
Quoted 7 lines
Quoted 5 lines
I'm also not sure how 0 is considered a "valid pending ring index". I suppose it is not
INVALID_PENDING_RING_IDXbut it appears that it doesn't have any actual meaning? So it's just an arbitrary valid but meaningless number perhaps?Yes. 0 is as good as any number other than
INVALID_PENDING_RING_IDX.So I still have this confusion between a 'V' entry and an entry which contains an actual index into various arrays. How are they different?
AIUI each entry can be one of three types:
a) Contains
INVALID_PENDING_RING_IDX(is a coalesced into a previous head)
b) Contains an index into various arrays (an integer)
c) Contains 'V', a "valid pending ring index", usually 0.Quoted 6 lines
Quoted 2 lines
So how are b) and c) distinguished? I think b) is the head, so what is c)?
c) state can only be reached *after* releasing a slot. When the slot is reused into b) state (after coalescing), the head field is then set to the actual number of the index. b) and c) are mutual exclusive.
Ah, so these 'V' entries are free entries, I think I've got it now.
Quoted 9 lines
So:
...|0 I I I|5 I|9 I I I|...
-->|<-INUSE----------------Then you consume "0 I I I" and get:
...|V V V V|5 I|9 I I I|...
-----FREE->|<-INUSE--------
Right, this is it. :-)
I will use the above graph in the comment.
Wei.
Quoted 1 line
Ian.
Quoted 143 lines · Wei Liu
Quoted 142 lines · Ian Campbell
Quoted 126 lines · Wei Liu
Quoted 94 lines · Ian Campbell
Quoted 65 lines · Wei Liu
Quoted 52 lines · Ian Campbell
Quoted 51 lines · Wei Liu
I sent this patch right before Ian requested more comments in code. Now I've updated this one. Not going to resend the whole series as this is only changes in comments.
Sorry for my bad English, I don't know whether I've made them clear enough. Suggestions are welcomed.
Wei.
---8<---
Frombb33027fe4bafeea546352cd3e409466f8bd7aa4Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Tue, 6 Aug 2013 06:59:15 +0100
Subject: [PATCH] xen-netback: switch to NAPI + kthread 1:1 modelThis patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)Xenvif and
xen_netbkare made into one structure to reduce code size.This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
Signed-off-by Wei Liu <[email protected]>--- drivers/net/xen-netback/common.h | 128 +++++--- drivers/net/xen-netback/interface.c | 119 ++++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 347 insertions(+), 507 deletions(-)drivers/net/xen-netback/common.h +8
-1@@ -45,31 +45,105 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +/* For the head field in pending_tx_info: It is used to indicate +* whether this tx info is the head of one or more coalesced requests. +* +* When head != INVALID_PENDING_RING_IDX, it means the start of a new +* tx requests queue and the end of previous queue. Quoted 9 lines
drivers/net/xen-netback/common.h line 61
Quoted 6 lines
drivers/net/xen-netback/common.h +6
-0+* +* An example sequence of head fields (I = INVALID_PENDING_RING_IDX): +* +* ... 0 I I I 5 I 9 I I I ... +* +* After consming the first packet we have: "consuming"
Oops...
Quoted 7 lines
Quoted 3 lines
The first packet here is "0 I I I"? Consisting of the head (0) and 3 extra data slots (the 3xI)?
Yes. But the term "extra data slot" is not acurate. "0 I I I" means we've coalesced 3 more slots into the first slot. And the index of first slot into various arrays is 0.
Got it, I think.
Quoted 18 lines
Quoted 17 lines
drivers/net/xen-netback/common.h line 66
Quoted 6 lines
drivers/net/xen-netback/common.h +5
-0+* +* ... V V V V 5 I 9 I I I ... +* +* where V stands for "valid pending ring index", any number other +* than INVALID_PENDING_RING_IDX is OK. In practice we use 0. OK, this is where I get confused, because 0 is also valid in a different state, this one:
drivers/net/xen-netback/common.h line 69
Quoted 3 lines
drivers/net/xen-netback/common.h +3
-0+* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above +* example) number is the index into pending_tx_info and mmap_pages +* arrays. So what does V mean and how to you distinguish this from a non-INVALID_PENDING_RING_IDX which happens to correspond to the 0 you use in practice for V?
Quoted 9 lines
Quoted 5 lines
Oh, V is just another way of saying non-INVALID_PENDING_RING_IDX. :-/
The head field is always manipulated when coalescing slots and releasing slots. So if the routine sees 0 when processing a slot is actually means index 0.
But you say "In practice we use 0", but you could use any arbitrary integer which is !=
INVALID_PENDING_RING_IDX?Yes. This is only useful when releasing slots. When the routine sees a number not equal to
INVALID_PENDING_RING_IDXit knows the previous sequence has ended. So setting head to 0 is as good as any.Quoted 17 lines
Quoted 7 lines
Quoted 5 lines
I'm also not sure how 0 is considered a "valid pending ring index". I suppose it is not
INVALID_PENDING_RING_IDXbut it appears that it doesn't have any actual meaning? So it's just an arbitrary valid but meaningless number perhaps?Yes. 0 is as good as any number other than
INVALID_PENDING_RING_IDX.So I still have this confusion between a 'V' entry and an entry which contains an actual index into various arrays. How are they different?
AIUI each entry can be one of three types:
a) Contains
INVALID_PENDING_RING_IDX(is a coalesced into a previous head)
b) Contains an index into various arrays (an integer)
c) Contains 'V', a "valid pending ring index", usually 0.Quoted 6 lines
Quoted 2 lines
So how are b) and c) distinguished? I think b) is the head, so what is c)?
c) state can only be reached *after* releasing a slot. When the slot is reused into b) state (after coalescing), the head field is then set to the actual number of the index. b) and c) are mutual exclusive.
Ah, so these 'V' entries are free entries, I think I've got it now.
So:
...|0 I I I|5 I|9 I I I|...
-->|<-INUSE----------------Then you consume "0 I I I" and get:
Quoted 8 lines
Quoted 3 lines
...|V V V V|5 I|9 I I I|...
-----FREE->|<-INUSE--------Right, this is it. :-)
I will use the above graph in the comment.
/* For the head field in pending_tx_info: it is used to indicate
* whether this tx info is the head of one or more coalesced requests. *
* When head != INVALID_PENDING_RING_IDX, it means the start of a new
* tx requests queue and the end of previous queue.
*
* An example sequence of head fields (I = INVALID_PENDING_RING_IDX):
*
* ...|0 I I I|5 I|9 I I I|...
* -->|<-INUSE----------------
*
* After consuming the first slot(s) we have:
*
* ...|V V V V|5 I|9 I I I|...
* -----FREE->|<-INUSE--------
*
* where V stands for "valid pending ring index". Any number other
* than INVALID_PENDING_RING_IDX is OK. In practice we use 0. *
* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above
* example) number is the index into pending_tx_info and mmap_pages
* arrays.
*/
Quoted 4 lines
Wei.
Quoted 1 line
Ian.
Quoted 163 lines · Wei Liu
Quoted 143 lines · Wei Liu
Quoted 142 lines · Ian Campbell
Quoted 126 lines · Wei Liu
Quoted 94 lines · Ian Campbell
Quoted 65 lines · Wei Liu
Quoted 52 lines · Ian Campbell
Quoted 51 lines · Wei Liu
I sent this patch right before Ian requested more comments in code. Now I've updated this one. Not going to resend the whole series as this is only changes in comments.
Sorry for my bad English, I don't know whether I've made them clear enough. Suggestions are welcomed.
Wei.
---8<---
Frombb33027fe4bafeea546352cd3e409466f8bd7aa4Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Tue, 6 Aug 2013 06:59:15 +0100
Subject: [PATCH] xen-netback: switch to NAPI + kthread 1:1 modelThis patch implements 1:1 model netback. NAPI and kthread are utilized to do the weight-lifting job:
- NAPI is used for guest side TX (host side RX)
- kthread is used for guest side RX (host side TX)Xenvif and
xen_netbkare made into one structure to reduce code size.This model provides better scheduling fairness among vifs. It is also prerequisite for implementing multiqueue for Xen netback.
Signed-off-by Wei Liu <[email protected]>--- drivers/net/xen-netback/common.h | 128 +++++--- drivers/net/xen-netback/interface.c | 119 ++++--- drivers/net/xen-netback/netback.c | 607 ++++++++++------------------------- 3 files changed, 347 insertions(+), 507 deletions(-)drivers/net/xen-netback/common.h +8
-1@@ -45,31 +45,105 @@#include <xen/grant_table.h> #include <xen/xenbus.h> -struct xen_netbk ; +typedef unsigned int pending_ring_idx_t ; +#define INVALID_PENDING_RING_IDX (~0U) + +/* For the head field in pending_tx_info: It is used to indicate +* whether this tx info is the head of one or more coalesced requests. +* +* When head != INVALID_PENDING_RING_IDX, it means the start of a new +* tx requests queue and the end of previous queue. Quoted 9 lines
drivers/net/xen-netback/common.h line 61
Quoted 6 lines
drivers/net/xen-netback/common.h +6
-0+* +* An example sequence of head fields (I = INVALID_PENDING_RING_IDX): +* +* ... 0 I I I 5 I 9 I I I ... +* +* After consming the first packet we have: "consuming"
Oops...
Quoted 7 lines
Quoted 3 lines
The first packet here is "0 I I I"? Consisting of the head (0) and 3 extra data slots (the 3xI)?
Yes. But the term "extra data slot" is not acurate. "0 I I I" means we've coalesced 3 more slots into the first slot. And the index of first slot into various arrays is 0.
Got it, I think.
Quoted 18 lines
Quoted 17 lines
drivers/net/xen-netback/common.h line 66
Quoted 6 lines
drivers/net/xen-netback/common.h +5
-0+* +* ... V V V V 5 I 9 I I I ... +* +* where V stands for "valid pending ring index", any number other +* than INVALID_PENDING_RING_IDX is OK. In practice we use 0. OK, this is where I get confused, because 0 is also valid in a different state, this one:
drivers/net/xen-netback/common.h line 69
Quoted 3 lines
drivers/net/xen-netback/common.h +3
-0+* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above +* example) number is the index into pending_tx_info and mmap_pages +* arrays. So what does V mean and how to you distinguish this from a non-INVALID_PENDING_RING_IDX which happens to correspond to the 0 you use in practice for V?
Quoted 9 lines
Quoted 5 lines
Oh, V is just another way of saying non-INVALID_PENDING_RING_IDX. :-/
The head field is always manipulated when coalescing slots and releasing slots. So if the routine sees 0 when processing a slot is actually means index 0.
But you say "In practice we use 0", but you could use any arbitrary integer which is !=
INVALID_PENDING_RING_IDX?Yes. This is only useful when releasing slots. When the routine sees a number not equal to
INVALID_PENDING_RING_IDXit knows the previous sequence has ended. So setting head to 0 is as good as any.Quoted 17 lines
Quoted 7 lines
Quoted 5 lines
I'm also not sure how 0 is considered a "valid pending ring index". I suppose it is not
INVALID_PENDING_RING_IDXbut it appears that it doesn't have any actual meaning? So it's just an arbitrary valid but meaningless number perhaps?Yes. 0 is as good as any number other than
INVALID_PENDING_RING_IDX.So I still have this confusion between a 'V' entry and an entry which contains an actual index into various arrays. How are they different?
AIUI each entry can be one of three types:
a) Contains
INVALID_PENDING_RING_IDX(is a coalesced into a previous head)
b) Contains an index into various arrays (an integer)
c) Contains 'V', a "valid pending ring index", usually 0.Quoted 6 lines
Quoted 2 lines
So how are b) and c) distinguished? I think b) is the head, so what is c)?
c) state can only be reached *after* releasing a slot. When the slot is reused into b) state (after coalescing), the head field is then set to the actual number of the index. b) and c) are mutual exclusive.
Ah, so these 'V' entries are free entries, I think I've got it now.
So:
...|0 I I I|5 I|9 I I I|...
-->|<-INUSE----------------Then you consume "0 I I I" and get:
Quoted 8 lines
Quoted 3 lines
...|V V V V|5 I|9 I I I|...
-----FREE->|<-INUSE--------Right, this is it. :-)
I will use the above graph in the comment.
/* For the head field in
pending_tx_info: it is used to indicate
* whether this tx info is the head of one or more coalesced requests. *
* When head !=INVALID_PENDING_RING_IDX, it means the start of a new
* tx requests queue and the end of previous queue.
*
* An example sequence of head fields (I =INVALID_PENDING_RING_IDX):
*
* ...|0 I I I|5 I|9 I I I|...
* -->|<-INUSE----------------
Quoted 8 lines
*
* After consuming the first slot(s) we have:
*
* ...|V V V V|5 I|9 I I I|...
* -----FREE->|<-INUSE--------
*
* where V stands for "valid pending ring index". Any number other
* thanINVALID_PENDING_RING_IDXis OK. In practice we use 0.
Perhaps add "These entries are considered free and can contain any number other than INVALID_PENDING_RING_IDX" ?
Do you have a #define, like FREE_PENDING_RING_IDX for this value? Should mention it if so I think.
Quoted 2 lines
*
* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above
^ add "in use"?
Quoted 8 lines
* example) number is the index into
pending_tx_infoandmmap_pages
* arrays.
*/Quoted 4 lines
Wei.
Quoted 1 line
Ian.
On Tue, Aug 06, 2013 at 04:38:56PM +0100, Ian Campbell wrote:
[...]
Quoted 13 lines
Quoted 4 lines
* An example sequence of head fields (I =
INVALID_PENDING_RING_IDX):
*
* ...|0 I I I|5 I|9 I I I|...
* -->|<-INUSE----------------Quoted 8 lines
*
* After consuming the first slot(s) we have:
*
* ...|V V V V|5 I|9 I I I|...
* -----FREE->|<-INUSE--------
*
* where V stands for "valid pending ring index". Any number other
* thanINVALID_PENDING_RING_IDXis OK. In practice we use 0.
Quoted 6 lines
Perhaps add "These entries are considered free and can contain any number other than
INVALID_PENDING_RING_IDX" ?Do you have a #define, like
FREE_PENDING_RING_IDXfor this value? Should mention it if so I think.
Unfortunately no. This can be fixed later with separate patch? Or just have that change in this patch?
Wei.
Quoted 13 lines
Quoted 2 lines
*
* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above^ add "in use"?Quoted 8 lines
* example) number is the index into
pending_tx_infoandmmap_pages
* arrays.
*/Quoted 4 lines
Wei.
Quoted 1 line
Ian.
Quoted 18 lines · Wei Liu
On Tue, Aug 06, 2013 at 04:38:56PM +0100, Ian Campbell wrote:
[...]Quoted 16 lines
Quoted 4 lines
* An example sequence of head fields (I =
INVALID_PENDING_RING_IDX):
*
* ...|0 I I I|5 I|9 I I I|...
* -->|<-INUSE----------------Quoted 8 lines
*
* After consuming the first slot(s) we have:
*
* ...|V V V V|5 I|9 I I I|...
* -----FREE->|<-INUSE--------
*
* where V stands for "valid pending ring index". Any number other
* thanINVALID_PENDING_RING_IDXis OK. In practice we use 0.Perhaps add "These entries are considered free and can contain any number other than
INVALID_PENDING_RING_IDX" ?
Quoted 6 lines
Quoted 3 lines
Do you have a #define, like
FREE_PENDING_RING_IDXfor this value? Should mention it if so I think.Unfortunately no. This can be fixed later with separate patch? Or just have that change in this patch?
Separate I think, this patch is already pretty unwieldy.
Quoted 17 lines
Wei.
Quoted 13 lines
Quoted 2 lines
*
* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above^ add "in use"?Quoted 8 lines
* example) number is the index into
pending_tx_infoandmmap_pages
* arrays.
*/Quoted 4 lines
Wei.
Quoted 1 line
Ian.
Quoted 19 lines · Ian Campbell
Quoted 18 lines · Wei Liu
On Tue, Aug 06, 2013 at 04:38:56PM +0100, Ian Campbell wrote:
[...]Quoted 16 lines
Quoted 4 lines
* An example sequence of head fields (I =
INVALID_PENDING_RING_IDX):
*
* ...|0 I I I|5 I|9 I I I|...
* -->|<-INUSE----------------Quoted 8 lines
*
* After consuming the first slot(s) we have:
*
* ...|V V V V|5 I|9 I I I|...
* -----FREE->|<-INUSE--------
*
* where V stands for "valid pending ring index". Any number other
* thanINVALID_PENDING_RING_IDXis OK. In practice we use 0.Perhaps add "These entries are considered free and can contain any number other than
INVALID_PENDING_RING_IDX" ?
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Do you have a #define, like
FREE_PENDING_RING_IDXfor this value? Should mention it if so I think.Unfortunately no. This can be fixed later with separate patch? Or just have that change in this patch?
Separate I think, this patch is already pretty unwieldy.
So the comment for now:
/* For the head field in pending_tx_info: it is used to indicate
* whether this tx info is the head of one or more coalesced requests. *
* When head != INVALID_PENDING_RING_IDX, it means the start of a new
* tx requests queue and the end of previous queue.
*
* An example sequence of head fields (I = INVALID_PENDING_RING_IDX):
*
* ...|0 I I I|5 I|9 I I I|...
* -->|<-INUSE----------------
*
* After consuming the first slot(s) we have:
*
* ...|V V V V|5 I|9 I I I|...
* -----FREE->|<-INUSE--------
*
* where V stands for "valid pending ring index". Any number other
* than INVALID_PENDING_RING_IDX is OK. These entries are considered
* free and can contain any number other than
* INVALID_PENDING_RING_IDX. In practice we use 0.
*
* The in use non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the
* above example) number is the index into pending_tx_info and
* mmap_pages arrays.
*/
The FREE_PENDING_RING_IDX will be added with later patch.
Wei.
Quoted 18 lines
Quoted 17 lines
Wei.
Quoted 13 lines
Quoted 2 lines
*
* The non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the above^ add "in use"?Quoted 8 lines
* example) number is the index into
pending_tx_infoandmmap_pages
* arrays.
*/Quoted 4 lines
Wei.
Quoted 1 line
Ian.
Quoted 49 lines · Wei Liu
Quoted 19 lines · Ian Campbell
Quoted 18 lines · Wei Liu
On Tue, Aug 06, 2013 at 04:38:56PM +0100, Ian Campbell wrote:
[...]Quoted 16 lines
Quoted 4 lines
* An example sequence of head fields (I =
INVALID_PENDING_RING_IDX):
*
* ...|0 I I I|5 I|9 I I I|...
* -->|<-INUSE----------------Quoted 8 lines
*
* After consuming the first slot(s) we have:
*
* ...|V V V V|5 I|9 I I I|...
* -----FREE->|<-INUSE--------
*
* where V stands for "valid pending ring index". Any number other
* thanINVALID_PENDING_RING_IDXis OK. In practice we use 0.Perhaps add "These entries are considered free and can contain any number other than
INVALID_PENDING_RING_IDX" ?Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Do you have a #define, like
FREE_PENDING_RING_IDXfor this value? Should mention it if so I think.Unfortunately no. This can be fixed later with separate patch? Or just have that change in this patch?
Separate I think, this patch is already pretty unwieldy.
So the comment for now:
/* For the head field in
pending_tx_info: it is used to indicate
* whether this tx info is the head of one or more coalesced requests. *
* When head !=INVALID_PENDING_RING_IDX, it means the start of a new
* tx requests queue and the end of previous queue.
*
* An example sequence of head fields (I =INVALID_PENDING_RING_IDX):
*
* ...|0 I I I|5 I|9 I I I|...
* -->|<-INUSE----------------
*
* After consuming the first slot(s) we have:
*
* ...|V V V V|5 I|9 I I I|...
* -----FREE->|<-INUSE--------
*
* where V stands for "valid pending ring index". Any number other
Quoted 8 lines
* than
INVALID_PENDING_RING_IDXis OK. These entries are considered
* free and can contain any number other than
*INVALID_PENDING_RING_IDX. In practice we use 0.
*
* The in use non-INVALID_PENDING_RING_IDX (say 0, 5 and 9 in the
* above example) number is the index intopending_tx_infoand
*mmap_pagesarrays.
*/
Looks good.
Quoted 1 line
The
FREE_PENDING_RING_IDXwill be added with later patch.
thanks
Ian.
Re: [PATCH V4 1/3] xen-netback: remove page tracking facility
In reply to Wei LiuQuoted 15 lines · Wei Liu
The data flow from DomU to DomU on the same host in current copying scheme with tracking facility:
copy
DomU --------> Dom0 DomU| ^ |____________________________|copy
The page in Dom0 is a page with valid MFN. So we can always copy from page Dom0, thus removing the need for a tracking facility.
copy copy
DomU --------> Dom0 -------> DomU
Quoted 8 lines
Simple iperf test shows no performance regression (obviously we copy twice either way):
W/ tracking: ~5.3Gb/s
W/o tracking: ~5.4Gb/sSigned-off-by Wei Liu <[email protected]>Acked-by Ian Campbell <[email protected]>
Quoted 3 lines
--- drivers/net/xen-netback/netback.c | 77 +------------------------------------ 1 file changed, 2 insertions(+), 75 deletions(-)
[...]
--msw
Any more comments?
Wei.
Quoted 58 lines · Wei Liu
This series implements NAPI + kthread 1:1 model for Xen netback.
This model
- provides better scheduling fairness among vifs
- is prerequisite for implementing multiqueue for Xen network driverThe first two patches are ground work for the third patch. First one simplifies code in netback, second one can reduce memory footprint if we switch to 1:1 model.
The third patch has the real meat:
- make use of NAPI to mitigate interrupt
- kthreads are not bound to CPUs any more, so that we can take advantage of backend scheduler and trust it to do the right thingBenchmark done on a Dell T3400 workstation with 4 cores, running 4 DomUs. Netserver running in Dom0. DomUs do netperf to Dom0 with following command:
/root/netperf-H Dom0 -fm -l120IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
* New model
%Cpu0 : 0.5 us, 20.3 sy, 0.0 ni, 28.9 id, 0.0 wa, 0.0 hi, 24.4 si, 25.9 st %Cpu1 : 0.5 us, 17.8 sy, 0.0 ni, 28.8 id, 0.0 wa, 0.0 hi, 27.7 si, 25.1 st %Cpu2 : 0.5 us, 18.8 sy, 0.0 ni, 30.7 id, 0.0 wa, 0.0 hi, 22.9 si, 27.1 st %Cpu3 : 0.0 us, 20.1 sy, 0.0 ni, 30.4 id, 0.0 wa, 0.0 hi, 22.7 si, 26.8 stThroughputs: 2027.89 2025.95 2018.57 2016.23 aggregated: 8088.64
* Old model
%Cpu0 : 0.5 us, 68.8 sy, 0.0 ni, 16.1 id, 0.5 wa, 0.0 hi, 2.8 si, 11.5 st %Cpu1 : 0.4 us, 45.1 sy, 0.0 ni, 31.1 id, 0.4 wa, 0.0 hi, 2.1 si, 20.9 st %Cpu2 : 0.9 us, 44.8 sy, 0.0 ni, 30.9 id, 0.0 wa, 0.0 hi, 1.3 si, 22.2 st %Cpu3 : 0.8 us, 46.4 sy, 0.0 ni, 28.3 id, 1.3 wa, 0.0 hi, 2.1 si, 21.1 stThroughputs: 1899.14 2280.43 1963.33 1893.47 aggregated: 8036.37
We can see that the impact is mainly on CPU usage. The new model moves processing from kthread to NAPI (software interrupt).
Changes since V3:
* rebase on top of net-next
* group TX and RX fields in different regions of the structure
* minor bugfix : useGFP_ATOMICto avoid sleeping in SI context
* split functional changes and funcation renames into two patches
* minor coding style fixesWei Liu (3):
xen-netback: remove page tracking facility
xen-netback: switch to NAPI + kthread 1:1 model
xen-netback: rename functionsdrivers/net/xen-netback/common.h | 127 ++++-- drivers/net/xen-netback/interface.c | 119 +++-- drivers/net/xen-netback/netback.c | 833 +++++++++++------------------------ 3 files changed, 406 insertions(+), 673 deletions(-)Signature · 1 line
1.7.10.4
Quoted 31 lines · Andrew Bennieston
Quoted 7 lines · David Vrabel
Quoted 6 lines · Pasi Kärkkäinen
Quoted 4 lines · Wei Liu
IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
Quoted 7 lines
Quoted 1 line
Hmm.. so with these patches applied is is *required* to do manual configuration in dom0 to get good performance?
This should be irqbalanced's job. The existing version doesn't do a good enough job yet though. Andrew Bennieston may have more details.
David
irqbalance 1.0.6 [1] includes a patch [2] from Wei Liu [3] that adds support for balancing `xen-dyn-event' interrupts. When I have compiled this version and run it under Xen(Server) I noticed that the interrupts are indeed moving between cores, but not necessarily in what I would call an obvious or optimal way (e.g. several VIF interrupts are being grouped onto a single dom0 VCPU at times). I plan on investigating this further when time permits.
I also noticed that, from time to time, the irqbalance process disappears. I tracked this down to a segfault that occurs when a VM shuts down and an IRQ disappears during one of irqbalance's periodic rescans. I'm hoping to be able to narrow this down sufficiently to identify the cause and ideally fix it, but I don't have a lot of time to work on this at the moment.
Quoted 9 lines
As for the impact on Wei's patches, without irqbalance it would be trivial to automatically assign (via a script, on VM start) the interrupts for a particular VIF to a particular dom0 vCPU in a round-robin fashion, just as VIFs were previously assigned to netback kthreads. This would result in broadly the same performance as before, while an improved irqbalanced should give better performance and fairness when two different VIFs would otherwise be competing for the same resources.
So can I conclude that this model doesn't incur severe performance regression, on the other hand it has its advantage on fairness so it's worth upstreaming?
If so I will post another series shortly with all comments addressed.
Wei.
Matt, Konrad, Annie, David, thoughts?
Wei.
Quoted 55 lines · Wei Liu
Quoted 31 lines · Andrew Bennieston
Quoted 7 lines · David Vrabel
Quoted 6 lines · Pasi Kärkkäinen
Quoted 4 lines · Wei Liu
IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
Quoted 7 lines
Quoted 1 line
Hmm.. so with these patches applied is is *required* to do manual configuration in dom0 to get good performance?
This should be irqbalanced's job. The existing version doesn't do a good enough job yet though. Andrew Bennieston may have more details.
David
irqbalance 1.0.6 [1] includes a patch [2] from Wei Liu [3] that adds support for balancing `xen-dyn-event' interrupts. When I have compiled this version and run it under Xen(Server) I noticed that the interrupts are indeed moving between cores, but not necessarily in what I would call an obvious or optimal way (e.g. several VIF interrupts are being grouped onto a single dom0 VCPU at times). I plan on investigating this further when time permits.
I also noticed that, from time to time, the irqbalance process disappears. I tracked this down to a segfault that occurs when a VM shuts down and an IRQ disappears during one of irqbalance's periodic rescans. I'm hoping to be able to narrow this down sufficiently to identify the cause and ideally fix it, but I don't have a lot of time to work on this at the moment.
Quoted 9 lines
As for the impact on Wei's patches, without irqbalance it would be trivial to automatically assign (via a script, on VM start) the interrupts for a particular VIF to a particular dom0 vCPU in a round-robin fashion, just as VIFs were previously assigned to netback kthreads. This would result in broadly the same performance as before, while an improved irqbalanced should give better performance and fairness when two different VIFs would otherwise be competing for the same resources.
So can I conclude that this model doesn't incur severe performance regression, on the other hand it has its advantage on fairness so it's worth upstreaming?
If so I will post another series shortly with all comments addressed.
Wei.
Quoted 42 lines · Wei Liu
Quoted 31 lines · Andrew Bennieston
Quoted 7 lines · David Vrabel
Quoted 6 lines · Pasi Kärkkäinen
Quoted 4 lines · Wei Liu
IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
Quoted 7 lines
Quoted 1 line
Hmm.. so with these patches applied is is *required* to do manual configuration in dom0 to get good performance?
This should be irqbalanced's job. The existing version doesn't do a good enough job yet though. Andrew Bennieston may have more details.
David
irqbalance 1.0.6 [1] includes a patch [2] from Wei Liu [3] that adds support for balancing `xen-dyn-event' interrupts. When I have compiled this version and run it under Xen(Server) I noticed that the interrupts are indeed moving between cores, but not necessarily in what I would call an obvious or optimal way (e.g. several VIF interrupts are being grouped onto a single dom0 VCPU at times). I plan on investigating this further when time permits.
I also noticed that, from time to time, the irqbalance process disappears. I tracked this down to a segfault that occurs when a VM shuts down and an IRQ disappears during one of irqbalance's periodic rescans. I'm hoping to be able to narrow this down sufficiently to identify the cause and ideally fix it, but I don't have a lot of time to work on this at the moment.
Quoted 9 lines
As for the impact on Wei's patches, without irqbalance it would be trivial to automatically assign (via a script, on VM start) the interrupts for a particular VIF to a particular dom0 vCPU in a round-robin fashion, just as VIFs were previously assigned to netback kthreads. This would result in broadly the same performance as before, while an improved irqbalanced should give better performance and fairness when two different VIFs would otherwise be competing for the same resources.
Quoted 3 lines
So can I conclude that this model doesn't incur severe performance regression, on the other hand it has its advantage on fairness so it's worth upstreaming?
Yes, I think so.
As far as initial interrupt affinity settings, I think it'd be great if the default value could be set in the kernel. I'd rather not require toolchain work or external scripts to get reasonable spread.
That said, I can understand why we might hesitate to do this in the kernel, and there's a fair president set through scripts like set_irq_affinity.sh [1].
On the other hand, the Hyper-V support for Linux guests assigns affinity on a round-robin basis [2].
Quoted 1 line
If so I will post another series shortly with all comments addressed.
Please do.
Quoted 1 line
Wei.
[1] http://www.intel.com/content/dam/doc/application-note/82575-82576-82598-82599-ethernet-controllers-interrupts-appl-note.pdf
[2] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=a11984
--msw
Quoted 37 lines · Wei Liu
Quoted 27 lines · Andrew Bennieston
Quoted 11 lines · David Vrabel
Quoted 5 lines · Pasi Kärkkäinen
Quoted 3 lines · Wei Liu
IRQs are distributed to 4 cores by hand in the new model, while in the old model vifs are automatically distributed to 4 kthreads.
Hmm.. so with these patches applied is is *required* to do manual configuration in dom0 to get good performance?
This should be irqbalanced's job. The existing version doesn't do a good enough job yet though. Andrew Bennieston may have more details.
David
irqbalance 1.0.6 [1] includes a patch [2] from Wei Liu [3] that adds support for balancing `xen-dyn-event' interrupts. When I have compiled this version and run it under Xen(Server) I noticed that the interrupts are indeed moving between cores, but not necessarily in what I would call an obvious or optimal way (e.g. several VIF interrupts are being grouped onto a single dom0 VCPU at times). I plan on investigating this further when time permits.
I also noticed that, from time to time, the irqbalance process disappears. I tracked this down to a segfault that occurs when a VM shuts down and an IRQ disappears during one of irqbalance's periodic rescans. I'm hoping to be able to narrow this down sufficiently to identify the cause and ideally fix it, but I don't have a lot of time to work on this at the moment.
Quoted 9 lines
As for the impact on Wei's patches, without irqbalance it would be trivial to automatically assign (via a script, on VM start) the interrupts for a particular VIF to a particular dom0 vCPU in a round-robin fashion, just as VIFs were previously assigned to netback kthreads. This would result in broadly the same performance as before, while an improved irqbalanced should give better performance and fairness when two different VIFs would otherwise be competing for the same resources.
Quoted 3 lines
So can I conclude that this model doesn't incur severe performance regression, on the other hand it has its advantage on fairness so it's worth upstreaming?
I agree.
From Andrew's result, I do not see any bad affect about this model, and well worked irqbalance may give us much better performance too. And this can also simplify persistent map patch(it is kind of stopped, but my recent test shows some good results)
Quoted 2 lines
If so I will post another series shortly with all comments addressed.
Please go ahead.
Thanks
Annie