[RFC v5 3/6] sched/core: Update turbo_sched count only when required
From: Parth Shah
Date: Mon Oct 07 2019 - 04:31:30 EST
Use the get/put methods to add/remove the use of TurboSched support, such
that the feature is turned on only in the presence of atleast one
classified small bckground task.
Signed-off-by: Parth Shah <parth@xxxxxxxxxxxxx>
---
kernel/sched/core.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ee5980b4e150..6e1ae8046fe0 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3141,6 +3141,9 @@ static struct rq *finish_task_switch(struct task_struct *prev)
mmdrop(mm);
}
if (unlikely(prev_state == TASK_DEAD)) {
+ if (unlikely(prev->flags & PF_CAN_BE_PACKED))
+ turbo_sched_put();
+
if (prev->sched_class->task_dead)
prev->sched_class->task_dead(prev);
@@ -4793,6 +4796,10 @@ static int __sched_setscheduler(struct task_struct *p,
prev_class = p->sched_class;
+ /* Refcount tasks classified as a small background task */
+ if (task_packing_flag != (p->flags & PF_CAN_BE_PACKED))
+ (task_packing_flag) ? turbo_sched_get() : turbo_sched_put();
+
__setscheduler(rq, p, attr, pi);
__setscheduler_uclamp(p, attr);
--
2.17.1