* gscope + private_futex for alpha
@ 2007-05-25 0:35 Richard Henderson
2007-05-25 2:26 ` Ulrich Drepper
0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2007-05-25 0:35 UTC (permalink / raw)
To: libc-hacker
It seems like much of this same code could be shared with all
of the targets, particularly those that define TLS_DTV_AT_TP.
r~
2007-05-24 Richard Henderson <rth@redhat.com>
* descr.h (struct pthread): Add header.gscope_flag and
header.private_futex.
* nptl/sysdeps/alpha/tls.h (THREAD_GSCOPE_FLAG_UNUSED): New.
(THREAD_GSCOPE_FLAG_USED, THREAD_GSCOPE_FLAG_WAIT): New.
(THREAD_GSCOPE_RESET_FLAG, THREAD_GSCOPE_SET_FLAG): New.
(THREAD_GSCOPE_WAIT): New.
* nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h
(FUTEX_PRIVATE_FLAG): New.
(lll_futex_wait_flags): New.
* nptl/sysdeps/unix/sysv/linux/alpha/pthread_once.c (__pthread_once):
Pass FUTEX_PRIVATE_FLAG or header.private_futex down to the
futex call.
Index: nptl/descr.h
===================================================================
RCS file: /cvs/glibc/libc/nptl/descr.h,v
retrieving revision 1.39
diff -u -p -d -r1.39 descr.h
--- nptl/descr.h 11 May 2007 06:11:48 -0000 1.39
+++ nptl/descr.h 24 May 2007 23:49:08 -0000
@@ -131,6 +131,8 @@ struct pthread
struct
{
int multiple_threads;
+ int gscope_flag;
+ int private_futex;
} header;
#endif
Index: nptl/sysdeps/alpha/tls.h
===================================================================
RCS file: /cvs/glibc/libc/nptl/sysdeps/alpha/tls.h,v
retrieving revision 1.7
diff -u -p -d -r1.7 tls.h
--- nptl/sysdeps/alpha/tls.h 27 Oct 2006 23:11:43 -0000 1.7
+++ nptl/sysdeps/alpha/tls.h 24 May 2007 23:49:08 -0000
@@ -121,6 +121,36 @@ typedef struct
#define THREAD_SETMEM_NC(descr, member, idx, value) \
descr->member[idx] = (value)
+/* Get and set the global scope generation counter in the TCB head. */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED 1
+#define THREAD_GSCOPE_FLAG_WAIT 2
+
+#define THREAD_GSCOPE_RESET_FLAG() \
+ do { \
+ int __res = atomic_exchange_rel(&THREAD_SELF->header.gscope_flag, \
+ THREAD_GSCOPE_FLAG_UNUSED); \
+ if (__res == THREAD_GSCOPE_FLAG_WAIT) \
+ lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1); \
+ } while (0)
+
+#define THREAD_GSCOPE_SET_FLAG() \
+ do { \
+ THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED; \
+ __sync_synchronize (); \
+ } while (0)
+
+#ifdef PTR_DEMANGLE
+# define THREAD_GSCOPE_WAIT() \
+ do { \
+ void (*ptr)(void) = GL(dl_wait_lookup_done); \
+ PTR_DEMANGLE (ptr); \
+ ptr (); \
+ } while (0)
+#else
+# define THREAD_GSCOPE_WAIT() GL(dl_wait_lookup_done) ()
+#endif
+
#endif /* __ASSEMBLER__ */
#endif /* tls.h */
Index: nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h
===================================================================
RCS file: /cvs/glibc/libc/nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h,v
retrieving revision 1.8
diff -u -p -d -r1.8 lowlevellock.h
--- nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h 29 Jul 2006 05:06:07 -0000 1.8
+++ nptl/sysdeps/unix/sysv/linux/alpha/lowlevellock.h 24 May 2007 23:49:08 -0000
@@ -36,6 +36,7 @@
#define FUTEX_LOCK_PI 6
#define FUTEX_UNLOCK_PI 7
#define FUTEX_TRYLOCK_PI 8
+#define FUTEX_PRIVATE_FLAG 128
/* Initializer for compatibility lock. */
#define LLL_MUTEX_LOCK_INITIALIZER (0)
@@ -49,6 +50,15 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \
})
+#define lll_futex_wait_flags(futexp, val, flags) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex, __err, 4, \
+ (futexp), FUTEX_WAIT | (flags), (val), 0); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err)? -__ret : __ret; \
+ })
+
#define lll_futex_timed_wait(futexp, val, timespec) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
Index: nptl/sysdeps/unix/sysv/linux/alpha/pthread_once.c
===================================================================
RCS file: /cvs/glibc/libc/nptl/sysdeps/unix/sysv/linux/alpha/pthread_once.c,v
retrieving revision 1.2
diff -u -p -d -r1.2 pthread_once.c
--- nptl/sysdeps/unix/sysv/linux/alpha/pthread_once.c 8 Sep 2004 06:11:35 -0000 1.2
+++ nptl/sysdeps/unix/sysv/linux/alpha/pthread_once.c 24 May 2007 23:49:08 -0000
@@ -34,6 +34,12 @@ clear_once_control (void *arg)
int
__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
{
+#ifdef __ASSUME_PRIVATE_FUTEX
+ const int futex_private_flag = FUTEX_PRIVATE_FLAG;
+#else
+ const int futex_private_flag = THREAD_SELF->header.private_futex;
+#endif
+
for (;;)
{
int oldval;
@@ -72,7 +78,7 @@ __pthread_once (pthread_once_t *once_con
break;
/* Same generation, some other thread was faster. Wait. */
- lll_futex_wait (once_control, oldval);
+ lll_futex_wait_flags (once_control, oldval, futex_private_flag);
}
/* This thread is the first here. Do the initialization.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gscope + private_futex for alpha
2007-05-25 0:35 gscope + private_futex for alpha Richard Henderson
@ 2007-05-25 2:26 ` Ulrich Drepper
2007-05-25 17:40 ` Richard Henderson
0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Drepper @ 2007-05-25 2:26 UTC (permalink / raw)
To: libc-hacker
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Richard Henderson wrote:
> It seems like much of this same code could be shared with all
> of the targets, particularly those that define TLS_DTV_AT_TP.
Jakub has some patches which I haven't yet looked at.
> +#define lll_futex_wait_flags(futexp, val, flags) \
I don't think this is what I want to do. The reason is obvious from the
rest of your changes. Your pthread_once cannot work since the wake call
doesn't use the private flag the same way. If we'd introduce a new
macro like that we'd have a whole lot of places to inspect and debug.
I'm looking at the generic situation right soon since even x86-64 needs
it for mutexes etc. What I'll probably end up doing it extend the
existing macros. This way every usage has to be inspected.
- --
⧠Ulrich Drepper ⧠Red Hat, Inc. ⧠444 Castro St ⧠Mountain View, CA â
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFGVkkx2ijCOnn/RHQRAjF1AJ9nB9ANs7lbmoJSe0GqaweKjSz4fwCgwXI1
NZeymA0gWKSEHiutmRBry3k=
=Dr09
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gscope + private_futex for alpha
2007-05-25 2:26 ` Ulrich Drepper
@ 2007-05-25 17:40 ` Richard Henderson
2007-05-25 17:53 ` Ulrich Drepper
0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2007-05-25 17:40 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: libc-hacker
On Thu, May 24, 2007 at 07:25:53PM -0700, Ulrich Drepper wrote:
> > It seems like much of this same code could be shared with all
> > of the targets, particularly those that define TLS_DTV_AT_TP.
>
> Jakub has some patches which I haven't yet looked at.
Yeah, Jakub puts the flag in a ppc specific place. I thought it
used the same scheme as ia64 and alpha though, and it would seem
the common header would be ideal.
> I don't think this is what I want to do. The reason is obvious from the
> rest of your changes. Your pthread_once cannot work since the wake call
> doesn't use the private flag the same way.
Ah, I didn't realize this was a requirement. I've not yet
managed to boot a new kernel with this support present.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gscope + private_futex for alpha
2007-05-25 17:40 ` Richard Henderson
@ 2007-05-25 17:53 ` Ulrich Drepper
0 siblings, 0 replies; 4+ messages in thread
From: Ulrich Drepper @ 2007-05-25 17:53 UTC (permalink / raw)
To: Ulrich Drepper, libc-hacker
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Richard Henderson wrote:
> Yeah, Jakub puts the flag in a ppc specific place. I thought it
> used the same scheme as ia64 and alpha though, and it would seem
> the common header would be ideal.
It's really a toss up. Jakub mentioned that he thought your approach is
good. We'll see whether it's better in his opinion to warrant him
writing another patch.
- --
⧠Ulrich Drepper ⧠Red Hat, Inc. ⧠444 Castro St ⧠Mountain View, CA â
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFGVyKA2ijCOnn/RHQRAri8AJ9yyoFcDhQz62UXKQWPWhgiPrmXDACgmVwg
vkRl6gFBj8D1tlrf2TK2tyQ=
=/eVj
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-05-25 17:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-25 0:35 gscope + private_futex for alpha Richard Henderson
2007-05-25 2:26 ` Ulrich Drepper
2007-05-25 17:40 ` Richard Henderson
2007-05-25 17:53 ` Ulrich Drepper
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 read-only IMAP folder(s) and NNTP newsgroup(s).