Skip to contentSkip to conversation

qemu/xendisk: set maximum number of grants to be used

PATCH Stefano Stabellini 3 participants 11 messages May 31, 2012 – Jun 12, 2012 4 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 9 lines · Jan Beulich

Legacy (non-pvops) gntdev drivers may require this to be done when the number of grants intended to be used simultaneously exceeds a certain driver specific default limit.

Change in v2: Double the number requested, as we need to account for the allocations needing to happen in contiguous chunks. The worst case number would be max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1, but in order to keep things simple just use 2 * max_req * max_seg.

Quoted 4 lines

Change in v3: introduce MAX_GRANTS(), and add a comment explaining its definition.

I think it is OK, I'll submit it as a bug fix for QEMU 1.1.

It should be applied to qemu-xen-traditional too.

Quoted 34 lines
hw/xen_disk.c +14 -0
@@ -537,6 +537,15 @@ static void blk_bh(void *opaque)
     blk_handle_requests(blkdev);
 }
 
+/*
+ * We need to account for the grant allocations requiring contiguous
+ * chunks; the worst case number would be
+ *     max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1,
+ * but in order to keep things simple just use
+ *     2 * max_req * max_seg.
+ */
+#define MAX_GRANTS(max_req, max_seg) (2 * (max_req) * (max_seg))
+
 static void blk_alloc(struct XenDevice *xendev)
 {
     struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
@@ -548,6 +557,11 @@ static void blk_alloc(struct XenDevice *
     if (xen_mode != XEN_EMULATE) {
         batch_maps = 1;
     }
+    if (xc_gnttab_set_max_grants(xendev->gnttabdev,
+            MAX_GRANTS(max_requests, BLKIF_MAX_SEGMENTS_PER_REQUEST)) < 0) {
+        xen_be_printf(xendev, 0, "xc_gnttab_set_max_grants failed: %s\n",
+                      strerror(errno));
+    }
 }
 
 static int blk_init(struct XenDevice *xendev)

A message that is not in the archive (sent off-list or not yet received): alpine.DEB.2.00.1205311226060.26786@kaball-desktop

#3 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 31.05.12 at 13:27, Stefano Stabellini <[email protected]>

Quoted 10 lines · wrote:
Quoted 9 lines · Jan Beulich

Legacy (non-pvops) gntdev drivers may require this to be done when the number of grants intended to be used simultaneously exceeds a certain driver specific default limit.

Change in v2: Double the number requested, as we need to account for the allocations needing to happen in contiguous chunks. The worst case number would be max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1, but in order to keep things simple just use 2 * max_req * max_seg.

Quoted 6 lines
Quoted 4 lines

Change in v3: introduce MAX_GRANTS(), and add a comment explaining its definition.

I think it is OK, I'll submit it as a bug fix for QEMU 1.1.

Thanks!

Quoted 1 line

It should be applied to qemu-xen-traditional too.

And the other one ("qemu/xendisk: properly update stats in ioreq_release()") probably too.

Jan

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 17 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 31.05.12 at 13:27, Stefano Stabellini <[email protected]>

Quoted 15 lines · wrote:
Quoted 13 lines · Jan Beulich

Legacy (non-pvops) gntdev drivers may require this to be done when the number of grants intended to be used simultaneously exceeds a certain driver specific default limit.

Change in v2: Double the number requested, as we need to account for the allocations needing to happen in contiguous chunks. The worst case number would be max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1, but in order to keep things simple just use 2 * max_req * max_seg.

Change in v3: introduce MAX_GRANTS(), and add a comment explaining its definition.

Quoted 8 lines
Quoted 1 line

I think it is OK, I'll submit it as a bug fix for QEMU 1.1.

Thanks!

Quoted 1 line

It should be applied to qemu-xen-traditional too.

And the other one ("qemu/xendisk: properly update stats in ioreq_release()") probably too.

Right.
That patch is already in upstream QEMU and qemu-xen-upstream but it is missing in qemu-xen-traditional.

A message that is not in the archive (sent off-list or not yet received): alpine.DEB.2.00.1205311432190.26786@kaball-desktop

#7 lore raw

Stefano Stabellini writes ("Re: [Xen-devel] [PATCH, v3] qemu/xendisk: set maximum number of grants to be used"):

Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line

It should be applied to qemu-xen-traditional too.

And the other one ("qemu/xendisk: properly update stats in ioreq_release()") probably too.

Right.
That patch is already in upstream QEMU and qemu-xen-upstream but it is missing in qemu-xen-traditional.

Can you tell me the commit id in qemu-xen-upstream so I can put it in the commit message in qemu-xen-traditional ?

Thanks,
Ian.

#8 lore raw
In reply to a message not in the archive

Stefano Stabellini writes ("Re: [Xen-devel] [PATCH, v3] qemu/xendisk: set maximum number of grants to be used"):

Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line

It should be applied to qemu-xen-traditional too.

And the other one ("qemu/xendisk: properly update stats in ioreq_release()") probably too.

Right.
That patch is already in upstream QEMU and qemu-xen-upstream but it is missing in qemu-xen-traditional.

Can you tell me the commit id in qemu-xen-upstream so I can put it in the commit message in qemu-xen-traditional ?

Thanks,
Ian.

#9 lore raw
Quoted 7 lines · Ian Jackson

Stefano Stabellini writes ("Re: [Xen-devel] [PATCH, v3] qemu/xendisk: set maximum number of grants to be used"):

Quoted 6 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line

It should be applied to qemu-xen-traditional too.

And the other one ("qemu/xendisk: properly update stats in ioreq_release()") probably too.

Quoted 6 lines
Quoted 3 lines

Right.
That patch is already in upstream QEMU and qemu-xen-upstream but it is missing in qemu-xen-traditional.

Can you tell me the commit id in qemu-xen-upstream so I can put it in the commit message in qemu-xen-traditional ?

I'll let you know when I have one.

#10 lore raw
In reply to Ian Jackson
Quoted 7 lines · Ian Jackson

Stefano Stabellini writes ("Re: [Xen-devel] [PATCH, v3] qemu/xendisk: set maximum number of grants to be used"):

Quoted 6 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line

It should be applied to qemu-xen-traditional too.

And the other one ("qemu/xendisk: properly update stats in ioreq_release()") probably too.

Quoted 6 lines
Quoted 3 lines

Right.
That patch is already in upstream QEMU and qemu-xen-upstream but it is missing in qemu-xen-traditional.

Can you tell me the commit id in qemu-xen-upstream so I can put it in the commit message in qemu-xen-traditional ?

I'll let you know when I have one.

author Reviewed-by Kevin Wolf
#11 lore raw
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Ian Jackson

Stefano Stabellini writes ("Re: [Xen-devel] [PATCH, v3] qemu/xendisk: set maximum number of grants to be used"):

Quoted 6 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line

It should be applied to qemu-xen-traditional too.

And the other one ("qemu/xendisk: properly update stats in ioreq_release()") probably too.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Right.
That patch is already in upstream QEMU and qemu-xen-upstream but it is missing in qemu-xen-traditional.

Can you tell me the commit id in qemu-xen-upstream so I can put it in the commit message in qemu-xen-traditional ?

I'll let you know when I have one.

Reading more carefully, you are actually talking about a different patch from the one in the subject line.
Here is what you are looking for:

commit ed5477664369c1e9de23b0e7e8f16a418573bd2a

Author: Jan Beulich <[email protected]>
Date:   Mon May 14 16:46:33 2012 +0000

xen_disk: properly update stats in ioreq_release()

While for the "normal" case (called from blk_send_response_all()) decrementing requests_finished is correct, doing so in the parse error case is wrong; requests_inflight needs to be decremented instead.

author Reviewed-by Kevin Wolf
#12 lore raw
In reply to Stefano Stabellini
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Ian Jackson

Stefano Stabellini writes ("Re: [Xen-devel] [PATCH, v3] qemu/xendisk: set maximum number of grants to be used"):

Quoted 6 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line

It should be applied to qemu-xen-traditional too.

And the other one ("qemu/xendisk: properly update stats in ioreq_release()") probably too.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Right.
That patch is already in upstream QEMU and qemu-xen-upstream but it is missing in qemu-xen-traditional.

Can you tell me the commit id in qemu-xen-upstream so I can put it in the commit message in qemu-xen-traditional ?

I'll let you know when I have one.

Reading more carefully, you are actually talking about a different patch from the one in the subject line.
Here is what you are looking for:

commit ed5477664369c1e9de23b0e7e8f16a418573bd2a

Author: Jan Beulich <[email protected]>
Date:   Mon May 14 16:46:33 2012 +0000

xen_disk: properly update stats in ioreq_release()

While for the "normal" case (called from blk_send_response_all()) decrementing requests_finished is correct, doing so in the parse error case is wrong; requests_inflight needs to be decremented instead.

#13 lore raw
In reply to a message not in the archive
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 31.05.12 at 13:27, Stefano Stabellini <[email protected]>

Quoted 10 lines · wrote:
Quoted 9 lines · Jan Beulich

Legacy (non-pvops) gntdev drivers may require this to be done when the number of grants intended to be used simultaneously exceeds a certain driver specific default limit.

Change in v2: Double the number requested, as we need to account for the allocations needing to happen in contiguous chunks. The worst case number would be max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1, but in order to keep things simple just use 2 * max_req * max_seg.

Quoted 8 lines
Quoted 4 lines

Change in v3: introduce MAX_GRANTS(), and add a comment explaining its definition.

I think it is OK, I'll submit it as a bug fix for QEMU 1.1.

It should be applied to qemu-xen-traditional too.

This is commit 64c27e5b1fdb6d94bdc0bda3b1869d7383a35c65 in git.qemu.org/?p=qemu.git.

Jan

Quoted 35 lines
Quoted 8 lines
hw/xen_disk.c +2 -0
@@ -537,6 +537,15 @@ static void blk_bh(void *opaque)
     blk_handle_requests(blkdev);
 }
 
