[Devel] [PATCH rh7] sched: Account iothrottled wakeups correctly

Kirill Tkhai ktkhai at virtuozzo.com
Tue Aug 8 16:47:29 MSK 2017


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.

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 69f83682317..54f92eb2f1f 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 4befd7cffb5..9899a55f6e8 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