summaryrefslogtreecommitdiff
path: root/kernel/locking/semaphore.c
diff options
context:
space:
mode:
authorXiaoming Ni <nixiaoming@huawei.com>2021-08-09 05:12:15 +0300
committerPeter Zijlstra <peterz@infradead.org>2021-08-20 13:33:17 +0300
commit99409b935c9ac5ea36ab5218954115c52449234d (patch)
tree0f2769c63640eecc5f5fd236202b5eb2fdc2f38b /kernel/locking/semaphore.c
parentb857174e68e26f9c4f0796971e11eb63ad5a3eb6 (diff)
downloadlinux-99409b935c9ac5ea36ab5218954115c52449234d.tar.xz
locking/semaphore: Add might_sleep() to down_*() family
Semaphore is sleeping lock. Add might_sleep() to down*() family (with exception of down_trylock()) to detect atomic context sleep. Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20210809021215.19991-1-nixiaoming@huawei.com
Diffstat (limited to 'kernel/locking/semaphore.c')
-rw-r--r--kernel/locking/semaphore.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/locking/semaphore.c b/kernel/locking/semaphore.c
index 9aa855a96c4a..9ee381e4d2a4 100644
--- a/kernel/locking/semaphore.c
+++ b/kernel/locking/semaphore.c
@@ -54,6 +54,7 @@ void down(struct semaphore *sem)
{
unsigned long flags;
+ might_sleep();
raw_spin_lock_irqsave(&sem->lock, flags);
if (likely(sem->count > 0))
sem->count--;
@@ -77,6 +78,7 @@ int down_interruptible(struct semaphore *sem)
unsigned long flags;
int result = 0;
+ might_sleep();
raw_spin_lock_irqsave(&sem->lock, flags);
if (likely(sem->count > 0))
sem->count--;
@@ -103,6 +105,7 @@ int down_killable(struct semaphore *sem)
unsigned long flags;
int result = 0;
+ might_sleep();
raw_spin_lock_irqsave(&sem->lock, flags);
if (likely(sem->count > 0))
sem->count--;
@@ -157,6 +160,7 @@ int down_timeout(struct semaphore *sem, long timeout)
unsigned long flags;
int result = 0;
+ might_sleep();
raw_spin_lock_irqsave(&sem->lock, flags);
if (likely(sem->count > 0))
sem->count--;