mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-05 09:05:53 +01:00
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected]
This commit is contained in:
1 parent
b857174e68
commit
99409b935c
1 file changed
+4
@@ -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--;
|
||||
|
||||
Reference in new issue
Block a user