[RFC PATCH v5 6/9] sched/fair: Generalize the detach_task interface

Chen Jinghuang posted 9 patches 2 weeks, 3 days ago
[RFC PATCH v5 6/9] sched/fair: Generalize the detach_task interface
Posted by Chen Jinghuang 2 weeks, 3 days ago
From: Steve Sistare <steven.sistare@oracle.com>

The detach_task function takes a struct lb_env argument, but only needs a
few of its members.  Pass the rq and cpu arguments explicitly so the
function may be called from code that is not based on lb_env.  No
functional change.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Signed-off-by: Chen Jinghuang <chenjinghuang2@huawei.com>
---
 kernel/sched/fair.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 742462d41118..ebb13108dabe 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9602,6 +9602,17 @@ static void detach_task(struct task_struct *p, struct lb_env *env)
 	set_task_cpu(p, env->dst_cpu);
 }
 
+/*
+ * detach_task_steal() -- detach the task for the migration from @src_rq to @dst_cpu.
+ */
+static void detach_task_steal(struct task_struct *p, struct rq *src_rq, int dst_cpu)
+{
+	lockdep_assert_rq_held(src_rq);
+
+	deactivate_task(src_rq, p, DEQUEUE_NOCLOCK);
+	set_task_cpu(p, dst_cpu);
+}
+
 /*
  * detach_one_task() -- tries to dequeue exactly one task from env->src_rq, as
  * part of active balancing operations within "domain".
-- 
2.34.1