All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Xiaoming Ni" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Xiaoming Ni <nixiaoming@huawei.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Will Deacon <will@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: locking/core] locking/semaphore: Add might_sleep() to down_*() family
Date: Mon, 23 Aug 2021 09:39:01 -0000	[thread overview]
Message-ID: <162971154151.25758.3817473813262421389.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210809021215.19991-1-nixiaoming@huawei.com>

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     99409b935c9ac5ea36ab5218954115c52449234d
Gitweb:        https://git.kernel.org/tip/99409b935c9ac5ea36ab5218954115c52449234d
Author:        Xiaoming Ni <nixiaoming@huawei.com>
AuthorDate:    Mon, 09 Aug 2021 10:12:15 +08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 20 Aug 2021 12:33:17 +02: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 <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
---
 kernel/locking/semaphore.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/locking/semaphore.c b/kernel/locking/semaphore.c
index 9aa855a..9ee381e 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--;

  parent reply	other threads:[~2021-08-23  9:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09  2:12 [PATCH] semaphore: Add might_sleep() to down_*() family Xiaoming Ni
2021-08-09  3:01 ` Waiman Long
2021-08-09  3:51   ` Xiaoming Ni
2021-08-09 12:52     ` Waiman Long
2021-08-09 14:33       ` Xiaoming Ni
2021-08-13 17:27   ` Thomas Gleixner
2021-08-13 18:47     ` Waiman Long
2021-08-13 14:43 ` Will Deacon
2021-08-23  9:39 ` tip-bot2 for Xiaoming Ni [this message]
2021-08-31 11:13 ` Guenter Roeck
2021-08-31 11:39   ` Hanjun Guo
2021-08-31 12:20     ` Thomas Gleixner
2021-08-31 11:40   ` Peter Zijlstra
2021-08-31 12:13   ` Thomas Gleixner
2021-08-31 12:34     ` Will Deacon
2021-08-31 17:42     ` Guenter Roeck
2021-09-01  8:37     ` [tip: smp/urgent] drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION() tip-bot2 for Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=162971154151.25758.3817473813262421389.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=nixiaoming@huawei.com \
    --cc=peterz@infradead.org \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.