Skip to contentSkip to conversation

xenbus_client: extend interface to suppurt multi-page ring

RFC PATCH In review Wei Liu 3 participants 7 messages May 30, 2013 – Aug 21, 2013

Subsystems (7)
lore
Share & tools
lore

Wei Liu

author
#0 lore raw

RFC PATCH 1/1 xenbus_client: extend interface to suppurt multi-page ring

Originally Xen PV drivers only use single-page ring to pass along information. This might limit the throughput between frontend and backend as they can easily run out of ring slots if hardware is fast.

The patch extends Xenbus driver to support multi-page ring, which in general should improve throughput. Changes to various frontend / backend to adapt to the new interface are also included.

Affected Xen drivers:
* blkfront/back
* netfront/back
* pcifront/back

The interface is documented, as before, in xenbus_client.c.

---
 drivers/block/xen-blkfront.c       |    5 +-
 drivers/net/xen-netback/netback.c  |    4 +-
 drivers/net/xen-netfront.c         |    9 +-
 drivers/pci/xen-pcifront.c         |    5 +-
 drivers/xen/xen-pciback/xenbus.c   |    2 +-
 drivers/xen/xenbus/xenbus_client.c |  360 ++++++++++++++++++++++++++----------
 include/xen/xenbus.h               |   19 +-
 7 files changed, 290 insertions(+), 114 deletions(-)
drivers/block/xen-blkfront.c +3 -2
index d89ef86..cf20fd3 100644
@@ -1023,6 +1023,7 @@ static int setup_blkring(struct xenbus_device *dev,
 {
 	struct blkif_sring *sring;
 	int err;
+	grant_ref_t gref;
 
 	info->ring_ref = GRANT_INVALID_REF;
 
@@ -1042,13 +1043,13 @@ static int setup_blkring(struct xenbus_device *dev,
 	if (err)
 		goto fail;
 
-	err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
+	err = xenbus_grant_ring(dev, info->ring.sring, 1, &gref);
 	if (err < 0) {
 		free_page((unsigned long)sring);
 		info->ring.sring = NULL;
 		goto fail;
 	}
-	info->ring_ref = err;
+	info->ring_ref = gref;
 
 	err = xenbus_alloc_evtchn(dev, &info->evtchn);
 	if (err)
drivers/net/xen-netback/netback.c +2 -2
index 09f32f2..7561ca4 100644
@@ -1572,7 +1572,7 @@ int xenvif_map_frontend_rings(struct xenvif *vif,
 	int err = -ENOMEM;
 
 	err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif),
-				     tx_ring_ref, &addr);
+				     &tx_ring_ref, 1, &addr);
 	if (err)
 		goto err;
 
@@ -1580,7 +1580,7 @@ int xenvif_map_frontend_rings(struct xenvif *vif,
 	BACK_RING_INIT(&vif->tx, txs, PAGE_SIZE);
 
 	err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif),
-				     rx_ring_ref, &addr);
+				     &rx_ring_ref, 1, &addr);
 	if (err)
 		goto err;
 
drivers/net/xen-netfront.c +5 -4
index 62238a0..91a1a80 100644
@@ -1604,6 +1604,7 @@ static int setup_netfront(struct xenbus_device *dev, struct netfront_info *info)
 	int err;
 	struct net_device *netdev = info->netdev;
 	unsigned int feature_split_evtchn;
+	grant_ref_t gref;
 
 	info->tx_ring_ref = GRANT_INVALID_REF;
 	info->rx_ring_ref = GRANT_INVALID_REF;
@@ -1632,11 +1633,11 @@ static int setup_netfront(struct xenbus_device *dev, struct netfront_info *info)
 	SHARED_RING_INIT(txs);
 	FRONT_RING_INIT(&info->tx, txs, PAGE_SIZE);
 
-	err = xenbus_grant_ring(dev, virt_to_mfn(txs));
+	err = xenbus_grant_ring(dev, txs, 1, &gref);
 	if (err < 0)
 		goto grant_tx_ring_fail;
 
