This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: __lll_mutex_unlock broken on IA64 with nptl?


I attached a possible (very minimally tested, untested in glibc) draft patch to atomic.h.  I ended up drastically simplifying the atomic_exchange implementation:

1) The split on sizeof (*mem) is redundant with similar code already in ia64intrin.h.  By using the ia64intrin.h code, we use a public interface instead of a gcc private one.

2) The explicit test on an unsupported size and abort() is not in ia64intrin.h.  But I took it out anyway, since it seems to be a mixed bag.  It catches some additional errors, but defers others to runtime.  It seems to me that if we really want it, it should be in ia64intrin.h, and probably only check for the size 1 and 2 cases.

3) I implicitly removed the conversion of the result to the correct type.  According to the PSABI (which actually seems to specify a source API here), this should be done by ia64intrin.h, but isn't.  If it's needed for glibc, it may need to be added back as a workaround for what appears to be a gcc bug.

I can add either of (2) or (3) back in, if you prefer.  If not, we should probably eventually simplify the rest of the file in a similar manner.

I tried both approaches for atomic_exchange_rel.  Especially on McKinley, David was right that just adding the barrier is faster.  Hence you only see the simple version.  (It's also a bit ugly to generate the other version, since the cmpxchg intrinsics like to generate a full barrier.)

Hans

> -----Original Message-----
> From: Ulrich Drepper [mailto:drepper@redhat.com]
> Sent: Friday, May 09, 2003 2:21 PM
> To: Boehm, Hans
> Cc: 'libc-alpha@sources.redhat.com'; 'Jakub Jelinek'; 'Ian Wienand';
> MOSBERGER, DAVID (HP-PaloAlto,unix3); 'Hans.Boehm@hp.com'
> Subject: Re: __lll_mutex_unlock broken on IA64 with nptl?
> 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> [Fold your lines, these hundreds-of-character lines are not nice.]
> 
> Boehm, Hans wrote:
> > AFAICT, the implementation of __lll_mutex_unlock and hence 
> pthread_mutex_unlock is currently broken on IA64.
> 
> Not unexpected.  Nobody cared to fix it yet, though.  The main problem
> is that atomic_exchange should really be atomic_exchange_acq and
> atomic_exchange_rel (just like the cmpxchg code).  Then the correct
> variant can be used in the right place.  For lll_mutex_unlock it would
> be atomic_exchange_rel.
> 
> So, if you provide an implementation for both atomic_exchange_acq (the
> current should be fine) and atomic_exchange_rel I'll put it in.  The
> _acq variant isn't currently used but still.  If implementing the _rel
> variant means adding a memory barrier, fine, let's just do it.
> 
> - -- 
> - --------------.                        ,-.            444 
> Castro Street
> Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 
> 94041 USA
> Red Hat         `--' drepper at redhat.com 
> `---------------------------
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
> 
> iD8DBQE+vBu32ijCOnn/RHQRAig0AJ9uQkMW34QjsW+P8Fq4201Tp/kUUwCfWd2Q
> t4ErA6GdkiFeXEvWxzVLN50=
> =LNck
> -----END PGP SIGNATURE-----
> 

Attachment: atomic.h.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]