|
Davidlohr Bueso |
a6825c |
From 7b5ff4bb9adc53cfbf7ac9ba7820ccf0cd7c070a Mon Sep 17 00:00:00 2001
|
|
Davidlohr Bueso |
a6825c |
From: Thomas Gleixner <tglx@linutronix.de>
|
|
Davidlohr Bueso |
a6825c |
Date: Thu, 23 Sep 2021 18:54:37 +0200
|
|
Davidlohr Bueso |
a6825c |
Subject: [PATCH] sched: Make cond_resched_*lock() variants consistent vs. might_sleep()
|
|
Davidlohr Bueso |
a6825c |
Git-commit: 7b5ff4bb9adc53cfbf7ac9ba7820ccf0cd7c070a
|
|
Davidlohr Bueso |
a6825c |
Patch-mainline: v5.16-rc1
|
|
Davidlohr Bueso |
a6825c |
References: bsc#1190137 bsc#1189998
|
|
Davidlohr Bueso |
a6825c |
|
|
Davidlohr Bueso |
a6825c |
Commit 3427445afd26 ("sched: Exclude cond_resched() from nested sleep
|
|
Davidlohr Bueso |
a6825c |
test") removed the task state check of __might_sleep() for
|
|
Davidlohr Bueso |
a6825c |
cond_resched_lock() because cond_resched_lock() is not a voluntary
|
|
Davidlohr Bueso |
a6825c |
scheduling point which blocks. It's a preemption point which requires the
|
|
Davidlohr Bueso |
a6825c |
lock holder to release the spin lock.
|
|
Davidlohr Bueso |
a6825c |
|
|
Davidlohr Bueso |
a6825c |
The same rationale applies to cond_resched_rwlock_read/write(), but those
|
|
Davidlohr Bueso |
a6825c |
were not touched.
|
|
Davidlohr Bueso |
a6825c |
|
|
Davidlohr Bueso |
a6825c |
Make it consistent and use the non-state checking __might_resched() there
|
|
Davidlohr Bueso |
a6825c |
as well.
|
|
Davidlohr Bueso |
a6825c |
|
|
Davidlohr Bueso |
a6825c |
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
|
|
Davidlohr Bueso |
a6825c |
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
|
|
Davidlohr Bueso |
a6825c |
Link: https://lkml.kernel.org/r/20210923165357.991262778@linutronix.de
|
|
Davidlohr Bueso |
a6825c |
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
|
|
Davidlohr Bueso |
a6825c |
|
|
Davidlohr Bueso |
a6825c |
---
|
|
Davidlohr Bueso |
a6825c |
include/linux/sched.h | 12 ++++++------
|
|
Davidlohr Bueso |
a6825c |
1 file changed, 6 insertions(+), 6 deletions(-)
|
|
Davidlohr Bueso |
a6825c |
|
|
Davidlohr Bueso |
a6825c |
diff --git a/include/linux/sched.h b/include/linux/sched.h
|
|
Davidlohr Bueso |
a6825c |
index b38f002334d5..7a989f2487f8 100644
|
|
Davidlohr Bueso |
a6825c |
--- a/include/linux/sched.h
|
|
Davidlohr Bueso |
a6825c |
+++ b/include/linux/sched.h
|
|
Davidlohr Bueso |
a6825c |
@@ -2051,14 +2051,14 @@ extern int __cond_resched_rwlock_write(rwlock_t *lock);
|
|
Davidlohr Bueso |
a6825c |
__cond_resched_lock(lock); \
|
|
Davidlohr Bueso |
a6825c |
})
|
|
Davidlohr Bueso |
a6825c |
|
|
Davidlohr Bueso |
a6825c |
-#define cond_resched_rwlock_read(lock) ({ \
|
|
Davidlohr Bueso |
a6825c |
- __might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \
|
|
Davidlohr Bueso |
a6825c |
- __cond_resched_rwlock_read(lock); \
|
|
Davidlohr Bueso |
a6825c |
+#define cond_resched_rwlock_read(lock) ({ \
|
|
Davidlohr Bueso |
a6825c |
+ __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \
|
|
Davidlohr Bueso |
a6825c |
+ __cond_resched_rwlock_read(lock); \
|
|
Davidlohr Bueso |
a6825c |
})
|
|
Davidlohr Bueso |
a6825c |
|
|
Davidlohr Bueso |
a6825c |
-#define cond_resched_rwlock_write(lock) ({ \
|
|
Davidlohr Bueso |
a6825c |
- __might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \
|
|
Davidlohr Bueso |
a6825c |
- __cond_resched_rwlock_write(lock); \
|
|
Davidlohr Bueso |
a6825c |
+#define cond_resched_rwlock_write(lock) ({ \
|
|
Davidlohr Bueso |
a6825c |
+ __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \
|
|
Davidlohr Bueso |
a6825c |
+ __cond_resched_rwlock_write(lock); \
|
|
Davidlohr Bueso |
a6825c |
})
|
|
Davidlohr Bueso |
a6825c |
|
|
Davidlohr Bueso |
a6825c |
static inline void cond_resched_rcu(void)
|
|
Davidlohr Bueso |
a6825c |
--
|
|
Davidlohr Bueso |
a6825c |
2.26.2
|
|
Davidlohr Bueso |
a6825c |
|