linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD
@ 2021-08-26 17:04 Sebastian Andrzej Siewior
  2021-08-26 17:14 ` Peter Zijlstra
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2021-08-26 17:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira, Thomas Gleixner

With PREEMPT_RT enabled all hrtimers callbacks will be invoked in
softirq mode unless they are explicitly marked as HRTIMER_MODE_HARD.
During boot kthread_bind() is used for the creation of per-CPU threads
and then hangs in wait_task_inactive() if the ksoftirqd is not
yet up and running.
The hang disappeared since commit
   26c7295be0c5e ("kthread: Do not preempt current task if it is going to call schedule()")

but enabling function trace on boot reliably leads to the freeze on boot
behaviour again.
The timer in wait_task_inactive() can not be directly used by a user
interface to abuse it and create a mass wake up of several tasks at the
same time leading to long sections with disabled interrupts.
Therefore it is safe to make the timer HRTIMER_MODE_REL_HARD.

Switch the timer to HRTIMER_MODE_REL_HARD.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 02718b6c7732d..3fbde6bc21bb2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3081,7 +3081,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
 			ktime_t to = NSEC_PER_SEC / HZ;
 
 			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_hrtimeout(&to, HRTIMER_MODE_REL);
+			schedule_hrtimeout(&to, HRTIMER_MODE_REL_HARD);
 			continue;
 		}
 
-- 
2.33.0


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

* Re: [PATCH] sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD
  2021-08-26 17:04 [PATCH] sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD Sebastian Andrzej Siewior
@ 2021-08-26 17:14 ` Peter Zijlstra
  2021-09-09 11:18 ` [tip: sched/core] " tip-bot2 for Sebastian Andrzej Siewior
  2021-10-05 14:12 ` tip-bot2 for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2021-08-26 17:14 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Ingo Molnar, Juri Lelli, Vincent Guittot,
	Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira, Thomas Gleixner

On Thu, Aug 26, 2021 at 07:04:08PM +0200, Sebastian Andrzej Siewior wrote:
> With PREEMPT_RT enabled all hrtimers callbacks will be invoked in
> softirq mode unless they are explicitly marked as HRTIMER_MODE_HARD.
> During boot kthread_bind() is used for the creation of per-CPU threads
> and then hangs in wait_task_inactive() if the ksoftirqd is not
> yet up and running.
> The hang disappeared since commit
>    26c7295be0c5e ("kthread: Do not preempt current task if it is going to call schedule()")
> 
> but enabling function trace on boot reliably leads to the freeze on boot
> behaviour again.
> The timer in wait_task_inactive() can not be directly used by a user
> interface to abuse it and create a mass wake up of several tasks at the
> same time leading to long sections with disabled interrupts.
> Therefore it is safe to make the timer HRTIMER_MODE_REL_HARD.
> 
> Switch the timer to HRTIMER_MODE_REL_HARD.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Thanks!

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

* [tip: sched/core] sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD
  2021-08-26 17:04 [PATCH] sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD Sebastian Andrzej Siewior
  2021-08-26 17:14 ` Peter Zijlstra
@ 2021-09-09 11:18 ` tip-bot2 for Sebastian Andrzej Siewior
  2021-10-05 14:12 ` tip-bot2 for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Sebastian Andrzej Siewior @ 2021-09-09 11:18 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Sebastian Andrzej Siewior, Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     e9e5ba93a24d946d6e70d5c85f74254335a6555b
Gitweb:        https://git.kernel.org/tip/e9e5ba93a24d946d6e70d5c85f74254335a6555b
Author:        Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate:    Thu, 26 Aug 2021 19:04:08 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 09 Sep 2021 11:27:30 +02:00

sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD

With PREEMPT_RT enabled all hrtimers callbacks will be invoked in
softirq mode unless they are explicitly marked as HRTIMER_MODE_HARD.
During boot kthread_bind() is used for the creation of per-CPU threads
and then hangs in wait_task_inactive() if the ksoftirqd is not
yet up and running.
The hang disappeared since commit
   26c7295be0c5e ("kthread: Do not preempt current task if it is going to call schedule()")

but enabling function trace on boot reliably leads to the freeze on boot
behaviour again.
The timer in wait_task_inactive() can not be directly used by a user
interface to abuse it and create a mass wake up of several tasks at the
same time leading to long sections with disabled interrupts.
Therefore it is safe to make the timer HRTIMER_MODE_REL_HARD.

Switch the timer to HRTIMER_MODE_REL_HARD.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210826170408.vm7rlj7odslshwch@linutronix.de
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a22cc3c..d19d1ba 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3234,7 +3234,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
 			ktime_t to = NSEC_PER_SEC / HZ;
 
 			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_hrtimeout(&to, HRTIMER_MODE_REL);
+			schedule_hrtimeout(&to, HRTIMER_MODE_REL_HARD);
 			continue;
 		}
 

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

* [tip: sched/core] sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD
  2021-08-26 17:04 [PATCH] sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD Sebastian Andrzej Siewior
  2021-08-26 17:14 ` Peter Zijlstra
  2021-09-09 11:18 ` [tip: sched/core] " tip-bot2 for Sebastian Andrzej Siewior
@ 2021-10-05 14:12 ` tip-bot2 for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Sebastian Andrzej Siewior @ 2021-10-05 14:12 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Sebastian Andrzej Siewior, Peter Zijlstra (Intel), x86, linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     c33627e9a1143afb988fb98d917c4a2faa16f9d9
Gitweb:        https://git.kernel.org/tip/c33627e9a1143afb988fb98d917c4a2faa16f9d9
Author:        Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate:    Thu, 26 Aug 2021 19:04:08 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 05 Oct 2021 15:51:32 +02:00

sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD

With PREEMPT_RT enabled all hrtimers callbacks will be invoked in
softirq mode unless they are explicitly marked as HRTIMER_MODE_HARD.
During boot kthread_bind() is used for the creation of per-CPU threads
and then hangs in wait_task_inactive() if the ksoftirqd is not
yet up and running.
The hang disappeared since commit
   26c7295be0c5e ("kthread: Do not preempt current task if it is going to call schedule()")

but enabling function trace on boot reliably leads to the freeze on boot
behaviour again.
The timer in wait_task_inactive() can not be directly used by a user
interface to abuse it and create a mass wake up of several tasks at the
same time leading to long sections with disabled interrupts.
Therefore it is safe to make the timer HRTIMER_MODE_REL_HARD.

Switch the timer to HRTIMER_MODE_REL_HARD.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210826170408.vm7rlj7odslshwch@linutronix.de
---
 kernel/sched/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1bba412..2672694 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3251,7 +3251,7 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
 			ktime_t to = NSEC_PER_SEC / HZ;
 
 			set_current_state(TASK_UNINTERRUPTIBLE);
-			schedule_hrtimeout(&to, HRTIMER_MODE_REL);
+			schedule_hrtimeout(&to, HRTIMER_MODE_REL_HARD);
 			continue;
 		}
 

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

end of thread, other threads:[~2021-10-05 14:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26 17:04 [PATCH] sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD Sebastian Andrzej Siewior
2021-08-26 17:14 ` Peter Zijlstra
2021-09-09 11:18 ` [tip: sched/core] " tip-bot2 for Sebastian Andrzej Siewior
2021-10-05 14:12 ` tip-bot2 for Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).