From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: linux-ia64@vger.kernel.org
Subject: RE: Bug in ia64 specific down() function??
Date: Fri, 13 Jan 2006 22:26:54 +0000 [thread overview]
Message-ID: <200601132226.k0DMQsg04061@unix-os.sc.intel.com> (raw)
In-Reply-To: <200601120138.k0C1cEg03582@unix-os.sc.intel.com>
Zoltan Menyhart wrote on Friday, January 13, 2006 8:25 AM
> Chen, Kenneth W wrote:
> > The memory order semantics for include/asm-ia64/semaphore.h:down()
> > doesn't look right. It is using atomic_dec_return, which eventually
> > translate into ia64_fetch_and_add() that uses release semantics.
> > Shouldn't it use acquire semantics?
>
> What about this one:
>
> --- linux-2.6.15-test/include/asm-ia64/semaphore.h 2006-01-10 13:54:31.000000000 +0100
> +++ linux-2.6.15-test-down/include/asm-ia64/semaphore.h 2006-01-13 16:16:04.000000000 +0100
> @@ -61,7 +61,7 @@ down (struct semaphore * sem)
> down (struct semaphore *sem)
> {
> might_sleep();
> - if (atomic_dec_return(&sem->count) < 0)
> + if (ia64_fetchadd(-1, &sem->count.counter, acq) < 1)
> __down(sem);
> }
>
> @@ -75,7 +75,7 @@ down_interruptible (struct semaphore * sem)
> int ret = 0;
>
> might_sleep();
> - if (atomic_dec_return(&sem->count) < 0)
> + if (ia64_fetchadd(-1, &sem->count.counter, acq) < 1)
> ret = __down_interruptible(sem);
> return ret;
> }
> @@ -85,7 +85,7 @@ down_trylock (struct semaphore *sem)
> {
> int ret = 0;
>
> - if (atomic_dec_return(&sem->count) < 0)
> + if (ia64_fetchadd(-1, &sem->count.counter, acq) < 1)
> ret = __down_trylock(sem);
> return ret;
> }
> @@ -93,7 +93,7 @@ up (struct semaphore *sem)
> static inline void
> up (struct semaphore * sem)
> {
> - if (atomic_inc_return(&sem->count) <= 0)
> + if (ia64_fetchadd(1, &sem->count.counter, rel) <= -1)
> __up(sem);
> }
Yeah, looked OK to me.
- Ken
prev parent reply other threads:[~2006-01-13 22:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-12 1:38 Bug in ia64 specific down() function?? Chen, Kenneth W
2006-01-13 16:25 ` Zoltan Menyhart
2006-01-13 22:26 ` Chen, Kenneth W [this message]
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=200601132226.k0DMQsg04061@unix-os.sc.intel.com \
--to=kenneth.w.chen@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