[Devel] [PATCH RHEL7 COMMIT] vziolimit: port diff-ubc-iolimit-precharge-dirty-pages-opensource
Konstantin Khorenko
khorenko at odin.com
Tue May 5 02:44:40 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 e6d640dd11fe7f1fc172f81d4a2e61d1d198eaf0
Author: Dmitry Monakhov <dmonakhov at openvz.org>
Date: Tue May 5 13:44:40 2015 +0400
vziolimit: port diff-ubc-iolimit-precharge-dirty-pages-opensource
https://jira.sw.ru/browse/PSBM-20104
Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
kernel/ve/vziolimit.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/kernel/ve/vziolimit.c b/kernel/ve/vziolimit.c
index 7ff2854..19dd7ad 100644
--- a/kernel/ve/vziolimit.c
+++ b/kernel/ve/vziolimit.c
@@ -120,6 +120,35 @@ static unsigned long iolimit_timeout(struct iolimit *iolimit)
throttle_timeout(&iolimit->iops, now));
}
+static void iolimit_balance_dirty(struct iolimit *iolimit,
+ struct user_beancounter *ub,
+ unsigned long write_chunk)
+{
+ struct throttle *th = &iolimit->throttle;
+ unsigned long flags, dirty, state;
+
+ if (!th->speed)
+ return;
+
+ /* can be non-atomic on i386, but ok. this just hint. */
+ state = th->state >> PAGE_SHIFT;
+ dirty = ub_stat_get(ub, dirty_pages) + write_chunk;
+ /* protect agains ub-stat percpu drift */
+ if (dirty + UB_STAT_BATCH * num_possible_cpus() < state)
+ return;
+ /* get exact value of for smooth throttling */
+ dirty = ub_stat_get_exact(ub, dirty_pages) + write_chunk;
+ if (dirty < state)
+ return;
+
+ spin_lock_irqsave(&ub->ub_lock, flags);
+ /* precharge dirty pages */
+ throttle_charge(th, (long long)dirty << PAGE_SHIFT);
+ /* set dirty_exceeded for smooth throttling */
+ ub->dirty_exceeded = 1;
+ spin_unlock_irqrestore(&ub->ub_lock, flags);
+}
+
static int iolimit_virtinfo(struct vnotifier_block *nb,
unsigned long cmd, void *arg, int old_ret)
{
@@ -170,6 +199,9 @@ static int iolimit_virtinfo(struct vnotifier_block *nb,
if (timeout)
return NOTIFY_FAIL;
break;
+ case VIRTINFO_IO_BALANCE_DIRTY:
+ iolimit_balance_dirty(iolimit, ub, (unsigned long)arg);
+ break;
}
return NOTIFY_OK;
More information about the Devel
mailing list