From: Geoff Keating <geoffk@cygnus.com>
To: dje@watson.ibm.com
Cc: drow@false.org, linuxppc-dev@lists.linuxppc.org,
libc-alpha@sourceware.cygnus.com
Subject: Re: DB_THREAD support in Berkeley DB/glibc
Date: Tue, 28 Dec 1999 15:52:47 -0800 [thread overview]
Message-ID: <199912282352.PAA11865@localhost.cygnus.com> (raw)
In-Reply-To: <199912282228.RAA25934@mal-ach.watson.ibm.com> (message from David Edelsohn on Tue, 28 Dec 1999 17:28:23 -0500)
> Date: Tue, 28 Dec 1999 17:28:23 -0500
> From: David Edelsohn <dje@watson.ibm.com>
>
> The TSL_UNSET still does not look sufficient to me. It needs to
> use lwarx/stwcx as well:
>
> #define TSL_UNSET(tsl) ({
> register tsl_t *__l = (tsl);
> register tsl_t __r1;
> __asm__ __volatile__ ("
> sync
> 10: lwarx %0,0,%1
> stwcx. %2,0,%1
> bne- 10b
> isync"
> : "=&r" (__r1) : "r" (__l), "r" (0));
> })
>
> As I mentioned privately to David Huggins-Daines, the order I normally use
> is: 1) sync, 2) perform the atomic update, 3) isync. This ensures that
> the cached copy of the memory location is consistent, performs the update,
> and the ensures that no later instructions which depend on the atomicity
> are moved ahead of the atomic operation. I am not sure how that maps to
> the Alpha "memory barrier" instruction as I have seen some discussion
> about it on the Linux/PPC mailinglists in the past. As long as all
> threads using the macro sync first, there is should be no need to sync
> after.
Hmmm.
I'm pretty sure the loop and lwarx/stwcx pair are unnecessary. Stores
on ppc are atomic, and we're not taking any action based on the
previous value, so we can just use a normal store. The store will
clear any reservations, although in the context of this code it
doesn't matter (because presumably only one thread will be unsetting
the lock).
Again, '__volatile__' does not imply a memory clobber, so we want to
do that instead.
We don't need 'isync', 'sync' will do just fine, and is faster. We
are only concerned here with memory coherency. In fact, 'isync' does
not imply 'sync' in a multiprocessor implementation; 'sync' does an
extra broadcast on the bus. The PowerPC User's Manual says
The sync instruction can be used to ensure that the result of all
stores into a data structure, performed in a "critical section" of a
program, are seen by other processors before the data structure is
seen as unlocked.
We probably want 'sync' before and after, although it's probable the
'after' is unnecessary.
--
- Geoffrey Keating <geoffk@cygnus.com>
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next prev parent reply other threads:[~1999-12-28 23:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-12-27 3:04 DB_THREAD support in Berkeley DB/glibc Troy Benjegerdes
1999-12-28 7:59 ` Daniel Jacobowitz
1999-12-28 17:53 ` Joel Klecker
1999-12-28 19:02 ` David Edelsohn
1999-12-28 21:22 ` BenH
1999-12-28 22:05 ` Daniel Jacobowitz
1999-12-28 22:28 ` David Edelsohn
1999-12-28 23:21 ` Tony Mantler
1999-12-29 0:15 ` David Edelsohn
1999-12-29 0:54 ` Geoff Keating
1999-12-29 1:01 ` David Edelsohn
1999-12-28 23:52 ` Geoff Keating [this message]
1999-12-29 0:21 ` David Edelsohn
-- strict thread matches above, loose matches on Subject: below --
1999-05-10 23:59 imac of booting Ben Martz
1999-05-11 8:36 ` Joel Klecker
1999-05-11 15:22 ` David Edelsohn
1999-05-11 16:47 ` Geert Uytterhoeven
1999-05-11 17:44 ` Anyone playing with Darwin 0.2 binary yet? Kevin B. Hendricks
1999-05-11 18:47 ` Nathan Ingersoll
1999-05-11 21:00 ` Roger Ivie
1999-05-11 22:15 ` David A. Gatwood
[not found] ` <v04011701b35e71c158ed@[199.174.98.46]>
1999-05-12 14:50 ` New PPC/Mac features of 2.2.8? Jason Haas
1999-05-12 18:21 ` Matt Porter
1999-05-12 19:41 ` Tom Rini
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=199912282352.PAA11865@localhost.cygnus.com \
--to=geoffk@cygnus.com \
--cc=dje@watson.ibm.com \
--cc=drow@false.org \
--cc=libc-alpha@sourceware.cygnus.com \
--cc=linuxppc-dev@lists.linuxppc.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;
as well as URLs for NNTP newsgroup(s).