[Devel] [PATCH RHEL7 COMMIT] sched: Account iothrottled wakeups correctly

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 11 17:45:16 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.35.3
------>
commit 8bea98c3ac3b5aa49c546c24980aad4de490e065
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Aug 11 18:45:15 2017 +0400

    sched: Account iothrottled wakeups correctly
    
    We can't use task_iothrottled() in ttwu_do_activate(),
    as task's state already changed to TASK_WAKING in try_to_wake_up().
    
    Instead of this, cache the fact, we are iothrottled,
    in new task_struct::sched_iothrottled_sleep bit,
    like we already do for sched_contributes_to_load
    and sched_interruptible_sleep bits.
    
    khorenko@: this deficciency lead to incorrect loadavg values
    in case a Container hits it i/o limit and it throttled.
    
    https://jira.sw.ru/browse/PSBM-68052
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 include/linux/sched.h | 1 +
 kernel/sched/core.c   | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 69f8368..54f92eb 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1377,6 +1377,7 @@ struct task_struct {
 	unsigned sched_contributes_to_load:1;
 	unsigned sched_interruptible_sleep:1;
 	unsigned woken_while_running:1;
+	unsigned sched_iothrottled_sleep:1;
 	unsigned :0; /* force alignment to the next boundary */
 
 	/* unserialized, strictly 'current' */
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 4befd7c..9899a55 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1629,7 +1629,7 @@ 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))
+		if (p->sched_iothrottled_sleep)
 			rq->nr_iothrottled--;
 		task_cfs_rq(p)->nr_unint--;
 	}
@@ -1855,6 +1855,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
 
 	p->sched_contributes_to_load = !!task_contributes_to_load(p);
 	p->sched_interruptible_sleep = (p->state == TASK_INTERRUPTIBLE);
+	p->sched_iothrottled_sleep = !!task_iothrottled(p);
 	p->state = TASK_WAKING;
 
 	if (p->sched_class->task_waking)


More information about the Devel mailing list