WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 1/2] blkback: Implement VBD QoS mechanics.

To: undisclosed-recipients:;
Subject: [Xen-devel] [PATCH 1/2] blkback: Implement VBD QoS mechanics.
From: William Pitcock <nenolod@xxxxxxxxxxxxxxxx>
Date: Tue, 31 Mar 2009 09:16:09 -0500
Delivery-date: Fri, 01 May 2009 12:06:35 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <cover.1238509559.git.nenolod@xxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <cover.1238509559.git.nenolod@xxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Impact: add ability to define I/O usage policies

This enables a nieve token-based QoS system which allows for guests to
get an equal share of I/O requests. Without this patch, a misbehaving or
misconfigured guest can use up any available I/O resources, degrading I/O
performance for other guests on the machine.

The method for specifying these limitations is not implemented in this patch,
because that is an operational detail.

Signed-off-by: William Pitcock <nenolod@xxxxxxxxxxxxxxxx>
---
 drivers/xen/blkback/blkback.c |   22 ++++++++++++++++++++++
 drivers/xen/blkback/common.h  |    6 ++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/xen/blkback/blkback.c b/drivers/xen/blkback/blkback.c
index 8d988f4..996869e 100644
--- a/drivers/xen/blkback/blkback.c
+++ b/drivers/xen/blkback/blkback.c
@@ -203,6 +203,14 @@ static void print_stats(blkif_t *blkif)
        blkif->st_oo_req = 0;
 }
 
+static void refill_reqcount(blkif_t *blkif)
+{
+       blkif->reqtime = jiffies + msecs_to_jiffies(1000);
+       blkif->reqcount += blkif->reqrate;
+       if (blkif->reqcount > blkif->reqmax)
+               blkif->reqcount = blkif->reqmax;
+}
+
 int blkif_schedule(void *arg)
 {
        blkif_t *blkif = arg;
@@ -232,6 +240,9 @@ int blkif_schedule(void *arg)
 
                if (log_stats && time_after(jiffies, blkif->st_print))
                        print_stats(blkif);
+
+               if (time_after(jiffies, blkif->reqtime))
+                       refill_reqcount(blkif);
        }
 
        if (log_stats)
@@ -313,11 +324,22 @@ static int do_block_io_op(blkif_t *blkif)
        rp = blk_rings->common.sring->req_prod;
        rmb(); /* Ensure we see queued requests up to 'rp'. */
 
+       /* if there's no available request tokens right now, and limiting
+        * is requested, then don't bother with going any further. */
+       if (blkif->reqcount <= 0 && blkif->reqmax != 0)
+               return (rc != rp) ? 1 : 0;
+
        while (rc != rp) {
 
                if (RING_REQUEST_CONS_OVERFLOW(&blk_rings->common, rc))
                        break;
 
+               /* FIXME: Should we report QoS overages as VBD_OO, or not? */
+               if (--blkif->reqcount <= 0) {
+                       more_to_do = 1;
+                       break;
+               }
+
                if (kthread_should_stop()) {
                        more_to_do = 1;
                        break;
diff --git a/drivers/xen/blkback/common.h b/drivers/xen/blkback/common.h
index 57b7825..45af42f 100644
--- a/drivers/xen/blkback/common.h
+++ b/drivers/xen/blkback/common.h
@@ -92,6 +92,12 @@ typedef struct blkif_st {
 
        grant_handle_t shmem_handle;
        grant_ref_t    shmem_ref;
+
+       /* qos information */
+       long                reqtime;
+       int                 reqcount;
+       int                 reqmax;
+       int                 reqfill;
 } blkif_t;
 
 blkif_t *blkif_alloc(domid_t domid);
-- 
1.6.1.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel