[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/2] blkback: Implement VBD QoS mechanics.
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 operation 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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |