diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2016-01-20 15:13:30 +0100 |
---|---|---|
committer | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2016-02-13 00:36:34 +0100 |
commit | 7755375254517e0ccc6e78195eecd2a69836f9d1 (patch) | |
tree | adb545347304344ea3193c845e0e8a2f93a602e9 | |
parent | c57b8cecdecb031896a75c5a5bfd97056d063deb (diff) | |
download | rt-linux-7755375254517e0ccc6e78195eecd2a69836f9d1.tar.gz |
preempt-lazy: Add the lazy-preemption check to preempt_schedule()
Probably in the rebase onto v4.1 this check got moved into less commonly used
preempt_schedule_notrace(). This patch ensures that both functions use it.
Reported-by: Mike Galbraith <umgwanakikbuti@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-rw-r--r-- | kernel/sched/core.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c4b0d6fdaa212..39f2bb5112146 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3460,6 +3460,30 @@ static void __sched notrace preempt_schedule_common(void) } while (need_resched()); } +#ifdef CONFIG_PREEMPT_LAZY +/* + * If TIF_NEED_RESCHED is then we allow to be scheduled away since this is + * set by a RT task. Oterwise we try to avoid beeing scheduled out as long as + * preempt_lazy_count counter >0. + */ +static int preemptible_lazy(void) +{ + if (test_thread_flag(TIF_NEED_RESCHED)) + return 1; + if (current_thread_info()->preempt_lazy_count) + return 0; + return 1; +} + +#else + +static int preemptible_lazy(void) +{ + return 1; +} + +#endif + #ifdef CONFIG_PREEMPT /* * this is the entry point to schedule() from in-kernel preemption @@ -3474,6 +3498,8 @@ asmlinkage __visible void __sched notrace preempt_schedule(void) */ if (likely(!preemptible())) return; + if (!preemptible_lazy()) + return; preempt_schedule_common(); } @@ -3500,15 +3526,9 @@ asmlinkage __visible void __sched notrace preempt_schedule_notrace(void) if (likely(!preemptible())) return; - -#ifdef CONFIG_PREEMPT_LAZY - /* - * Check for lazy preemption - */ - if (current_thread_info()->preempt_lazy_count && - !test_thread_flag(TIF_NEED_RESCHED)) + if (!preemptible_lazy()) return; -#endif + do { preempt_disable_notrace(); /* |