[Devel] [PATCH RHEL7 COMMIT] vziolimit: add blktrace hooks

Konstantin Khorenko khorenko at odin.com
Tue May 5 02:44:46 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.4.9
------>
commit 3bfc1fa5b827b38ecc96c6ddaaa9cacfa4bb2eec
Author: Dmitry Monakhov <dmonakhov at openvz.org>
Date:   Tue May 5 13:44:46 2015 +0400

    vziolimit: add blktrace hooks
    
    This hooks allow us to use standard blktrace tools to trace vziolimits
    functionality.
    
    https://jira.sw.ru/browse/PSBM-20104
    
    Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
 block/cfq-iosched.c      |  2 +-
 block/deadline-iosched.c |  2 +-
 fs/direct-io.c           |  2 +-
 kernel/ve/vziolimit.c    | 18 ++++++++++++++++++
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 2937c58..c649678 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3925,7 +3925,7 @@ static void cfq_insert_request(struct request_queue *q, struct request *rq)
 	cfqg_stats_update_io_add(RQ_CFQG(rq), cfqd->serving_group,
 				 rq->cmd_flags);
 
-	virtinfo_notifier_call_irq(VITYPE_IO, VIRTINFO_IO_OP_ACCOUNT, NULL);
+	virtinfo_notifier_call_irq(VITYPE_IO, VIRTINFO_IO_OP_ACCOUNT, q);
 	cfq_rq_enqueued(cfqd, cfqq, rq);
 }
 
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index 8923afa..792b305 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -110,7 +110,7 @@ deadline_add_request(struct request_queue *q, struct request *rq)
 	rq_set_fifo_time(rq, jiffies + dd->fifo_expire[data_dir]);
 	list_add_tail(&rq->queuelist, &dd->fifo_list[data_dir]);
 	ub_writeback_io(1, blk_rq_sectors(rq));
-	virtinfo_notifier_call_irq(VITYPE_IO, VIRTINFO_IO_OP_ACCOUNT, NULL);
+	virtinfo_notifier_call_irq(VITYPE_IO, VIRTINFO_IO_OP_ACCOUNT, q);
 }
 
 /*
diff --git a/fs/direct-io.c b/fs/direct-io.c
index b4bb2e9..8e67f35 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -721,7 +721,7 @@ submit_page_section(struct dio *dio, struct dio_submit *sdio, struct page *page,
 {
 	int ret = 0;
 
-	virtinfo_notifier_call(VITYPE_IO, VIRTINFO_IO_PREPARE, NULL);
+	virtinfo_notifier_call(VITYPE_IO, VIRTINFO_IO_PREPARE, bdev_get_queue(map_bh->b_bdev));
 
 	if (dio->rw & WRITE) {
 		/*
diff --git a/kernel/ve/vziolimit.c b/kernel/ve/vziolimit.c
index 4a0fee7..6239c4c 100644
--- a/kernel/ve/vziolimit.c
+++ b/kernel/ve/vziolimit.c
@@ -11,6 +11,8 @@
 #include <linux/virtinfo.h>
 #include <linux/vzctl.h>
 #include <linux/vziolimit.h>
+#include <linux/blkdev.h>
+#include <linux/blktrace_api.h>
 #include <asm/uaccess.h>
 #include <bc/beancounter.h>
 
@@ -153,6 +155,7 @@ static int iolimit_virtinfo(struct vnotifier_block *nb,
 	struct user_beancounter *ub = get_exec_ub();
 	struct iolimit *iolimit = ub->private_data2;
 	unsigned long flags, timeout;
+	struct request_queue *q;
 
 	if (!iolimit)
 		return old_ret;
@@ -175,8 +178,16 @@ static int iolimit_virtinfo(struct vnotifier_block *nb,
 			break;
 		case VIRTINFO_IO_FUSE_REQ:
 		case VIRTINFO_IO_OP_ACCOUNT:
+
 			if (!iolimit->iops.speed)
 				break;
+
+			q = (struct request_queue *) arg;
+			if (q)
+				blk_add_trace_msg(q, "vziolimit iops ub:%s speed:%d remain:%d ",
+						  ub->ub_name,iolimit->iops.speed,
+						  iolimit->iops.remain);
+
 			spin_lock_irqsave(&ub->ub_lock, flags);
 			if (iolimit->iops.speed) {
 				throttle_charge(&iolimit->iops, 1);
@@ -192,9 +203,16 @@ static int iolimit_virtinfo(struct vnotifier_block *nb,
 			break;
 		case VIRTINFO_IO_PREPARE:
 		case VIRTINFO_IO_JOURNAL:
+
 			if (current->flags & PF_SWAPWRITE)
 				break;
+
 			timeout = iolimit_timeout(iolimit);
+			q = (struct request_queue *) arg;
+			if (q)
+				blk_add_trace_msg(q, "vziolimit sleep ub:%s speed:%ld ",
+						  ub->ub_name, timeout);
+
 			if (timeout && !fatal_signal_pending(current))
 				iolimit_wait(iolimit, timeout);
 			break;



More information about the Devel mailing list