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


Groups > linux.kernel > #1489650 > unrolled thread

[PATCH RT 08/10] x86/preempt-lazy: fixup should_resched()

Started bySteven Rostedt <rostedt@goodmis.org>
First post2016-09-23 01:20 +0200
Last post2016-09-23 01:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH RT 08/10] x86/preempt-lazy: fixup should_resched() Steven Rostedt <rostedt@goodmis.org> - 2016-09-23 01:20 +0200

#1489650 — [PATCH RT 08/10] x86/preempt-lazy: fixup should_resched()

FromSteven Rostedt <rostedt@goodmis.org>
Date2016-09-23 01:20 +0200
Subject[PATCH RT 08/10] x86/preempt-lazy: fixup should_resched()
Message-ID<sklrA-4iR-17@gated-at.bofh.it>
3.18.42-rt45-rc1 stable review patch.
If anyone has any objections, please let me know.

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

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

should_resched() returns true if NEED_RESCHED is set and the
preempt_count is 0 _or_ if NEED_RESCHED_LAZY is set ignoring the preempt
counter. Ignoring the preemp counter is wrong. This patch adds this into
account.
While at it, __preempt_count_dec_and_test() ignores preempt_lazy_count
while checking TIF_NEED_RESCHED_LAZY so we this check, too.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 arch/x86/include/asm/preempt.h | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
index 060d1b4e475d..6806369bddf5 100644
--- a/arch/x86/include/asm/preempt.h
+++ b/arch/x86/include/asm/preempt.h
@@ -95,6 +95,8 @@ static __always_inline bool __preempt_count_dec_and_test(void)
 	if (____preempt_count_dec_and_test())
 		return true;
 #ifdef CONFIG_PREEMPT_LAZY
+	if (current_thread_info()->preempt_lazy_count)
+		return false;
 	return test_thread_flag(TIF_NEED_RESCHED_LAZY);
 #else
 	return false;
@@ -107,8 +109,18 @@ static __always_inline bool __preempt_count_dec_and_test(void)
 static __always_inline bool should_resched(void)
 {
 #ifdef CONFIG_PREEMPT_LAZY
-	return unlikely(!raw_cpu_read_4(__preempt_count) || \
-			test_thread_flag(TIF_NEED_RESCHED_LAZY));
+	u32 tmp;
+
+	if (!raw_cpu_read_4(__preempt_count))
+		return true;
+
+	/* preempt count == 0 ? */
+	tmp &= ~PREEMPT_NEED_RESCHED;
+	if (tmp)
+		return false;
+	if (current_thread_info()->preempt_lazy_count)
+		return false;
+	return test_thread_flag(TIF_NEED_RESCHED_LAZY);
 #else
 	return unlikely(!raw_cpu_read_4(__preempt_count));
 #endif
-- 
2.8.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web