All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com,
	tim@xen.org, linux-kernel@vger.kernel.org,
	"Julien Grall" <julien.grall@citrix.com>,
	"David Vrabel" <david.vrabel@citrix.com>,
	"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
	linux-arm-kernel@lists.infradead.org,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [RFC 19/23] block/xen-blkback: Make it running on 64KB page granularity
Date: Thu, 14 May 2015 18:00:59 +0100	[thread overview]
Message-ID: <1431622863-28575-20-git-send-email-julien.grall__47535.1939247504$1431623975$gmane$org@citrix.com> (raw)
In-Reply-To: <1431622863-28575-1-git-send-email-julien.grall@citrix.com>

The PV block protocol is using 4KB page granularity. The goal of this
patch is to allow a Linux using 64KB page granularity behaving as a
block backend on a non-modified Xen.

It's only necessary to adapt the ring size and the number of request per
indirect frames. The rest of the code is relying on the grant table
code.

Note that the grant table code is allocating a Linux page per grant
which will result to waste 6OKB for every grant when Linux is using 64KB
page granularity. This could be improved by sharing the page between
multiple grants.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>

---

Improvement such as support of 64KB grant is not taken into
consideration in this patch because we have the requirement to run a
Linux using 64KB pages on a non-modified Xen.

This has been tested only with a loop device. I plan to test passing
hard drive partition but I didn't yet convert the swiotlb code.
---
 drivers/block/xen-blkback/blkback.c |  5 +++--
 drivers/block/xen-blkback/common.h  | 16 +++++++++++++---
 drivers/block/xen-blkback/xenbus.c  |  6 +++---
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 7049528..1803c07 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -954,7 +954,7 @@ static int xen_blkbk_parse_indirect(struct blkif_request *req,
 		seg[n].nsec = segments[i].last_sect -
 			segments[i].first_sect + 1;
 		seg[n].offset = (segments[i].first_sect << 9);
-		if ((segments[i].last_sect >= (PAGE_SIZE >> 9)) ||
+		if ((segments[i].last_sect >= (XEN_PAGE_SIZE >> 9)) ||
 		    (segments[i].last_sect < segments[i].first_sect)) {
 			rc = -EINVAL;
 			goto unmap;
@@ -1203,6 +1203,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
 
 	req_operation = req->operation == BLKIF_OP_INDIRECT ?
 			req->u.indirect.indirect_op : req->operation;
+
 	if ((req->operation == BLKIF_OP_INDIRECT) &&
 	    (req_operation != BLKIF_OP_READ) &&
 	    (req_operation != BLKIF_OP_WRITE)) {
@@ -1261,7 +1262,7 @@ static int dispatch_rw_block_io(struct xen_blkif *blkif,
 			seg[i].nsec = req->u.rw.seg[i].last_sect -
 				req->u.rw.seg[i].first_sect + 1;
 			seg[i].offset = (req->u.rw.seg[i].first_sect << 9);
-			if ((req->u.rw.seg[i].last_sect >= (PAGE_SIZE >> 9)) ||
+			if ((req->u.rw.seg[i].last_sect >= (XEN_PAGE_SIZE >> 9)) ||
 			    (req->u.rw.seg[i].last_sect <
 			     req->u.rw.seg[i].first_sect))
 				goto fail_response;
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index 7a03e07..ef15ad4 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -39,6 +39,7 @@
 #include <asm/pgalloc.h>
 #include <asm/hypervisor.h>
 #include <xen/grant_table.h>
+#include <xen/page.h>
 #include <xen/xenbus.h>
 #include <xen/interface/io/ring.h>
 #include <xen/interface/io/blkif.h>
@@ -50,12 +51,21 @@
  */
 #define MAX_INDIRECT_SEGMENTS 256
 
-#define SEGS_PER_INDIRECT_FRAME \
-	(PAGE_SIZE/sizeof(struct blkif_request_segment))
+/*
+ * Xen use 4K pages. The guest may use different page size (4K or 64K)
+ * Number of Xen pages per segment
+ */
+#define XEN_PAGES_PER_SEGMENT   (PAGE_SIZE / XEN_PAGE_SIZE)
+
+#define SEGS_PER_INDIRECT_FRAME	\
+	(XEN_PAGE_SIZE/sizeof(struct blkif_request_segment) / XEN_PAGES_PER_SEGMENT)
+#define XEN_PAGES_PER_INDIRECT_FRAME \
+	(XEN_PAGE_SIZE/sizeof(struct blkif_request_segment))
+
 #define MAX_INDIRECT_PAGES \
 	((MAX_INDIRECT_SEGMENTS + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
 #define INDIRECT_PAGES(_segs) \
-	((_segs + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
+	((_segs + XEN_PAGES_PER_INDIRECT_FRAME - 1)/XEN_PAGES_PER_INDIRECT_FRAME)
 
 /* Not a real protocol.  Used to generate ring structs which contain
  * the elements common to all protocols only.  This way we get a
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 6ab69ad..2fcf24e 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -217,21 +217,21 @@ static int xen_blkif_map(struct xen_blkif *blkif, grant_ref_t gref,
 	{
 		struct blkif_sring *sring;
 		sring = (struct blkif_sring *)blkif->blk_ring;
-		BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
+		BACK_RING_INIT(&blkif->blk_rings.native, sring, XEN_PAGE_SIZE);
 		break;
 	}
 	case BLKIF_PROTOCOL_X86_32:
 	{
 		struct blkif_x86_32_sring *sring_x86_32;
 		sring_x86_32 = (struct blkif_x86_32_sring *)blkif->blk_ring;
-		BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE);
+		BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, XEN_PAGE_SIZE);
 		break;
 	}
 	case BLKIF_PROTOCOL_X86_64:
 	{
 		struct blkif_x86_64_sring *sring_x86_64;
 		sring_x86_64 = (struct blkif_x86_64_sring *)blkif->blk_ring;
-		BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE);
+		BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, XEN_PAGE_SIZE);
 		break;
 	}
 	default:
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2015-05-14 17:18 UTC|newest]

Thread overview: 200+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14 17:00 [RFC 00/23] arm64: Add support for 64KB page granularity in Xen guest Julien Grall
2015-05-14 17:00 ` Julien Grall
2015-05-14 17:00 ` [RFC 01/23] xen: Include xen/page.h rather than asm/xen/page.h Julien Grall
2015-05-14 17:00 ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-19 13:50   ` [Xen-devel] " David Vrabel
2015-05-19 13:50     ` David Vrabel
2015-05-19 13:50   ` David Vrabel
2015-05-14 17:00 ` [RFC 02/23] xen/xenbus: client: Fix call of virt_to_mfn in xenbus_grant_ring Julien Grall
2015-05-14 17:00 ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-19 13:51   ` David Vrabel
2015-05-19 13:51   ` [Xen-devel] " David Vrabel
2015-05-19 13:51     ` David Vrabel
2015-05-19 14:12     ` Julien Grall
2015-05-19 14:12     ` [Xen-devel] " Julien Grall
2015-05-19 14:12       ` Julien Grall
2015-05-14 17:00 ` [RFC 03/23] xen/grant-table: Remove unused macro SPP Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-19 13:52   ` [Xen-devel] " David Vrabel
2015-05-19 13:52     ` David Vrabel
2015-05-19 13:52   ` David Vrabel
2015-05-14 17:00 ` [RFC 04/23] block/xen-blkfront: Remove unused macro MAXIMUM_OUTSTANDING_BLOCK_REQS Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-20 14:36   ` Roger Pau Monné
2015-05-20 14:36   ` Roger Pau Monné
2015-05-20 14:36     ` Roger Pau Monné
2015-05-14 17:00 ` Julien Grall
2015-05-14 17:00 ` [RFC 05/23] block/xen-blkfront: Remove invalid comment Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-20 14:42   ` Roger Pau Monné
2015-05-20 14:42     ` Roger Pau Monné
2015-05-20 14:42     ` Roger Pau Monné
2015-05-14 17:00 ` [RFC 06/23] block/xen-blkback: s/nr_pages/nr_segs/ Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-20 14:54   ` Roger Pau Monné
2015-05-20 14:54     ` Roger Pau Monné
2015-05-20 14:54   ` Roger Pau Monné
2015-05-14 17:00 ` [RFC 07/23] net/xen-netfront: Correct printf format in xennet_get_responses Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-19 13:53   ` [Xen-devel] " David Vrabel
2015-05-19 13:53     ` David Vrabel
2015-05-19 13:53   ` David Vrabel
2015-05-14 17:00 ` [RFC 08/23] net/xen-netback: Remove unused code in xenvif_rx_action Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-15  0:26   ` Wei Liu
2015-05-15  0:26   ` Wei Liu
2015-05-15  0:26     ` Wei Liu
2015-05-14 17:00 ` Julien Grall
2015-05-14 17:00 ` [RFC 09/23] arm/xen: Drop duplicate define mfn_to_virt Julien Grall
2015-05-14 17:00 ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-06-23 13:25   ` Stefano Stabellini
2015-06-23 13:25   ` Stefano Stabellini
2015-06-23 13:25     ` Stefano Stabellini
2015-06-23 13:53     ` Julien Grall
2015-06-23 13:53     ` [Xen-devel] " Julien Grall
2015-06-23 13:53       ` Julien Grall
2015-05-14 17:00 ` [RFC 10/23] xen/biomerge: WORKAROUND always says the biovec are not mergeable Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-15 15:54   ` Boris Ostrovsky
2015-05-15 15:54   ` Boris Ostrovsky
2015-05-15 15:54     ` Boris Ostrovsky
2015-05-19 14:16     ` Julien Grall
2015-05-19 14:16       ` Julien Grall
2015-05-19 14:16     ` Julien Grall
2015-05-14 17:00 ` [RFC 11/23] xen: Add Xen specific page definition Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00 ` [RFC 12/23] xen: Extend page_to_mfn to take an offset in the page Julien Grall
2015-05-14 17:00 ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-19 13:57   ` David Vrabel
2015-05-19 13:57   ` [Xen-devel] " David Vrabel
2015-05-19 13:57     ` David Vrabel
2015-05-19 14:18     ` Julien Grall
2015-05-19 14:18       ` Julien Grall
2015-05-19 14:18     ` Julien Grall
2015-05-14 17:00 ` [RFC 13/23] xen/xenbus: Use Xen page definition Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-19 13:59   ` David Vrabel
2015-05-19 13:59   ` [Xen-devel] " David Vrabel
2015-05-19 13:59     ` David Vrabel
2015-05-19 14:19     ` Julien Grall
2015-05-19 14:19     ` [Xen-devel] " Julien Grall
2015-05-19 14:19       ` Julien Grall
2015-05-14 17:00 ` [RFC 14/23] tty/hvc: xen: Use xen " Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00 ` [RFC 15/23] xen/balloon: Don't rely on the page granularity is the same for Xen and Linux Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-19 15:23   ` [Xen-devel] " David Vrabel
2015-05-19 15:23     ` David Vrabel
2015-05-19 15:23   ` David Vrabel
2015-05-14 17:00 ` Julien Grall
2015-05-14 17:00 ` [RFC 16/23] xen/events: fifo: Make it running on 64KB granularity Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-19 15:25   ` David Vrabel
2015-05-19 15:25   ` [Xen-devel] " David Vrabel
2015-05-19 15:25     ` David Vrabel
2015-05-14 17:00 ` [RFC 17/23] xen/grant-table: " Julien Grall
2015-05-14 17:00 ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-19 15:27   ` [Xen-devel] " David Vrabel
2015-05-19 15:27     ` David Vrabel
2015-05-19 15:27   ` David Vrabel
2015-05-14 17:00 ` [RFC 18/23] block/xen-blkfront: Make it running on 64KB page granularity Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:00 ` Julien Grall [this message]
2015-05-14 17:00 ` [RFC 19/23] block/xen-blkback: " Julien Grall
2015-05-14 17:00   ` Julien Grall
2015-05-14 17:01 ` [RFC 20/23] net/xen-netfront: " Julien Grall
2015-05-14 17:01 ` Julien Grall
2015-05-14 17:01   ` Julien Grall
2015-05-14 17:01 ` [RFC 21/23] net/xen-netback: " Julien Grall
2015-05-14 17:01   ` Julien Grall
2015-05-14 17:01   ` Julien Grall
2015-05-14 17:01   ` Julien Grall
2015-05-15  2:35   ` Wei Liu
2015-05-15  2:35     ` Wei Liu
2015-05-15 12:35     ` [Xen-devel] " Julien Grall
2015-05-15 12:35       ` Julien Grall
2015-05-15 15:31       ` Wei Liu
2015-05-15 15:31         ` Wei Liu
2015-05-15 15:41         ` Ian Campbell
2015-05-15 15:41           ` Ian Campbell
2015-05-15 15:41         ` Ian Campbell
2015-05-18 12:11         ` [Xen-devel] " Julien Grall
2015-05-18 12:11           ` Julien Grall
2015-05-18 12:54           ` Wei Liu
2015-05-18 12:54           ` [Xen-devel] " Wei Liu
2015-05-18 12:54             ` Wei Liu
2015-05-19 22:56             ` Julien Grall
2015-05-19 22:56             ` [Xen-devel] " Julien Grall
2015-05-19 22:56               ` Julien Grall
2015-05-20  8:26               ` Wei Liu
2015-05-20  8:26               ` [Xen-devel] " Wei Liu
2015-05-20  8:26                 ` Wei Liu
2015-05-20 14:26                 ` Julien Grall
2015-05-20 14:26                   ` Julien Grall
2015-05-20 14:26                 ` Julien Grall
2015-05-20 14:29               ` Julien Grall
2015-05-20 14:29               ` [Xen-devel] " Julien Grall
2015-05-20 14:29                 ` Julien Grall
2015-05-18 12:11         ` Julien Grall
2015-05-15 15:31       ` Wei Liu
2015-05-15 12:35     ` Julien Grall
2015-05-15  2:35   ` Wei Liu
2015-05-14 17:01 ` [RFC 22/23] xen/privcmd: Add support for Linux " Julien Grall
2015-05-14 17:01 ` Julien Grall
2015-05-14 17:01   ` Julien Grall
2015-05-19 15:39   ` David Vrabel
2015-05-19 15:39   ` [Xen-devel] " David Vrabel
2015-05-19 15:39     ` David Vrabel
2015-06-18 17:05     ` Julien Grall
2015-06-18 17:05     ` [Xen-devel] " Julien Grall
2015-06-18 17:05       ` Julien Grall
2015-05-14 17:01 ` [RFC 23/23] arm/xen: Add support for " Julien Grall
2015-05-14 17:01   ` Julien Grall
2015-05-14 17:01   ` Julien Grall
2015-06-23 14:19   ` Stefano Stabellini
2015-06-23 14:19   ` Stefano Stabellini
2015-06-23 14:19     ` Stefano Stabellini
2015-06-23 14:37     ` Julien Grall
2015-06-23 14:37     ` Julien Grall
2015-06-23 14:37       ` Julien Grall
2015-06-23 14:49       ` Stefano Stabellini
2015-06-23 14:49       ` Stefano Stabellini
2015-06-23 14:49         ` Stefano Stabellini
2015-06-23 15:02         ` [Xen-devel] " Julien Grall
2015-06-23 15:02           ` Julien Grall
2015-06-23 16:12           ` Stefano Stabellini
2015-06-23 16:12           ` [Xen-devel] " Stefano Stabellini
2015-06-23 16:12             ` Stefano Stabellini
2015-06-23 15:02         ` Julien Grall
2015-05-15 15:45 ` [RFC 00/23] arm64: Add support for 64KB page granularity in Xen guest David Vrabel
2015-05-15 15:45 ` [Xen-devel] " David Vrabel
2015-05-15 15:45   ` David Vrabel
2015-05-15 15:51   ` Boris Ostrovsky
2015-05-15 15:51   ` [Xen-devel] " Boris Ostrovsky
2015-05-15 15:51     ` Boris Ostrovsky
2015-05-18 12:23   ` Julien Grall
2015-05-18 12:23   ` [Xen-devel] " Julien Grall
2015-05-18 12:23     ` Julien Grall
2015-06-23 13:37     ` Stefano Stabellini
2015-06-23 13:37     ` [Xen-devel] " Stefano Stabellini
2015-06-23 13:37       ` Stefano Stabellini
2015-06-23 13:41       ` Stefano Stabellini
2015-06-23 13:41       ` [Xen-devel] " Stefano Stabellini
2015-06-23 13:41         ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='1431622863-28575-20-git-send-email-julien.grall__47535.1939247504$1431623975$gmane$org@citrix.com' \
    --to=julien.grall@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roger.pau@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.