[PATCH v15 4/7] io-throttle controller infrastructure

Andrea Righi righi.andrea at gmail.com
Tue Apr 28 07:50:50 PDT 2009


On Tue, Apr 28, 2009 at 10:43:51AM +0200, Andrea Righi wrote:
> This is the core of the io-throttle kernel infrastructure. It creates
> the basic interfaces to the cgroup subsystem and implements the I/O
> measurement and throttling functionality.

Subject: io-throttle: correctly throttle O_DIRECT reads

There's a bug in the latest io-throttle patchset: the IO generated by
O_DIRECT reads is correctly accounted, but tasks doing direct IO are not
correctly throttled.

The following fix apply the correct behaviour, throttling the tasks that
are doing O_DIRECT reads directly, instead of delaying their IO
requests.

[ This patch must be applied on top of io-throttle v15 ]

Signed-off-by: Andrea Righi <righi.andrea at gmail.com>
---
 block/blk-io-throttle.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/block/blk-io-throttle.c b/block/blk-io-throttle.c
index 380a21a..8dc2c93 100644
--- a/block/blk-io-throttle.c
+++ b/block/blk-io-throttle.c
@@ -803,12 +803,21 @@ cgroup_io_throttle(struct bio *bio, struct block_device *bdev, ssize_t bytes)
 	 * cgroup. If they're different we're doing writeback IO and we can't
 	 * throttle the current task directly.
 	 */
-	if (!is_in_dio())
+	if (!is_in_dio()) {
+		/*
+		 * We're not doing O_DIRECT: find the source of this IO
+		 * request.
+		 */
 		iot = get_iothrottle_from_bio(bio);
+	}
 	rcu_read_lock();
 	curr_iot = task_to_iothrottle(current);
-	if (curr_iot != iot) {
-		css_get(&curr_iot->css);
+	if (iot == NULL) {
+		/* IO occurs in the same context of the current task */
+		iot = curr_iot;
+		css_get(&iot->css);
+	}
+	if (iot != curr_iot) {
 		/*
 		 * IO occurs in a different context of the current task
 		 * (writeback IO).
@@ -819,10 +828,6 @@ cgroup_io_throttle(struct bio *bio, struct block_device *bdev, ssize_t bytes)
 		 */
 		can_sleep = 0;
 	}
-	if (iot == NULL) {
-		/* IO occurs in the same context of the current task */
-		iot = curr_iot;
-	}
 	/* Apply IO throttling */
 	iothrottle_evaluate_sleep(&s, iot, bdev, bytes);
 	sleep = max(s.bw_sleep, s.iops_sleep);
@@ -831,8 +836,6 @@ cgroup_io_throttle(struct bio *bio, struct block_device *bdev, ssize_t bytes)
 	if (unlikely(sleep && can_sleep))
 		iothrottle_acct_stat(iot, bdev, type, sleep);
 	css_put(&iot->css);
-	if (curr_iot != iot)
-		css_put(&curr_iot->css);
 	rcu_read_unlock();
 	if (unlikely(sleep && can_sleep)) {
 		/* Throttle the current task directly */


More information about the Containers mailing list