2020-04-21 20:13:52 +00:00
|
|
|
From 9f5be54f1f4d5410605f14e2cfb080ac1dd4d31b Mon Sep 17 00:00:00 2001
|
2019-02-27 18:51:46 +00:00
|
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
Date: Tue, 26 Feb 2019 12:31:10 +0100
|
2020-04-21 20:13:52 +00:00
|
|
|
Subject: [PATCH 184/325] hrtimer: cpu_chill(): save task state in
|
2019-04-08 23:49:20 +00:00
|
|
|
->saved_state()
|
2020-04-21 20:13:52 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.115-rt48.tar.xz
|
2019-02-27 18:51:46 +00:00
|
|
|
|
|
|
|
In the previous change I saved the current task state on stack. This was
|
|
|
|
bad because while the task is scheduled-out it might receive a wake-up.
|
|
|
|
The wake up changes the task state and we must not destroy it.
|
|
|
|
|
|
|
|
Save the task-state in ->saved_state under a PI-lock to unsure that
|
|
|
|
state changes during are not missed while the task temporary scheduled
|
|
|
|
out.
|
|
|
|
|
|
|
|
Reported-by: Mike Galbraith <efault@gmx.de>
|
|
|
|
Tested-by: Mike Galbraith <efault@gmx.de>
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
kernel/time/hrtimer.c | 18 +++++++++++++-----
|
2019-02-27 18:51:46 +00:00
|
|
|
1 file changed, 13 insertions(+), 5 deletions(-)
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
|
2020-01-19 00:54:59 +00:00
|
|
|
index 21a454557c8a..f16cbc98c47a 100644
|
2019-02-27 18:51:46 +00:00
|
|
|
--- a/kernel/time/hrtimer.c
|
|
|
|
+++ b/kernel/time/hrtimer.c
|
2020-01-19 00:54:59 +00:00
|
|
|
@@ -1903,20 +1903,28 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
|
2019-02-27 18:51:46 +00:00
|
|
|
*/
|
|
|
|
void cpu_chill(void)
|
|
|
|
{
|
|
|
|
- ktime_t chill_time;
|
|
|
|
unsigned int freeze_flag = current->flags & PF_NOFREEZE;
|
|
|
|
- long saved_state;
|
|
|
|
+ struct task_struct *self = current;
|
|
|
|
+ ktime_t chill_time;
|
|
|
|
|
|
|
|
- saved_state = current->state;
|
|
|
|
- chill_time = ktime_set(0, NSEC_PER_MSEC);
|
|
|
|
+ raw_spin_lock_irq(&self->pi_lock);
|
|
|
|
+ self->saved_state = self->state;
|
|
|
|
__set_current_state_no_track(TASK_UNINTERRUPTIBLE);
|
|
|
|
+ raw_spin_unlock_irq(&self->pi_lock);
|
|
|
|
+
|
|
|
|
+ chill_time = ktime_set(0, NSEC_PER_MSEC);
|
|
|
|
+
|
|
|
|
current->flags |= PF_NOFREEZE;
|
|
|
|
sleeping_lock_inc();
|
|
|
|
schedule_hrtimeout(&chill_time, HRTIMER_MODE_REL_HARD);
|
|
|
|
sleeping_lock_dec();
|
|
|
|
if (!freeze_flag)
|
|
|
|
current->flags &= ~PF_NOFREEZE;
|
|
|
|
- __set_current_state_no_track(saved_state);
|
|
|
|
+
|
|
|
|
+ raw_spin_lock_irq(&self->pi_lock);
|
|
|
|
+ __set_current_state_no_track(self->saved_state);
|
|
|
|
+ self->saved_state = TASK_RUNNING;
|
|
|
|
+ raw_spin_unlock_irq(&self->pi_lock);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(cpu_chill);
|
|
|
|
#endif
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-04-09 19:44:24 +00:00
|
|
|
2.25.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|