+/*
+ * We need to account for the grant allocations requiring contiguous

hw/xen_disk.c static void blk_bh(void *opaque) · line 551

Quoted 10 lines
hw/xen_disk.c +7 -0
+ * chunks; the worst case number would be
+ *     max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1,
+ * but in order to keep things simple just use
+ *     2 * max_req * max_seg.
+ */
+#define MAX_GRANTS(max_req, max_seg) (2 * (max_req) * (max_seg))
+
 static void blk_alloc(struct XenDevice *xendev)
 {
     struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, 

xendev);

Quoted 16 lines
hw/xen_disk.c +5 -0
@@ -548,6 +557,11 @@ static void blk_alloc(struct XenDevice *
     if (xen_mode != XEN_EMULATE) {
         batch_maps = 1;
     }
+    if (xc_gnttab_set_max_grants(xendev->gnttabdev,
+            MAX_GRANTS(max_requests, BLKIF_MAX_SEGMENTS_PER_REQUEST)) < 0) {
+        xen_be_printf(xendev, 0, "xc_gnttab_set_max_grants failed: %s\n",
+                      strerror(errno));
+    }
 }
 
 static int blk_init(struct XenDevice *xendev)
#14 lore raw
In reply to a message not in the archive
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 31.05.12 at 13:27, Stefano Stabellini <[email protected]>

