[Devel] [PATCH RHEL7 COMMIT] vziolimit: port diff-iolimit-wakup-at-kill-and-limit-change

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

    vziolimit: port diff-iolimit-wakup-at-kill-and-limit-change
    
    iolimit: wakeable and killable iolimit wait
    
    * Make iolimit wait killable.
    * Wakeup all tasks after iolimit speed change.
    
    https://jira.sw.ru/browse/PCLIN-28566
    
    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 | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/kernel/ve/vziolimit.c b/kernel/ve/vziolimit.c
index 72b8d51..af16182 100644
--- a/kernel/ve/vziolimit.c
+++ b/kernel/ve/vziolimit.c
@@ -87,8 +87,25 @@ static unsigned long throttle_timeout(struct throttle *th, unsigned long now)
 
 struct iolimit {
 	struct throttle throttle;
+	wait_queue_head_t wq;
 };
 
+static void iolimit_wait(struct iolimit *iolimit, unsigned long timeout)
+{
+	DEFINE_WAIT(wait);
+
+	do {
+		prepare_to_wait(&iolimit->wq, &wait, TASK_KILLABLE);
+		timeout = schedule_timeout(timeout);
+		if (fatal_signal_pending(current))
+			break;
+		if (unlikely(timeout))
+			timeout = min(throttle_timeout(&iolimit->throttle,
+						jiffies), timeout);
+	} while (timeout);
+	finish_wait(&iolimit->wq, &wait);
+}
+
 static int iolimit_virtinfo(struct vnotifier_block *nb,
 		unsigned long cmd, void *arg, int old_ret)
 {
@@ -113,10 +130,8 @@ static int iolimit_virtinfo(struct vnotifier_block *nb,
 			if (current->flags & PF_FLUSHER)
 				break;
 			timeout = throttle_timeout(&iolimit->throttle, jiffies);
-			if (timeout) {
-				__set_current_state(TASK_UNINTERRUPTIBLE);
-				schedule_timeout(timeout);
-			}
+			if (timeout && !fatal_signal_pending(current))
+				iolimit_wait(iolimit, timeout);
 			break;
 		case VIRTINFO_IO_READAHEAD:
 		case VIRTINFO_IO_CONGESTION:
@@ -159,6 +174,7 @@ static int iolimit_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 				err = -ENOMEM;
 				if (!new_iolimit)
 					break;
+				init_waitqueue_head(&new_iolimit->wq);
 			}
 
 			spin_lock_irq(&ub->ub_lock);
@@ -177,6 +193,8 @@ static int iolimit_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 			spin_unlock_irq(&ub->ub_lock);
 
+			wake_up_all(&iolimit->wq);
+
 			err = 0;
 			break;
 		case VZCTL_GET_IOLIMIT:



More information about the Devel mailing list