All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [RFC] rt: kernel/sched/core: fix kthread_park() pending too long when CPU un-plugged
@ 2021-01-07  9:18 Ran Wang
  2021-01-07  9:13 ` Ran Wang
  2021-01-07 10:45 ` Peter Zijlstra
  0 siblings, 2 replies; 9+ messages in thread
From: Ran Wang @ 2021-01-07  9:18 UTC (permalink / raw)
  To: Sebastian Siewior, Thomas Gleixner
  Cc: Jiafei Pan, linux-rt-users, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
	Ben Segall, Mel Gorman, linux-kernel, Ran Wang

When doing CPU un-plug stress test, function smpboot_park_threads() would
get call to park kernel threads (which including ksoftirqd) on that
CPU core, and function wait_task_inactive() would yield for those queued
task(s) by calling schedule_hrtimerout() with mode of HRTIMER_MODE_REL.

stack trace:
...
smpboot_thread_fn
    cpuhp_thread_fun
        cpuhp_invoke_callback
            smpboot_park_threads
              smpboot_park_thread: ksoftirqd/1
                kthread_park
                  wait_task_inactive
                     schedule_hrtimerout

However, when PREEMPT_RT is set, this would cause a pending issue since
schedule_hrtimerout() depend on thread ksoftirqd to complete related
work if it using HRTIMER_MODE_SOFT. So force using HRTIMER_MODE_HARD
in such case.

Suggested-by: Jiafei Pan <jiafei.pan@nxp.com>
Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
---
 kernel/sched/core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 792da55..4cc742a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2054,10 +2054,15 @@ unsigned long wait_task_inactive(struct task_struct *p, long match_state)
 			ktime_t to = NSEC_PER_SEC / HZ;
 
 			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_hrtimeout(&to, HRTIMER_MODE_REL);
+
+			if (IS_ENABLED(CONFIG_PREEMPT_RT) &&
+			    !strncmp(p->comm, "ksoftirqd/", 10))
+				schedule_hrtimeout(&to,
+					HRTIMER_MODE_REL | HRTIMER_MODE_HARD);
+			else
+				schedule_hrtimeout(&to, HRTIMER_MODE_REL);
 			continue;
 		}
-
 		/*
 		 * Ahh, all good. It wasn't running, and it wasn't
 		 * runnable, which means that it will never become
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-01-08 11:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07  9:18 [PATCH] [RFC] rt: kernel/sched/core: fix kthread_park() pending too long when CPU un-plugged Ran Wang
2021-01-07  9:13 ` Ran Wang
2021-01-07 10:45 ` Peter Zijlstra
2021-01-07 15:28   ` Sebastian Siewior
2021-01-08  8:45     ` Ran Wang
2021-01-08  9:05       ` Sebastian Siewior
2021-01-08  9:27         ` Ran Wang
2021-01-08  9:32     ` Peter Zijlstra
2021-01-08 11:19       ` Sebastian Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.