diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c index dba55e3..83c24ed 100644 --- a/drivers/block/xen-blkback/blkback.c +++ b/drivers/block/xen-blkback/blkback.c @@ -60,8 +60,11 @@ static int xen_blkif_reqs = 64; module_param_named(reqs, xen_blkif_reqs, int, 0); MODULE_PARM_DESC(reqs, "Number of blkback requests to allocate"); +static int xen_kick_front = 1; +module_param(xen_kick_front, int, 0644); + /* Run-time switchable: /sys/module/blkback/parameters/ */ -static unsigned int log_stats; +static unsigned int log_stats = 1; module_param(log_stats, int, 0644); /* @@ -255,10 +258,21 @@ static void print_stats(struct xen_blkif *blkif) pr_info("xen-blkback (%s): oo %3d | rd %4d | wr %4d | f %4d\n", current->comm, blkif->st_oo_req, blkif->st_rd_req, blkif->st_wr_req, blkif->st_f_req); + + if (blkif->st_reqs_avail) { + pr_info("xen-blkback (%s): bk %4d fk %4d | avail %4d finished %4d\n", + current->comm, blkif->st_back_kick, blkif->st_front_kick, + blkif->st_reqs_avail, blkif->st_reqs_finished); + } + blkif->st_print = jiffies + msecs_to_jiffies(10 * 1000); blkif->st_rd_req = 0; blkif->st_wr_req = 0; blkif->st_oo_req = 0; + blkif->st_back_kick = 0; + blkif->st_front_kick = 0; + blkif->st_reqs_avail = 0; + blkif->st_reqs_finished = 0; } int xen_blkif_schedule(void *arg) @@ -459,6 +473,7 @@ static int do_block_io_op(struct xen_blkif *blkif) struct pending_req *pending_req; RING_IDX rc, rp; int more_to_do = 0; + unsigned long flags; rc = blk_rings->common.req_cons; rp = blk_rings->common.sring->req_prod; @@ -505,7 +520,13 @@ static int do_block_io_op(struct xen_blkif *blkif) /* Yield point for this unbounded loop. */ cond_resched(); } - + if (!more_to_do && xen_kick_front) { + spin_lock_irqsave(&blkif->blk_ring_lock, flags); + RING_FINAL_CHECK_FOR_REQUESTS(&blk_rings->common, more_to_do); + if (more_to_do) + blkif->st_reqs_avail ++; + spin_unlock_irqrestore(&blkif->blk_ring_lock, flags); + } return more_to_do; } @@ -727,6 +748,7 @@ static void make_response(struct xen_blkif *blkif, u64 id, blk_rings->common.rsp_prod_pvt++; RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&blk_rings->common, notify); if (blk_rings->common.rsp_prod_pvt == blk_rings->common.req_cons) { + blkif->st_reqs_finished ++; /* * Tail check for pending requests. Allows frontend to avoid * notifications if requests are already in flight (lower @@ -740,10 +762,14 @@ static void make_response(struct xen_blkif *blkif, u64 id, spin_unlock_irqrestore(&blkif->blk_ring_lock, flags); - if (more_to_do) + if (more_to_do) { + blkif->st_back_kick++; blkif_notify_work(blkif); - if (notify) + } + if (notify) { + blkif->st_front_kick ++; notify_remote_via_irq(blkif->irq); + } } static int __init xen_blkif_init(void) diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h index 9e40b28..ccb72e2 100644 --- a/drivers/block/xen-blkback/common.h +++ b/drivers/block/xen-blkback/common.h @@ -161,6 +161,10 @@ struct xen_blkif { int st_f_req; int st_rd_sect; int st_wr_sect; + int st_reqs_finished; + int st_reqs_avail; + int st_front_kick; + int st_back_kick; wait_queue_head_t waiting_to_free;