From: Paul Mundt <lethal@linux-sh.org>
To: Hirokazu Takata <takata@linux-m32r.org>
Cc: Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org, Matthew Wilcox <matthew@wil.cx>,
linux-arch@vger.kernel.org
Subject: Re: [PATCH] m32r: Revise __raw_read_trylock()
Date: Fri, 22 Sep 2006 16:48:13 +0900 [thread overview]
Message-ID: <20060922074813.GA20921@localhost.Internal.Linux-SH.ORG> (raw)
In-Reply-To: <swfzmcse7mm.wl%takata@linux-m32r.org>
On Fri, Sep 22, 2006 at 03:29:53PM +0900, Hirokazu Takata wrote:
> Matthew Wilcox pointed out that generic__raw_read_trylock() is
> unfit for use.
>
> Here is a patch to fix __raw_read_trylock() for m32r.
> It is taken from the i386 implementation.
>
This might be a stupid question, but why exactly are we ripping out
generic__raw_read_trylock() if architectures are going to implement a
generic implementation anyways, rather than just changing it to match
the proper semantics?
With this the m32r patch can be dropped and the rest of the
architectures can switch over as necessary to optimized versions, rather
than being fundamentally broken.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
--
include/asm-i386/spinlock.h | 10 +---------
kernel/spinlock.c | 9 +++++++--
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/include/asm-i386/spinlock.h b/include/asm-i386/spinlock.h
index d102036..2aba6b3 100644
--- a/include/asm-i386/spinlock.h
+++ b/include/asm-i386/spinlock.h
@@ -169,15 +169,7 @@ static inline void __raw_write_lock(raw_
__build_write_lock(rw, "__write_lock_failed");
}
-static inline int __raw_read_trylock(raw_rwlock_t *lock)
-{
- atomic_t *count = (atomic_t *)lock;
- atomic_dec(count);
- if (atomic_read(count) >= 0)
- return 1;
- atomic_inc(count);
- return 0;
-}
+#define __raw_read_trylock(lock) generic__raw_read_trylock(lock)
static inline int __raw_write_trylock(raw_rwlock_t *lock)
{
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index fb524b0..8d50b9d 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -15,6 +15,7 @@ #include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/debug_locks.h>
#include <linux/module.h>
+#include <asm/atomic.h>
/*
* Generic declaration of the raw read_trylock() function,
@@ -22,8 +23,12 @@ #include <linux/module.h>
*/
int __lockfunc generic__raw_read_trylock(raw_rwlock_t *lock)
{
- __raw_read_lock(lock);
- return 1;
+ atomic_t *count = (atomic_t *)lock;
+ atomic_dec(count);
+ if (atomic_read(count) >= 0)
+ return 1;
+ atomic_inc(count);
+ return 0;
}
EXPORT_SYMBOL(generic__raw_read_trylock);
next prev parent reply other threads:[~2006-09-22 7:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-22 6:29 [PATCH] m32r: Revise __raw_read_trylock() Hirokazu Takata
2006-09-22 7:48 ` Paul Mundt [this message]
2006-09-22 11:27 ` Matthew Wilcox
2006-09-25 6:09 ` Paul Mundt
2006-09-24 6:20 ` Matthew Wilcox
2006-09-25 7:47 ` Hirokazu Takata
2006-09-26 21:33 ` Andrew Morton
2006-09-26 22:29 ` Matthew Wilcox
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=20060922074813.GA20921@localhost.Internal.Linux-SH.ORG \
--to=lethal@linux-sh.org \
--cc=akpm@osdl.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=takata@linux-m32r.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox