[Devel] [PATCH rh7] Port diff-fairsched-do-not-account-iothrottled-tasks-in-loadavg-core

Vladimir Davydov vdavydov at parallels.com
Fri May 29 06:18:41 PDT 2015


Author: Vladimir Davydov
Email: vdavydov at parallels.com
Subject: sched: do not account iothrottled tasks in loadavg
Date: Mon, 22 Oct 2012 14:27:25 +0400

Changes from v1:
 * do not account tasks throttled while doing reclaim too

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
Acked-by: Konstantin Khlebnikov <khlebnikov at openvz.org>
=============================================================================

Related to https://jira.sw.ru/browse/PSBM-33642

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 include/linux/sched.h | 3 +++
 kernel/sched/core.c   | 7 +++++++
 kernel/sched/sched.h  | 1 +
 kernel/ve/vziolimit.c | 3 ++-
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2871013e89b9..e62dc2b6c2d3 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -167,6 +167,8 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq);
 #define TASK_PARKED		512
 #define TASK_STATE_MAX		1024
 
+#define __TASK_IOTHROTTLED	1024
+
 #define TASK_STATE_TO_CHAR_STR "RSDTtZXxKWP"
 
 extern char ___assert_task_state[1 - 2*!!(
@@ -194,6 +196,7 @@ extern char ___assert_task_state[1 - 2*!!(
 #define task_contributes_to_load(task)	\
 				((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
 				 (task->flags & PF_FROZEN) == 0)
+#define task_iothrottled(task)	((task->state & __TASK_IOTHROTTLED) != 0)
 
 #define __set_task_state(tsk, state_value)		\
 	do { (tsk)->state = (state_value); } while (0)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c6a5ab063f6a..4e6254b641a6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -870,6 +870,8 @@ void activate_task(struct rq *rq, struct task_struct *p, int flags)
 {
 	if (task_contributes_to_load(p)) {
 		rq->nr_uninterruptible--;
+		if (task_iothrottled(p))
+			rq->nr_iothrottled--;
 		task_cfs_rq(p)->nr_unint--;
 	}
 
@@ -890,6 +892,8 @@ void deactivate_task(struct rq *rq, struct task_struct *p, int flags)
 
 	if (task_contributes_to_load(p)) {
 		rq->nr_uninterruptible++;
+		if (task_iothrottled(p))
+			rq->nr_iothrottled++;
 		task_cfs_rq(p)->nr_unint++;
 	}
 
@@ -1567,6 +1571,8 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags)
 #ifdef CONFIG_SMP
 	if (p->sched_contributes_to_load) {
 		rq->nr_uninterruptible--;
+		if (task_iothrottled(p))
+			rq->nr_iothrottled--;
 		task_cfs_rq(p)->nr_unint--;
 	}
 #endif
@@ -2432,6 +2438,7 @@ static long calc_load_fold_active(struct rq *this_rq)
 
 	nr_active = this_rq->nr_running;
 	nr_active += (long) this_rq->nr_uninterruptible;
+	nr_active -= (long) this_rq->nr_iothrottled;
 
 	if (nr_active != this_rq->calc_load_active) {
 		delta = nr_active - this_rq->calc_load_active;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 555c57ef8024..d4053c649279 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -479,6 +479,7 @@ struct rq {
 	 * it on another CPU. Always updated under the runqueue lock:
 	 */
 	unsigned long nr_uninterruptible;
+	unsigned long nr_iothrottled;
 
 	unsigned long nr_sleeping;
 	unsigned long nr_stopped;
diff --git a/kernel/ve/vziolimit.c b/kernel/ve/vziolimit.c
index fc8b24a00ffd..1da233d2f89d 100644
--- a/kernel/ve/vziolimit.c
+++ b/kernel/ve/vziolimit.c
@@ -110,7 +110,8 @@ static void iolimit_wait(struct iolimit *iolimit, unsigned long timeout)
 	DEFINE_WAIT(wait);
 
 	do {
-		prepare_to_wait(&iolimit->wq, &wait, TASK_KILLABLE);
+		prepare_to_wait(&iolimit->wq, &wait,
+				TASK_KILLABLE | __TASK_IOTHROTTLED);
 		timeout = schedule_timeout(timeout);
 		if (fatal_signal_pending(current))
 			break;
-- 
2.1.4




More information about the Devel mailing list