[Devel,rh7] sched: Account iothrottled wakeups correctly

Submitted by Kirill Tkhai on Aug. 8, 2017, 1:47 p.m.

Details

Message ID 150220002009.21786.7772170612109488998.stgit@localhost.localdomain
State New
Series "sched: Account iothrottled wakeups correctly"
Headers show

Commit Message

Kirill Tkhai Aug. 8, 2017, 1:47 p.m.
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@virtuozzo.com>
---
 include/linux/sched.h |    1 +
 kernel/sched/core.c   |    3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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)