Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1348215

[PATCH RT 04/20] preempt-lazy: Add the lazy-preemption check to preempt_schedule()

From Steven Rostedt <rostedt@goodmis.org>
Newsgroups linux.kernel
Subject [PATCH RT 04/20] preempt-lazy: Add the lazy-preemption check to preempt_schedule()
Date 2016-03-02 16:50 +0100
Message-ID <r8hch-1c4-77@gated-at.bofh.it> (permalink)
References <r8h2y-18n-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


3.18.27-rt27-rc1 stable review patch.
If anyone has any objections, please let me know.

------------------

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

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>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/sched/core.c | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9e01a8f358f8..8214206817f2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3164,6 +3164,30 @@ void __sched schedule_preempt_disabled(void)
 	preempt_disable();
 }
 
+#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
@@ -3178,15 +3202,9 @@ asmlinkage __visible void __sched notrace preempt_schedule(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_count_add(PREEMPT_ACTIVE);
 		/*
-- 
2.7.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RT 00/20] Linux 3.18.27-rt27-rc1 Steven Rostedt <rostedt@goodmis.org> - 2016-03-02 16:50 +0100
  [PATCH RT 12/20] tick/broadcast: Make broadcast hrtimer irqsafe Steven Rostedt <rostedt@goodmis.org> - 2016-03-02 16:50 +0100
  [PATCH RT 01/20] sched: reset tasks lockless wake-queues on fork() Steven Rostedt <rostedt@goodmis.org> - 2016-03-02 16:50 +0100
  [PATCH RT 04/20] preempt-lazy: Add the lazy-preemption check to preempt_schedule() Steven Rostedt <rostedt@goodmis.org> - 2016-03-02 16:50 +0100
  [PATCH RT 09/20] kernel: migrate_disable() do fastpath in atomic & irqs-off Steven Rostedt <rostedt@goodmis.org> - 2016-03-02 16:50 +0100

csiph-web