[Devel] [PATCH RHEL7 COMMIT] vziolimit: port diff-iolimit-handle-virtinfo-events

Konstantin Khorenko khorenko at odin.com
Tue May 5 02:44:35 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 337d82253d3db00d6f8fff7ac939f0cd155173aa
Author: Dmitry Monakhov <dmonakhov at openvz.org>
Date:   Tue May 5 13:44:35 2015 +0400

    vziolimit: port diff-iolimit-handle-virtinfo-events
    
    iolimit: wire throttler into virtinfo
    
    Call throttler methods from virtinfo hook.
    
    Signed-off-by: Konstantin Khlebnikov <khlebnikov at openvz.org>
    
    ====================================
    https://jira.sw.ru/browse/PSBM-20104
    
    Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
 kernel/ve/vziolimit.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/kernel/ve/vziolimit.c b/kernel/ve/vziolimit.c
index d70d416..949d1a6 100644
--- a/kernel/ve/vziolimit.c
+++ b/kernel/ve/vziolimit.c
@@ -84,10 +84,46 @@ static unsigned long throttle_timeout(struct throttle *th, unsigned long now)
 	return min(time - now, (unsigned long)th->latency);
 }
 
+struct iolimit {
+	struct throttle throttle;
+};
 
 static int iolimit_virtinfo(struct vnotifier_block *nb,
 		unsigned long cmd, void *arg, int old_ret)
 {
+	struct user_beancounter *ub = top_beancounter(get_exec_ub());
+	struct iolimit *iolimit = ub->private_data2;
+	unsigned long flags, timeout;
+
+	if (!iolimit)
+		return old_ret;
+
+	if (!iolimit->throttle.speed)
+		return NOTIFY_OK;
+
+	switch (cmd) {
+		case VIRTINFO_IO_ACCOUNT:
+			spin_lock_irqsave(&ub->ub_lock, flags);
+			throttle_charge(&iolimit->throttle, *(size_t*)arg);
+			spin_unlock_irqrestore(&ub->ub_lock, flags);
+			break;
+		case VIRTINFO_IO_PREPARE:
+		case VIRTINFO_IO_JOURNAL:
+			timeout = throttle_timeout(&iolimit->throttle, jiffies);
+			if (timeout) {
+				__set_current_state(TASK_UNINTERRUPTIBLE);
+				schedule_timeout(timeout);
+			}
+			break;
+		case VIRTINFO_IO_READAHEAD:
+		case VIRTINFO_IO_CONGESTION:
+			timeout = throttle_timeout(&iolimit->throttle, jiffies);
+			if (timeout)
+				return NOTIFY_FAIL;
+			break;
+	}
+
+	return NOTIFY_OK;
 }
 
 static struct vnotifier_block iolimit_virtinfo_nb = {



More information about the Devel mailing list