LKML Archive on
help / color / mirror / Atom feed
* [PATCH RT] locking: Drop might_resched() from might_sleep_no_state_check()
@ 2021-09-06 16:19 Sebastian Andrzej Siewior
  0 siblings, 0 replies; only message in thread
From: Sebastian Andrzej Siewior @ 2021-09-06 16:19 UTC (permalink / raw)
  To: linux-kernel, linux-rt-users; +Cc: Steven Rostedt, Thomas Gleixner

might_sleep_no_state_check() serves the same purpose as might_sleep()
except it is used before sleeping locks are acquired and therefore does
not check task_struct::state because the state is preserved.

That state is preserved in the locking slow path so we must not schedule
at the begin of the locking function because the state will be lost and
not preserved at that time.

Remove might_resched() from might_sleep_no_state_check() to avoid losing the
state before it is preserved.

Signed-off-by: Sebastian Andrzej Siewior <>

After the locking rework, ___might_sleep() is used directly in
rt_spin_lock(), … so there is no might_sleep_no_state_check() macro
This applies to all RT trees.

 include/linux/kernel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2cff7554395d1..6eb0ab994f4c5 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -222,7 +222,7 @@ extern void __cant_migrate(const char *file, int line);
 	do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
 # define might_sleep_no_state_check() \
-	do { ___might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
+	do { ___might_sleep(__FILE__, __LINE__, 0); } while (0)
  * cant_sleep - annotation for functions that cannot sleep

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-06 16:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 16:19 [PATCH RT] locking: Drop might_resched() from might_sleep_no_state_check() 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).