-	info->tx_ring_ref = err;
+	info->tx_ring_ref = gref;
 	rxs = (struct xen_netif_rx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIGH);
 	if (!rxs) {
 		err = -ENOMEM;
@@ -1646,10 +1647,10 @@ static int setup_netfront(struct xenbus_device *dev, struct netfront_info *info)
 	SHARED_RING_INIT(rxs);
 	FRONT_RING_INIT(&info->rx, rxs, PAGE_SIZE);
 
-	err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
+	err = xenbus_grant_ring(dev, rxs, 1, &gref);
 	if (err < 0)
 		goto grant_rx_ring_fail;
-	info->rx_ring_ref = err;
+	info->rx_ring_ref = gref;
 
 	if (feature_split_evtchn)
 		err = setup_netfront_split(info);
drivers/pci/xen-pcifront.c +3 -2
index 966abc6..a2c3427 100644
@@ -772,12 +772,13 @@ static int pcifront_publish_info(struct pcifront_device *pdev)
 {
 	int err = 0;
 	struct xenbus_transaction trans;
+	grant_ref_t gref;
 
-	err = xenbus_grant_ring(pdev->xdev, virt_to_mfn(pdev->sh_info));
+	err = xenbus_grant_ring(pdev->xdev, pdev->sh_info, 1, &gref);
 	if (err < 0)
 		goto out;
 
-	pdev->gnt_ref = err;
+	pdev->gnt_ref = gref;
 
 	err = xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn);
 	if (err)
drivers/xen/xen-pciback/xenbus.c +1 -1
index 64b11f9..e0834cd 100644
@@ -108,7 +108,7 @@ static int xen_pcibk_do_attach(struct xen_pcibk_device *pdev, int gnt_ref,
 		"Attaching to frontend resources - gnt_ref=%d evtchn=%d\n",
 		gnt_ref, remote_evtchn);
 
-	err = xenbus_map_ring_valloc(pdev->xdev, gnt_ref, &vaddr);
+	err = xenbus_map_ring_valloc(pdev->xdev, &gnt_ref, 1, &vaddr);
 	if (err < 0) {
 		xenbus_dev_fatal(pdev->xdev, err,
 				"Error mapping other domain page in ours.");
drivers/xen/xenbus/xenbus_client.c +263 -97

523 lines not on this page · raw message

include/xen/xenbus.h +13 -6
index 0a7515c..98a8048 100644
@@ -46,6 +46,10 @@
 #include <xen/interface/io/xenbus.h>
 #include <xen/interface/io/xs_wire.h>
 
+#define XENBUS_MAX_RING_PAGE_ORDER 4
+#define XENBUS_MAX_RING_PAGES      (1U << XENBUS_MAX_RING_PAGE_ORDER)
+#define INVALID_GRANT_HANDLE       (~0U)
+
 /* Register callback to watch this node. */
 struct xenbus_watch
 {
@@ -195,15 +199,18 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch,
 			 const char *pathfmt, ...);
 
 int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state);
-int xenbus_grant_ring(struct xenbus_device *dev, unsigned long ring_mfn);
-int xenbus_map_ring_valloc(struct xenbus_device *dev,
-			   int gnt_ref, void **vaddr);
-int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
-			   grant_handle_t *handle, void *vaddr);
+int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
+		      unsigned int nr_pages, grant_ref_t *grefs);
+int xenbus_map_ring_valloc(struct xenbus_device *dev, grant_ref_t *gnt_refs,
+			   unsigned int nr_grefs, void **vaddr);
+int xenbus_map_ring(struct xenbus_device *dev,
+		    grant_ref_t *gnt_refs, unsigned int nr_grefs,
+		    grant_handle_t *handles, void *vaddr, bool *leaked);
 
 int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr);
 int xenbus_unmap_ring(struct xenbus_device *dev,
-		      grant_handle_t handle, void *vaddr);
+		      grant_handle_t *handles, unsigned int nr_handles,
+		      void *vaddr);
 
 int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port);
 int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port);
Signature · 1 line
1.7.10.4
author
#1 lore raw
Quoted 8 lines · Wei Liu

Originally Xen PV drivers only use single-page ring to pass along information. This might limit the throughput between frontend and backend as they can easily run out of ring slots if hardware is fast.

The patch extends Xenbus driver to support multi-page ring, which in general should improve throughput. Changes to various frontend / backend to adapt to the new interface are also included.

Quoted 7 lines

Affected Xen drivers:
* blkfront/back
* netfront/back
* pcifront/back

The interface is documented, as before, in xenbus_client.c.

Please note that this patch won't apply cleanly on upstream kernel as it relies on some patches that are not in tree.

I mainly want to collect views on the interface. Also in the HVM case I use vmap, I would like to know if I get it right.

Thanks
Wei.

#2 lore raw
Quoted 14 lines · Wei Liu
Quoted 13 lines · Wei Liu

Originally Xen PV drivers only use single-page ring to pass along information. This might limit the throughput between frontend and backend as they can easily run out of ring slots if hardware is fast.

The patch extends Xenbus driver to support multi-page ring, which in general should improve throughput. Changes to various frontend / backend to adapt to the new interface are also included.

Affected Xen drivers:
* blkfront/back
* netfront/back
* pcifront/back

Quoted 5 lines
Quoted 2 lines

The interface is documented, as before, in xenbus_client.c.

Please note that this patch won't apply cleanly on upstream kernel as it relies on some patches that are not in tree.

OK.

Quoted 3 lines

I mainly want to collect views on the interface. Also in the HVM case I use vmap, I would like to know if I get it right.

This patches looks familiar that I had seen some time ago (maybe I even backported it for PV?). Anyhow the PV part looks OK.

The HVM - I don't see why we cannot do vmap. The nature of the ring is that it stays mapped for a very long time - so using vmap is OK. That is, the issues with vmap is that it takes a bit to setup and teardown - and that is OK with us.

If you would like to rebase it on top of v3.11-rc5 and repost it I don't see why we can't have it for v3.12. David, Boris?