Quoted 10 lines · wrote:
Quoted 9 lines · Jan Beulich

Legacy (non-pvops) gntdev drivers may require this to be done when the number of grants intended to be used simultaneously exceeds a certain driver specific default limit.

Change in v2: Double the number requested, as we need to account for the allocations needing to happen in contiguous chunks. The worst case number would be max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1, but in order to keep things simple just use 2 * max_req * max_seg.

Quoted 8 lines
Quoted 4 lines

Change in v3: introduce MAX_GRANTS(), and add a comment explaining its definition.

I think it is OK, I'll submit it as a bug fix for QEMU 1.1.

It should be applied to qemu-xen-traditional too.

This is commit 64c27e5b1fdb6d94bdc0bda3b1869d7383a35c65 in git.qemu.org/?p=qemu.git.

Jan

Quoted 35 lines
Quoted 8 lines
hw/xen_disk.c +2 -0
@@ -537,6 +537,15 @@ static void blk_bh(void *opaque)
     blk_handle_requests(blkdev);
 }
 
+/*
+ * We need to account for the grant allocations requiring contiguous

hw/xen_disk.c static void blk_bh(void *opaque) · line 551

Quoted 10 lines
hw/xen_disk.c +7 -0
+ * chunks; the worst case number would be
+ *     max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1,
+ * but in order to keep things simple just use
+ *     2 * max_req * max_seg.
+ */
+#define MAX_GRANTS(max_req, max_seg) (2 * (max_req) * (max_seg))
+
 static void blk_alloc(struct XenDevice *xendev)
 {
     struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, 

xendev);

Quoted 16 lines
hw/xen_disk.c +5 -0
@@ -548,6 +557,11 @@ static void blk_alloc(struct XenDevice *
     if (xen_mode != XEN_EMULATE) {
         batch_maps = 1;
     }
+    if (xc_gnttab_set_max_grants(xendev->gnttabdev,
+            MAX_GRANTS(max_requests, BLKIF_MAX_SEGMENTS_PER_REQUEST)) < 0) {
+        xen_be_printf(xendev, 0, "xc_gnttab_set_max_grants failed: %s\n",
+                      strerror(errno));
+    }
 }
 
 static int blk_init(struct XenDevice *xendev)