From: Zou Nan hai <nanhai.zou@intel.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [patch 2.6.15-rc5] Define an ia64 version of __raw_read_trylock
Date: Mon, 12 Dec 2005 06:16:29 +0000 [thread overview]
Message-ID: <1134368188.3560.11.camel@linux-znh> (raw)
In-Reply-To: <17916.1134185068@ocs3.ocs.com.au>
On Sat, 2005-12-10 at 11:24, Keith Owens wrote:
> IA64 is using the generic version of __raw_read_trylock, which always
> waits for the lock to be free instead of returning when the lock is in
> use. Define an ia64 version of __raw_read_trylock which behaves
> correctly, and drop the generic one.
>
> Signed-off-by: Keith Owens <kaos@sgi.com>
>
> Index: linux/include/asm-ia64/spinlock.h
> =================================> --- linux.orig/include/asm-ia64/spinlock.h 2005-12-09
> 14:44:56.883252331 +1100
> +++ linux/include/asm-ia64/spinlock.h 2005-12-10 14:20:44.459423430
> +1100
> @@ -201,6 +201,16 @@ static inline void __raw_write_unlock(ra
>
> #endif /* !ASM_SUPPORTED */
>
> -#define __raw_read_trylock(lock) generic__raw_read_trylock(lock)
> +static inline int __raw_read_trylock(raw_rwlock_t *x)
> +{
> + union {
> + raw_rwlock_t lock;
> + __u32 word;
> + } old, new;
> + old.lock = new.lock = *x;
> + old.lock.write_lock = new.lock.write_lock = 0;
> + ++new.lock.read_counter;
> + return (u32)ia64_cmpxchg4_acq((__u32 *)(x), new.word,
> old.word) = old.word;
> +}
>
> #endif /* _ASM_IA64_SPINLOCK_H */
>
How about using fetchadd4.acq 1 in trylock and rollback by fetchadd4.rel -1 if lock failed,
just like how __raw_read_lock does?
That should emit fewer code and give no extra memory foot print I think.
Zou Nan hai
next prev parent reply other threads:[~2005-12-12 6:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-10 3:24 [patch 2.6.15-rc5] Define an ia64 version of __raw_read_trylock Keith Owens
2005-12-12 2:34 ` Luck, Tony
2005-12-12 3:04 ` Keith Owens
2005-12-12 6:16 ` Zou Nan hai [this message]
2005-12-12 13:20 ` Keith Owens
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=1134368188.3560.11.camel@linux-znh \
--to=nanhai.zou@intel.com \
--cc=linux-ia64@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox