lkml.org 
[lkml]   [2022]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v7 2/2] sched/rt: Trying to push current task when target disable migrating
Date
When the task to push disable migration, retry to push the current
running task on this CPU away, instead doing nothing for this migrate
disabled task.

Signed-off-by: Schspa Shi <schspa@gmail.com>
---
kernel/sched/core.c | 13 ++++++++++++-
kernel/sched/deadline.c | 9 +++++++++
kernel/sched/rt.c | 8 ++++++++
3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index da0bf6fe9ecd..af90cc558b8e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2509,8 +2509,19 @@ int push_cpu_stop(void *arg)
if (p->sched_class->find_lock_rq)
lowest_rq = p->sched_class->find_lock_rq(p, rq);

- if (!lowest_rq)
+ if (!lowest_rq) {
+ /*
+ * The find_lock_rq function above could have released the rq
+ * lock and allow p to schedule and be preempted again, and
+ * that lowest_rq could be NULL because p now has the
+ * migrate_disable flag set and not because it could not find
+ * the lowest rq. So we must check task migration flag again.
+ */
+ if (unlikely(is_migration_disabled(p)))
+ p->migration_flags |= MDF_PUSH;
+
goto out_unlock;
+ }

// XXX validate p is still the highest prio task
if (task_rq(p) == rq) {
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index cb3b886a081c..21af20445e7f 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2335,6 +2335,15 @@ static int push_dl_task(struct rq *rq)
*/
task = pick_next_pushable_dl_task(rq);
if (task == next_task) {
+ /*
+ * If next task has now disabled migrating, see if we
+ * can push the current task.
+ */
+ if (unlikely(is_migration_disabled(task))) {
+ put_task_struct(next_task);
+ goto retry;
+ }
+
/*
* The task is still there. We don't try
* again, some other CPU will pull it when ready.
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 7bd3e6ecbe45..316088e2fee2 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2136,6 +2136,14 @@ static int push_rt_task(struct rq *rq, bool pull)
*/
task = pick_next_pushable_task(rq);
if (task == next_task) {
+ /*
+ * If next task has now disabled migrating, see if we
+ * can push the current task.
+ */
+ if (unlikely(is_migration_disabled(task))) {
+ put_task_struct(next_task);
+ goto retry;
+ }
/*
* The task hasn't migrated, and is still the next
* eligible task, but we failed to find a run-queue
--
2.29.0
\
 
 \ /
  Last update: 2022-07-13 15:50    [W:0.087 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site