Quoted 10 lines

Thanks
Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 29 lines · Konrad Rzeszutek Wilk
Quoted 14 lines · Wei Liu
Quoted 13 lines · Wei Liu

Originally Xen PV drivers only use single-page ring to pass along information. This might limit the throughput between frontend and backend as they can easily run out of ring slots if hardware is fast.

The patch extends Xenbus driver to support multi-page ring, which in general should improve throughput. Changes to various frontend / backend to adapt to the new interface are also included.

Affected Xen drivers:
* blkfront/back
* netfront/back
* pcifront/back

Quoted 5 lines
Quoted 2 lines

The interface is documented, as before, in xenbus_client.c.

Please note that this patch won't apply cleanly on upstream kernel as it relies on some patches that are not in tree.

OK.

Quoted 3 lines

I mainly want to collect views on the interface. Also in the HVM case I use vmap, I would like to know if I get it right.

This patches looks familiar that I had seen some time ago (maybe I even backported it for PV?). Anyhow the PV part looks OK.

Quoted 8 lines

The HVM - I don't see why we cannot do vmap. The nature of the ring is that it stays mapped for a very long time - so using vmap is OK. That is, the issues with vmap is that it takes a bit to setup and teardown - and that is OK with us.

If you would like to rebase it on top of v3.11-rc5 and repost it I don't see why we can't have it for v3.12. David, Boris?

I think the above implementation has a problem in the HVM case, but I cannot recall what. :-(

If you're generally happy with the idea, I can polish this patch and target it for 3.12.

Wei.

Quoted 15 lines
Quoted 10 lines

Thanks
Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw
Quoted 36 lines · Wei Liu
Quoted 34 lines · Konrad Rzeszutek Wilk
Quoted 14 lines · Wei Liu
Quoted 13 lines · Wei Liu

Originally Xen PV drivers only use single-page ring to pass along information. This might limit the throughput between frontend and backend as they can easily run out of ring slots if hardware is fast.

The patch extends Xenbus driver to support multi-page ring, which in general should improve throughput. Changes to various frontend / backend to adapt to the new interface are also included.

Affected Xen drivers:
* blkfront/back
* netfront/back
* pcifront/back

Quoted 5 lines
Quoted 2 lines

The interface is documented, as before, in xenbus_client.c.

Please note that this patch won't apply cleanly on upstream kernel as it relies on some patches that are not in tree.

OK.

Quoted 3 lines

I mainly want to collect views on the interface. Also in the HVM case I use vmap, I would like to know if I get it right.

This patches looks familiar that I had seen some time ago (maybe I even backported it for PV?). Anyhow the PV part looks OK.

The HVM - I don't see why we cannot do vmap. The nature of the ring is that it stays mapped for a very long time - so using vmap is OK. That is, the issues with vmap is that it takes a bit to setup and teardown - and that is OK with us.

Quoted 6 lines
Quoted 3 lines

If you would like to rebase it on top of v3.11-rc5 and repost it I don't see why we can't have it for v3.12. David, Boris?

I think the above implementation has a problem in the HVM case, but I cannot recall what. :-(

Heh. Well does it work?

Quoted 3 lines

If you're generally happy with the idea, I can polish this patch and target it for 3.12.

Yes sure. We still have some time before I need to clamp down.

Quoted 18 lines

Wei.

Quoted 15 lines
Quoted 10 lines

Thanks
Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#5 lore raw

On Tue, Aug 20, 2013 at 04:07:31PM -0400, Konrad Rzeszutek Wilk wrote:
[...]

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I think the above implementation has a problem in the HVM case, but I cannot recall what. :-(

Heh. Well does it work?

I don't remember. :-)

Quoted 5 lines
Quoted 3 lines

If you're generally happy with the idea, I can polish this patch and target it for 3.12.

Yes sure. We still have some time before I need to clamp down.

How much time do we have? Will probably post patch later this week or early next week.

Wei.

Quoted 18 lines
Quoted 18 lines

Wei.

Quoted 15 lines
Quoted 10 lines

Thanks
Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
Quoted 13 lines · Wei Liu

On Tue, Aug 20, 2013 at 04:07:31PM -0400, Konrad Rzeszutek Wilk wrote:
[...]

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

I think the above implementation has a problem in the HVM case, but

I

Quoted 3 lines
Quoted 1 line

cannot recall what. :-(

Heh. Well does it work?

I don't remember. :-)

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 1 line
Quoted 1 line

If you're generally happy with the idea, I can polish this patch

and

Quoted 3 lines
Quoted 1 line

target it for 3.12.

Yes sure. We still have some time before I need to clamp down.

How much time do we have? Will probably post patch later this week or early next week.

That sounds double. We have two to three weeks until the merge window opens. Next week is when we will be clamping down and asking only for bug fixes.

Or wait till the next merge window.

Quoted 21 lines

Wei.

Quoted 18 lines
Quoted 18 lines

Wei.

Quoted 15 lines
Quoted 10 lines

Thanks
Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel