From: Harvey Harrison <harvey.harrison@gmail.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: linux-kernel@vger.kernel.org, sfr@canb.auug.org.au,
lenb@kernel.org, dhowells@redhat.com, peterz@infradead.org,
mingo@elte.hu
Subject: Re: Updated generic semaphore patch set
Date: Fri, 14 Mar 2008 14:23:33 -0700 [thread overview]
Message-ID: <1205529813.27712.15.camel@brick> (raw)
In-Reply-To: <20080314204248.GV613@parisc-linux.org>
From: Harvey Harrison <harvey.harrison@gmail.com>
Subject: [PATCH] semaphore: add stubs for kerneldoc to semphore functions
The difference between down/down_trylock/down_interruptable/down_killable
should be expanded to note the difference/use case, a simple stub is added here.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
This applies on top of the last patch I sent, feel free to just use it as
a base for a fuller version.
kernel/semaphore.c | 37 ++++++++++++++++++++++++++++++++++---
1 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/kernel/semaphore.c b/kernel/semaphore.c
index bae1017..f48ac5e 100644
--- a/kernel/semaphore.c
+++ b/kernel/semaphore.c
@@ -98,6 +98,12 @@ static noinline void __sched __up(struct semaphore *sem)
wake_up_process(waiter->task);
}
+/**
+ * down - acquire the semaphore
+ * @sem: the semaphore to be acquired
+ *
+ * This can be called from interrupt context, unlike mutexes.
+ */
void down(struct semaphore *sem)
{
unsigned long flags;
@@ -111,6 +117,12 @@ void down(struct semaphore *sem)
}
EXPORT_SYMBOL(down);
+/**
+ * down_killable - try to acquire the semaphore
+ * @sem: the semaphore to be acquired
+ *
+ * This can be called from interrupt context, unlike mutexes.
+ */
int down_interruptible(struct semaphore *sem)
{
unsigned long flags;
@@ -127,6 +139,12 @@ int down_interruptible(struct semaphore *sem)
}
EXPORT_SYMBOL(down_interruptible);
+/**
+ * down_killable - try to acquire the semaphore
+ * @sem: the semaphore to be acquired
+ *
+ * This can be called from interrupt context, unlike mutexes.
+ */
int down_killable(struct semaphore *sem)
{
unsigned long flags;
@@ -147,7 +165,7 @@ EXPORT_SYMBOL(down_killable);
* down_trylock - try to acquire the semaphore, without waiting
* @sem: the semaphore to be acquired
*
- * Try to acquire the semaphore atomically. Returns 0 if the mutex has
+ * Try to acquire the semaphore atomically. Returns 0 if the semaphore has
* been acquired successfully and 1 if it is contended.
*
* NOTE: This return value is inverted from both spin_trylock and
@@ -171,7 +189,14 @@ int down_trylock(struct semaphore *sem)
}
EXPORT_SYMBOL(down_trylock);
-int down_timeout(struct semaphore *sem, long jiffies)
+/**
+ * down_timeout - try to acquire the semaphore within a timeout
+ * @sem: the semaphore to be acquired
+ * @timeout: the length to wait before timing out, in jiffies
+ *
+ * This can be called from interrupt context, unlike mutexes.
+ */
+int down_timeout(struct semaphore *sem, long timeout)
{
unsigned long flags;
int result = 0;
@@ -180,13 +205,19 @@ int down_timeout(struct semaphore *sem, long jiffies)
if (likely(sem->count > 0))
sem->count--;
else
- result = __down_timeout(sem, jiffies);
+ result = __down_timeout(sem, timeout);
spin_unlock_irqrestore(&sem->lock, flags);
return result;
}
EXPORT_SYMBOL(down_timeout);
+/**
+ * up - release the semaphore
+ * @sem: the semaphore to be released
+ *
+ * This can be called from interrupt context, unlike mutexes.
+ */
void up(struct semaphore *sem)
{
unsigned long flags;
--
1.5.4.4.684.g0e08
next prev parent reply other threads:[~2008-03-14 21:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-14 20:42 Updated generic semaphore patch set Matthew Wilcox
2008-03-14 20:44 ` [PATCH 1/6] Fix quota.h includes Matthew Wilcox
2008-03-14 20:44 ` [PATCH 2/6] Add semaphore.h to kernel_lock.c Matthew Wilcox
2008-03-14 20:44 ` [PATCH 3/6] Generic semaphore implementation Matthew Wilcox
2008-03-14 20:44 ` [PATCH 4/6] Introduce down_killable() Matthew Wilcox
2008-03-14 20:44 ` [PATCH 5/6] Add down_timeout and change ACPI to use it Matthew Wilcox
2008-03-14 20:44 ` [PATCH 6/6] Simplify semaphore implementation Matthew Wilcox
2008-03-14 20:59 ` Updated generic semaphore patch set Harvey Harrison
2008-03-14 21:23 ` Harvey Harrison [this message]
2008-03-14 23:37 ` Johannes Weiner
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=1205529813.27712.15.camel@brick \
--to=harvey.harrison@gmail.com \
--cc=dhowells@redhat.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=sfr@canb.auug.org.au \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox