From owner-freebsd-threads@FreeBSD.ORG Mon Aug 2 11:07:50 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8A54F16A4F6 for ; Mon, 2 Aug 2004 11:07:50 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 677C143D53 for ; Mon, 2 Aug 2004 11:07:50 +0000 (GMT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i72B7oHl009091 for ; Mon, 2 Aug 2004 11:07:50 GMT (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i72B7nOJ009085 for freebsd-threads@freebsd.org; Mon, 2 Aug 2004 11:07:49 GMT (envelope-from owner-bugmaster@freebsd.org) Date: Mon, 2 Aug 2004 11:07:49 GMT Message-Id: <200408021107.i72B7nOJ009085@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: freebsd-threads@FreeBSD.org Subject: Current problem reports assigned to you X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Aug 2004 11:07:50 -0000 Current FreeBSD problem reports Critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/06/13] kern/19247 threads uthread_sigaction.c does not do anything s [2004/03/15] kern/64313 threads FreeBSD (OpenBSD) pthread implicit set/un o [2004/04/22] threads/65883threads libkse's sigwait does not work after fork 3 problems total. Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/07/18] kern/20016 threads pthreads: Cannot set scheduling timer/Can o [2000/08/26] misc/20861 threads libc_r does not honor socket timeouts o [2001/01/20] bin/24472 threads libc_r does not honor SO_SNDTIMEO/SO_RCVT o [2001/01/25] bin/24632 threads libc_r delicate deviation from libc in ha o [2001/01/25] misc/24641 threads pthread_rwlock_rdlock can deadlock o [2001/11/26] bin/32295 threads pthread dont dequeue signals o [2002/02/01] i386/34536 threads accept() blocks other threads o [2002/05/25] kern/38549 threads the procces compiled whith pthread stoppe o [2002/06/27] threads/39922threads [PATCH?] Threaded applications executed w o [2002/08/04] misc/41331 threads Pthread library open sets O_NONBLOCK flag o [2003/03/02] threads/48856threads Setting SIGCHLD to SIG_IGN still leaves z o [2003/03/10] threads/49087threads Signals lost in programs linked with libc o [2003/05/08] threads/51949threads thread in accept cannot be cancelled 13 problems total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/05/26] misc/18824 threads gethostbyname is not thread safe o [2000/10/21] misc/22190 threads A threaded read(2) from a socketpair(2) f o [2001/09/09] threads/30464threads pthread mutex attributes -- pshared o [2002/05/02] threads/37676threads libc_r: msgsnd(), msgrcv(), pread(), pwri s [2002/07/16] threads/40671threads pthread_cancel doesn't remove thread from o [2004/07/13] threads/69020threads pthreads library leaks _gc_mutex 6 problems total. From owner-freebsd-threads@FreeBSD.ORG Mon Aug 2 14:55:50 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E5D216A4CF for ; Mon, 2 Aug 2004 14:55:50 +0000 (GMT) Received: from mx2.cryptopro.ru (mx2.cryptopro.ru [213.59.158.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 00A2E43D68 for ; Mon, 2 Aug 2004 14:55:45 +0000 (GMT) (envelope-from pooh@cryptopro.ru) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Date: Mon, 2 Aug 2004 18:55:38 +0400 Message-ID: <14716057441580428E48F1266386E0B38236F1@xfiles.cp.ru> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: EAGAIN with libc_r Thread-Index: AcR4oMWbeQ/e/RgiQC6WWlmSMqdIHA== From: =?koi8-r?B?8NXIwczY08vJyiDg0snKIOHOxNLFxdfJ3g==?= To: X-Mailman-Approved-At: Tue, 03 Aug 2004 15:06:18 +0000 Subject: EAGAIN with libc_r X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Aug 2004 14:55:50 -0000 Hello! I try to read data from /dev/fd0 and use code like: { char buf[512]; int fd=3Dopen("/dev/fd0",O_RDONLY); printf("%d ",fd); perror("open"); printf("%d ",read(fd,buf,512)); perror("read"); } When I compile it without threads, everything works ok. But when I try = to do "gcc -pthread ...", or "gcc ... -lc_r" it hangs on read. When I = call open() with O_NONBLOCK flag, I receive EAGAIN error on read(), = whatever command I use to compile, -lc_r or not. Apparently it's some = inner thing concerning floppy device? Please, help to clear the issue! Thank You in advance! From owner-freebsd-threads@FreeBSD.ORG Thu Aug 5 08:40:46 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 300CF16A4CE for ; Thu, 5 Aug 2004 08:40:46 +0000 (GMT) Received: from itchy.rabson.org (mailgate.nlsystems.com [80.177.232.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id B377343D2D for ; Thu, 5 Aug 2004 08:40:44 +0000 (GMT) (envelope-from dfr@nlsystems.com) Received: from ns0.nlsystems.com (ns0.nlsystems.com [80.177.232.243]) by itchy.rabson.org (8.12.11/8.12.11) with ESMTP id i758ed7Z025335 for ; Thu, 5 Aug 2004 09:40:39 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: freebsd-threads@freebsd.org Date: Thu, 5 Aug 2004 09:40:36 +0100 User-Agent: KMail/1.6.2 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <200408050940.36506.dfr@nlsystems.com> X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on itchy.rabson.org X-Virus-Scanned: clamd / ClamAV version 0.71, clamav-milter version 0.71 X-Virus-Status: Clean Subject: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 08:40:46 -0000 This is the current state of my patches to add TLS support to libpthread and libthr. I have added code for i386, amd64 and ia64 but I've only tested i386. I believe the code for amd64 is right. I don't much like what I've done to the ia64 version though. I would like to commit only the i386 version at this stage. The amd64 code could be committed if someone tests it. The current code in rtld for variant I TLS assumes that the size of the TCB is fixed at 2*sizeof(Elf_Addr). The original code in libpthread assumed that it was possible to extend that by allocating extra storage to live below the thread pointer. Since I don't support that in rtld, I've just allocated the extra space with malloc() and used the spare pointer in the architecturally defined TCB to point at it. This could be fixed in two ways. The first (which requires no changes to rtld) would be to add a '__thread struct tcp _pthread_tcb' variable and arrange for ia64_tp::tp_tcp to point at that in each thread. The advantage there is that rtld stays simple. The alternative is to change the semantics of _rtld_allocate_tls() for variant I to allow the caller to request a larger tcb size - it would allocate the extra space below the 16 byte architectural TCB. Trying out either of these will have to wait until I have time to fire up my horrible noisy old itanium1 system and update it to current. Index: libthr/arch/i386/i386/_curthread.S =================================================================== RCS file: /home/ncvs/src/lib/libthr/arch/i386/i386/_curthread.S,v retrieving revision 1.2 diff -u -r1.2 _curthread.S --- libthr/arch/i386/i386/_curthread.S 2 Jun 2003 02:32:56 -0000 1.2 +++ libthr/arch/i386/i386/_curthread.S 5 Aug 2004 08:17:40 -0000 @@ -5,7 +5,7 @@ ENTRY(_get_curthread) cmpl $0, _thread_initial je nothreads - movl %gs:0, %eax + movl %gs:8, %eax ret nothreads: xor %eax, %eax Index: libthr/arch/i386/i386/_setcurthread.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/arch/i386/i386/_setcurthread.c,v retrieving revision 1.13 diff -u -r1.13 _setcurthread.c --- libthr/arch/i386/i386/_setcurthread.c 5 Mar 2004 08:10:18 -0000 1.13 +++ libthr/arch/i386/i386/_setcurthread.c 5 Aug 2004 08:17:40 -0000 @@ -38,112 +38,67 @@ #include #include "thr_private.h" - -#define MAXTHR 8192 - -#define LDT_INDEX(x) (((long)(x) - (long)ldt_entries) / sizeof(ldt_entries[0])) - -void **ldt_free = NULL; -void *ldt_entries[MAXTHR]; -static int ldt_inited = 0; -static spinlock_t ldt_lock = _SPINLOCK_INITIALIZER; - -static void ldt_init(void); +#include "rtld_tls.h" /* in _curthread.S */ extern void _set_gs(int); -/* - * Initialize the array of ldt_entries and the next free slot. - * This routine must be called with the global ldt lock held. - */ -static void -ldt_init(void) -{ - int i; - - ldt_free = &ldt_entries[NLDT]; - - for (i = 0; i < MAXTHR - 1; i++) - ldt_entries[i] = (void *)&ldt_entries[i + 1]; - - ldt_entries[MAXTHR - 1] = NULL; - - ldt_inited = 1; -} +struct tcb { + struct tcb *tcb_self; /* required by rtld */ + void *tcb_dtv; /* required by rtld */ + struct pthread *tcb_thread; +}; void _retire_thread(void *entry) { - _spinlock(&ldt_lock); - if (ldt_free == NULL) - *(void **)entry = NULL; - else - *(void **)entry = *ldt_free; - ldt_free = entry; - _spinunlock(&ldt_lock); + _rtld_free_tls(entry, sizeof(struct tcb), 16); + /* XXX free ldt descriptor here */ } void * _set_curthread(ucontext_t *uc, struct pthread *thr, int *err) { union descriptor desc; - void **ldt_entry; + struct tcb *tcb; + void *oldtls; int ldt_index; *err = 0; - /* - * If we are setting up the initial thread, the gs register - * won't be setup for the current thread. In any case, we - * don't need protection from re-entrancy at this point in - * the life of the program. - */ - if (thr != _thread_initial) - _SPINLOCK(&ldt_lock); - - if (ldt_inited == 0) - ldt_init(); - - if (ldt_free == NULL) { - /* Concurrent thread limit reached */ - *err = curthread->error = EAGAIN; - if (thr != _thread_initial) - _SPINUNLOCK(&ldt_lock); - return (NULL); + if (uc == NULL) { + __asm __volatile("movl %%gs:0, %0" : "=r" (oldtls)); + } else { + oldtls = NULL; } /* - * Pull one off of the free list and update the free list pointer. + * Allocate and initialise a new TLS block with enough extra + * space for our self pointer. */ - ldt_entry = ldt_free; - ldt_free = (void **)*ldt_entry; - - if (thr != _thread_initial) - _SPINUNLOCK(&ldt_lock); + tcb = _rtld_allocate_tls(oldtls, sizeof(struct tcb), 16); /* - * Cache the address of the thread structure here. This is - * what the gs register will point to. + * Cache the address of the thread structure here, after + * rtld's two words of private space. */ - *ldt_entry = (void *)thr; + tcb->tcb_thread = thr; bzero(&desc, sizeof(desc)); /* - * Set up the descriptor to point into the ldt table which contains - * only a pointer to the thread. + * Set up the descriptor to point at the TLS block. */ - desc.sd.sd_lolimit = sizeof(*ldt_entry); - desc.sd.sd_lobase = (unsigned int)ldt_entry & 0xFFFFFF; - desc.sd.sd_type = SDT_MEMRO; + desc.sd.sd_lolimit = 0xFFFF; + desc.sd.sd_lobase = (unsigned int)tcb & 0xFFFFFF; + desc.sd.sd_type = SDT_MEMRW; desc.sd.sd_dpl = SEL_UPL; desc.sd.sd_p = 1; - desc.sd.sd_hilimit = 0; + desc.sd.sd_hilimit = 0xF; desc.sd.sd_xx = 0; desc.sd.sd_def32 = 1; - desc.sd.sd_gran = 0; - desc.sd.sd_hibase = (unsigned int)ldt_entry >> 24; + desc.sd.sd_gran = 1; + desc.sd.sd_hibase = (unsigned int)tcb >> 24; /* Get a slot from the process' LDT list */ ldt_index = i386_set_ldt(LDT_AUTO_ALLOC, &desc, 1); @@ -158,5 +113,5 @@ else _set_gs(LSEL(ldt_index, SEL_UPL)); - return (ldt_entry); + return (tcb); } Index: libthr/arch/ia64/ia64/_curthread.c =================================================================== RCS file: /home/ncvs/src/lib/libthr/arch/ia64/ia64/_curthread.c,v retrieving revision 1.3 diff -u -r1.3 _curthread.c --- libthr/arch/ia64/ia64/_curthread.c 25 May 2003 22:40:57 -0000 1.3 +++ libthr/arch/ia64/ia64/_curthread.c 5 Aug 2004 08:22:06 -0000 @@ -33,27 +33,38 @@ #include #include "thr_private.h" -register struct pthread *_tp __asm("%r13"); +struct tcb { + void *tcb_dtv; + struct pthread *tcb_thread; +}; + +register struct tcb *_tp __asm("%r13"); struct pthread * _get_curthread(void) { - return (_tp); + return (_tp->tcb_thread); } void _retire_thread(void *v) { + + _rtld_free_tls(v, sizeof(struct tcb), 16); } void * _set_curthread(ucontext_t *uc, struct pthread *thread, int *err) { + struct tcb *tcb; + + tcb = _rtld_allocate_tls(sizeof(struct tcb), 16); + tcb->tcb_thread = thread; *err = 0; if (uc != NULL) - uc->uc_mcontext.mc_special.tp = (uint64_t)thread; + uc->uc_mcontext.mc_special.tp = (uint64_t)tcb; else - _tp = thread; - return (NULL); + _tp = tcb; + return (tcb); } Index: libpthread/arch/amd64/amd64/pthread_md.c =================================================================== RCS file: /home/ncvs/src/lib/libpthread/arch/amd64/amd64/pthread_md.c,v retrieving revision 1.2 diff -u -r1.2 pthread_md.c --- libpthread/arch/amd64/amd64/pthread_md.c 12 Aug 2003 22:13:06 -0000 1.2 +++ libpthread/arch/amd64/amd64/pthread_md.c 5 Aug 2004 08:27:37 -0000 @@ -28,29 +28,37 @@ #include #include +#include "rtld_tls.h" #include "pthread_md.h" /* * The constructors. */ struct tcb * -_tcb_ctor(struct pthread *thread) +_tcb_ctor(struct pthread *thread, int initial) { struct tcb *tcb; + void *oldtls; - if ((tcb = malloc(sizeof(struct tcb))) != NULL) { - bzero(tcb, sizeof(struct tcb)); + if (initial) { + __asm __volatile("movq %%fs:0, %0" : "=r" (oldtls)); + } else { + oldtls = NULL; + } + + tcb = _rtld_allocate_tls(oldtls, sizeof(struct tcb), 16); + if (tcb) { tcb->tcb_thread = thread; - /* Allocate TDV */ + bzero(&tcb->tcb_tmbx, sizeof(tcb->tcb_tmbx)); } + return (tcb); } void _tcb_dtor(struct tcb *tcb) { - /* Free TDV */ - free(tcb); + _rtld_free_tls(tcb, sizeof(struct tcb), 16); } struct kcb * Index: libpthread/arch/amd64/include/pthread_md.h =================================================================== RCS file: /home/ncvs/src/lib/libpthread/arch/amd64/include/pthread_md.h,v retrieving revision 1.7 diff -u -r1.7 pthread_md.h --- libpthread/arch/amd64/include/pthread_md.h 31 Jul 2004 14:14:55 -0000 1.7 +++ libpthread/arch/amd64/include/pthread_md.h 5 Aug 2004 08:27:02 -0000 @@ -62,8 +62,10 @@ }; struct tcb { - struct tdv *tcb_tdv; + struct tcb *tcb_self; /* required by rtld */ + void *tcb_dtv; /* required by rtld */ struct pthread *tcb_thread; + void *tcb_spare[1]; /* align tcb_tmbx to 16 bytes */ struct kse_thr_mailbox tcb_tmbx; }; @@ -138,7 +140,7 @@ /* * The constructors. */ -struct tcb *_tcb_ctor(struct pthread *); +struct tcb *_tcb_ctor(struct pthread *, int); void _tcb_dtor(struct tcb *tcb); struct kcb *_kcb_ctor(struct kse *); void _kcb_dtor(struct kcb *); Index: libpthread/arch/i386/i386/pthread_md.c =================================================================== RCS file: /home/ncvs/src/lib/libpthread/arch/i386/i386/pthread_md.c,v retrieving revision 1.2 diff -u -r1.2 pthread_md.c --- libpthread/arch/i386/i386/pthread_md.c 5 Aug 2003 23:09:22 -0000 1.2 +++ libpthread/arch/i386/i386/pthread_md.c 5 Aug 2004 08:27:24 -0000 @@ -39,35 +39,35 @@ #include #include +#include "rtld_tls.h" #include "pthread_md.h" struct tcb * -_tcb_ctor(struct pthread *thread) +_tcb_ctor(struct pthread *thread, int initial) { struct tcb *tcb; - void *addr; + void *oldtls; - addr = malloc(sizeof(struct tcb) + 15); - if (addr == NULL) - tcb = NULL; - else { - tcb = (struct tcb *)(((uintptr_t)(addr) + 15) & ~15); - bzero(tcb, sizeof(struct tcb)); - tcb->tcb_addr = addr; + if (initial) { + __asm __volatile("movl %%gs:0, %0" : "=r" (oldtls)); + } else { + oldtls = NULL; + } + + tcb = _rtld_allocate_tls(oldtls, sizeof(struct tcb), 16); + if (tcb) { tcb->tcb_thread = thread; - /* XXX - Allocate tdv/tls */ + tcb->tcb_spare = 0; + bzero(&tcb->tcb_tmbx, sizeof(tcb->tcb_tmbx)); } + return (tcb); } void _tcb_dtor(struct tcb *tcb) { - void *addr; - - addr = tcb->tcb_addr; - tcb->tcb_addr = NULL; - free(addr); + _rtld_free_tls(tcb, sizeof(struct tcb), 16); } /* Index: libpthread/arch/i386/include/pthread_md.h =================================================================== RCS file: /home/ncvs/src/lib/libpthread/arch/i386/include/pthread_md.h,v retrieving revision 1.8 diff -u -r1.8 pthread_md.h --- libpthread/arch/i386/include/pthread_md.h 13 Jul 2004 22:54:23 -0000 1.8 +++ libpthread/arch/i386/include/pthread_md.h 5 Aug 2004 08:26:51 -0000 @@ -47,7 +47,6 @@ struct kse; struct pthread; -struct tdv; /* * %gs points to a struct kcb. @@ -61,9 +60,9 @@ }; struct tcb { - struct tdv *tcb_tdv; + struct tcb *tcb_self; /* required by rtld */ + void *tcb_dtv; /* required by rtld */ struct pthread *tcb_thread; - void *tcb_addr; /* allocated tcb address */ void *tcb_spare; /* align tcb_tmbx to 16 bytes */ struct kse_thr_mailbox tcb_tmbx; }; @@ -140,7 +139,7 @@ /* * The constructors. */ -struct tcb *_tcb_ctor(struct pthread *); +struct tcb *_tcb_ctor(struct pthread *, int); void _tcb_dtor(struct tcb *tcb); struct kcb *_kcb_ctor(struct kse *); void _kcb_dtor(struct kcb *); Index: libpthread/arch/ia64/ia64/pthread_md.c =================================================================== RCS file: /home/ncvs/src/lib/libpthread/arch/ia64/ia64/pthread_md.c,v retrieving revision 1.2 diff -u -r1.2 pthread_md.c --- libpthread/arch/ia64/ia64/pthread_md.c 6 Aug 2003 04:17:42 -0000 1.2 +++ libpthread/arch/ia64/ia64/pthread_md.c 5 Aug 2004 08:27:46 -0000 @@ -29,19 +29,25 @@ #include #include #include "pthread_md.h" +#include "rtld_tls.h" /* * The constructors. */ struct tcb * -_tcb_ctor(struct pthread *thread) +_tcb_ctor(struct pthread *thread, int initial) { - struct tcb *tcb; + struct ia64_tp *tp; + + tp = _rtld_allocate_tls(initial ? _tp : NULL, + sizeof(struct ia64_tp), 16); + if (tp == NULL) + return (NULL); if ((tcb = malloc(sizeof(struct tcb))) != NULL) { bzero(tcb, sizeof(struct tcb)); tcb->tcb_thread = thread; - /* Allocate TDV */ + tcb->tcb_tp = tp; } return (tcb); } @@ -49,7 +55,8 @@ void _tcb_dtor(struct tcb *tcb) { - /* Free TDV */ + + _rtld_free_tls(tcb->tcb_tp, sizeof(struct ia64_tp), 16); free(tcb); } Index: libpthread/arch/ia64/include/pthread_md.h =================================================================== RCS file: /home/ncvs/src/lib/libpthread/arch/ia64/include/pthread_md.h,v retrieving revision 1.13 diff -u -r1.13 pthread_md.h --- libpthread/arch/ia64/include/pthread_md.h 12 Jul 2004 07:41:01 -0000 1.13 +++ libpthread/arch/ia64/include/pthread_md.h 5 Aug 2004 08:27:08 -0000 @@ -44,19 +44,13 @@ struct kse; struct pthread; struct tcb; -struct tdv; /* We don't know what this is yet? */ /* - * tp points to one of these. We define the static TLS as an array - * of long double to enforce 16-byte alignment of the TLS memory, - * struct ia64_tp, struct tcb and also struct kcb. Both static and - * dynamic allocation of any of these structures will result in a - * valid, well-aligned thread pointer. + * tp points to one of these. */ struct ia64_tp { - struct tdv *tp_tdv; /* dynamic TLS */ - uint64_t _reserved_; - long double tp_tls[0]; /* static TLS */ + void *tp_dtv; /* required by rtld */ + struct tcb *tp_tcb; /* real tcb for thread */ }; struct tcb { @@ -64,7 +58,7 @@ struct pthread *tcb_thread; struct kcb *tcb_curkcb; long tcb_isfake; - struct ia64_tp tcb_tp; + struct ia64_tp *tcb_tp; }; struct kcb { @@ -76,12 +70,12 @@ register struct ia64_tp *_tp __asm("%r13"); -#define _tcb ((struct tcb*)((char*)(_tp) - offsetof(struct tcb, tcb_tp))) +#define _tcb (_tp->tp_tcb) /* * The kcb and tcb constructors. */ -struct tcb *_tcb_ctor(struct pthread *); +struct tcb *_tcb_ctor(struct pthread *, int); void _tcb_dtor(struct tcb *); struct kcb *_kcb_ctor(struct kse *kse); void _kcb_dtor(struct kcb *); @@ -90,8 +84,6 @@ static __inline void _kcb_set(struct kcb *kcb) { - /* There is no thread yet; use the fake tcb. */ - _tp = &kcb->kcb_faketcb.tcb_tp; } /* @@ -103,6 +95,7 @@ static __inline struct kcb * _kcb_get(void) { + return (_tcb->tcb_curkcb); } @@ -165,22 +158,25 @@ static __inline void _tcb_set(struct kcb *kcb, struct tcb *tcb) { + if (tcb == NULL) tcb = &kcb->kcb_faketcb; kcb->kcb_curtcb = tcb; tcb->tcb_curkcb = kcb; - _tp = &tcb->tcb_tp; + _tp = tcb->tcb_tp; } static __inline struct tcb * _tcb_get(void) { + return (_tcb); } static __inline struct pthread * _get_curthread(void) { + return (_tcb->tcb_thread); } @@ -204,6 +200,7 @@ static __inline int _thread_enter_uts(struct tcb *tcb, struct kcb *kcb) { + if (_ia64_save_context(&tcb->tcb_tmbx.tm_context.uc_mcontext) == 0) { /* Make the fake tcb the current thread. */ kcb->kcb_curtcb = &kcb->kcb_faketcb; Index: libpthread/thread/thr_kern.c =================================================================== RCS file: /home/ncvs/src/lib/libpthread/thread/thr_kern.c,v retrieving revision 1.108 diff -u -r1.108 thr_kern.c --- libpthread/thread/thr_kern.c 3 Aug 2004 02:22:25 -0000 1.108 +++ libpthread/thread/thr_kern.c 5 Aug 2004 08:29:54 -0000 @@ -2384,7 +2384,7 @@ if ((thread == NULL) && ((thread = malloc(sizeof(struct pthread))) != NULL)) { bzero(thread, sizeof(struct pthread)); - if ((thread->tcb = _tcb_ctor(thread)) == NULL) { + if ((thread->tcb = _tcb_ctor(thread, curthread == NULL)) == NULL) { free(thread); thread = NULL; } else { From owner-freebsd-threads@FreeBSD.ORG Thu Aug 5 14:45:16 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8255416A4CE for ; Thu, 5 Aug 2004 14:45:16 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F64E43D39; Thu, 5 Aug 2004 14:45:16 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from [127.0.0.1] (davidxu@localhost [127.0.0.1]) i75EjDGZ007970; Thu, 5 Aug 2004 14:45:15 GMT (envelope-from davidxu@freebsd.org) Message-ID: <411248DA.3080607@freebsd.org> Date: Thu, 05 Aug 2004 22:48:58 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.7.1) Gecko/20040730 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Doug Rabson References: <200408050940.36506.dfr@nlsystems.com> In-Reply-To: <200408050940.36506.dfr@nlsystems.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 14:45:16 -0000 This patch does not work for statically linked binary even if the binary does not use __thread, I think you still need to use malloc to allocate memory for tcb if it is being compiled as a static library. I have tested it on AMD64, dynamically linked binary works fine. David Xu Doug Rabson wrote: >This is the current state of my patches to add TLS support to libpthread >and libthr. I have added code for i386, amd64 and ia64 but I've only >tested i386. I believe the code for amd64 is right. I don't much like >what I've done to the ia64 version though. I would like to commit only >the i386 version at this stage. The amd64 code could be committed if >someone tests it. > > From owner-freebsd-threads@FreeBSD.ORG Thu Aug 5 14:53:59 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8BC7716A4CE; Thu, 5 Aug 2004 14:53:59 +0000 (GMT) Received: from itchy.rabson.org (mailgate.nlsystems.com [80.177.232.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id D322C43D54; Thu, 5 Aug 2004 14:53:58 +0000 (GMT) (envelope-from dfr@nlsystems.com) Received: from ns0.nlsystems.com (ns0.nlsystems.com [80.177.232.243]) by itchy.rabson.org (8.12.11/8.12.11) with ESMTP id i75Ertmw027989; Thu, 5 Aug 2004 15:53:55 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: David Xu Date: Thu, 5 Aug 2004 15:53:51 +0100 User-Agent: KMail/1.6.2 References: <200408050940.36506.dfr@nlsystems.com> <411248DA.3080607@freebsd.org> In-Reply-To: <411248DA.3080607@freebsd.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200408051553.51692.dfr@nlsystems.com> X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on itchy.rabson.org X-Virus-Scanned: clamd / ClamAV version 0.71, clamav-milter version 0.71 X-Virus-Status: Clean cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 14:53:59 -0000 I haven't tried to support static linked TLS at all. The plan is to get the kernel to size the TLS segment and add extra AUXARGs to report its size, initialiser location and alignment. The stubs in libc/gen/tls.c would be extended to provide support for allocating the TLS blocks in the static case. I was under the impression that no-one particularly wanted to support pthreads in statically linked binaries? On Thursday 05 August 2004 15:48, David Xu wrote: > This patch does not work for statically linked binary even if the > binary does > not use __thread, I think you still need to use malloc to allocate > memory for tcb if it is being compiled as a static library. > I have tested it on AMD64, dynamically linked binary works fine. > > David Xu > > Doug Rabson wrote: > >This is the current state of my patches to add TLS support to > > libpthread and libthr. I have added code for i386, amd64 and ia64 > > but I've only tested i386. I believe the code for amd64 is right. I > > don't much like what I've done to the ia64 version though. I would > > like to commit only the i386 version at this stage. The amd64 code > > could be committed if someone tests it. From owner-freebsd-threads@FreeBSD.ORG Thu Aug 5 15:06:13 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8AFF516A4CE; Thu, 5 Aug 2004 15:06:13 +0000 (GMT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4867A43D1D; Thu, 5 Aug 2004 15:06:13 +0000 (GMT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id i75F6C3w002131; Thu, 5 Aug 2004 11:06:12 -0400 (EDT) Date: Thu, 5 Aug 2004 11:06:12 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Doug Rabson In-Reply-To: <200408051553.51692.dfr@nlsystems.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: David Xu cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 15:06:13 -0000 On Thu, 5 Aug 2004, Doug Rabson wrote: > I haven't tried to support static linked TLS at all. The plan is to get > the kernel to size the TLS segment and add extra AUXARGs to report its > size, initialiser location and alignment. The stubs in libc/gen/tls.c > would be extended to provide support for allocating the TLS blocks in > the static case. > > I was under the impression that no-one particularly wanted to support > pthreads in statically linked binaries? The thread guys don't want to support static thread libraries ;-) But I proposed this a few months ago (year?) in -current and there was some reluctance. Imp was one that was against it (from what I can remember). The reason given was speed of static binaries is faster than dynamic. I didn't force the issue any more than that. That's how I recall it anyways. I'll have to search the list archives to see if I can find the thread. -- Dan Eischen From owner-freebsd-threads@FreeBSD.ORG Thu Aug 5 15:17:07 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5AA9916A4CF; Thu, 5 Aug 2004 15:17:07 +0000 (GMT) Received: from rms06.rommon.net (rms06.rommon.net [212.54.5.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 82D8B43D4C; Thu, 5 Aug 2004 15:17:06 +0000 (GMT) (envelope-from pete@he.iki.fi) Received: from [193.64.42.134] (h86.vuokselantie10.fi [193.64.42.134]) by rms06.rommon.net (Postfix) with ESMTP id 3A69C33C26; Thu, 5 Aug 2004 18:17:03 +0300 (EEST) Message-ID: <41124F71.9010102@he.iki.fi> Date: Thu, 05 Aug 2004 18:17:05 +0300 From: Petri Helenius User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Doug Rabson References: <200408050940.36506.dfr@nlsystems.com> <411248DA.3080607@freebsd.org> <200408051553.51692.dfr@nlsystems.com> In-Reply-To: <200408051553.51692.dfr@nlsystems.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: David Xu cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 15:17:07 -0000 Doug Rabson wrote: >I haven't tried to support static linked TLS at all. The plan is to get >the kernel to size the TLS segment and add extra AUXARGs to report its >size, initialiser location and alignment. The stubs in libc/gen/tls.c >would be extended to provide support for allocating the TLS blocks in >the static case. > >I was under the impression that no-one particularly wanted to support >pthreads in statically linked binaries? > > > Does this still allow for some, non-thread libraries to be linked statically as long as libpthread is dynamically linked? Pete From owner-freebsd-threads@FreeBSD.ORG Thu Aug 5 15:19:49 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4B84F16A4CE; Thu, 5 Aug 2004 15:19:49 +0000 (GMT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 071A943D54; Thu, 5 Aug 2004 15:19:49 +0000 (GMT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id i75FJm3w004431; Thu, 5 Aug 2004 11:19:48 -0400 (EDT) Date: Thu, 5 Aug 2004 11:19:48 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Doug Rabson In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: David Xu cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 15:19:49 -0000 On Thu, 5 Aug 2004, Daniel Eischen wrote: > On Thu, 5 Aug 2004, Doug Rabson wrote: > > > I haven't tried to support static linked TLS at all. The plan is to get > > the kernel to size the TLS segment and add extra AUXARGs to report its > > size, initialiser location and alignment. The stubs in libc/gen/tls.c > > would be extended to provide support for allocating the TLS blocks in > > the static case. > > > > I was under the impression that no-one particularly wanted to support > > pthreads in statically linked binaries? > > The thread guys don't want to support static thread libraries ;-) > But I proposed this a few months ago (year?) in -current and there > was some reluctance. Imp was one that was against it (from what I > can remember). The reason given was speed of static binaries is > faster than dynamic. I didn't force the issue any more than that. > That's how I recall it anyways. I'll have to search the list > archives to see if I can find the thread. Found it. http://docs.freebsd.org/mail/archive/2003/freebsd-arch/20030330.freebsd-arch.html Look for "Not providing static libraries", Mar 26, 2003, freebsd-arch Note that Solaris doesn't have static thread libraries. I'm not sure about Linux... -- Dan Eischen From owner-freebsd-threads@FreeBSD.ORG Thu Aug 5 15:34:27 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D9CDA16A4CE; Thu, 5 Aug 2004 15:34:27 +0000 (GMT) Received: from itchy.rabson.org (mailgate.nlsystems.com [80.177.232.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id 41EC043D45; Thu, 5 Aug 2004 15:34:27 +0000 (GMT) (envelope-from dfr@nlsystems.com) Received: from ns0.nlsystems.com (ns0.nlsystems.com [80.177.232.243]) by itchy.rabson.org (8.12.11/8.12.11) with ESMTP id i75FYOU1028334; Thu, 5 Aug 2004 16:34:24 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: Daniel Eischen Date: Thu, 5 Aug 2004 16:34:21 +0100 User-Agent: KMail/1.6.2 References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200408051634.21312.dfr@nlsystems.com> X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on itchy.rabson.org X-Virus-Scanned: clamd / ClamAV version 0.71, clamav-milter version 0.71 X-Virus-Status: Clean cc: David Xu cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 15:34:28 -0000 On Thursday 05 August 2004 16:19, Daniel Eischen wrote: > On Thu, 5 Aug 2004, Daniel Eischen wrote: > > On Thu, 5 Aug 2004, Doug Rabson wrote: > > > I haven't tried to support static linked TLS at all. The plan is > > > to get the kernel to size the TLS segment and add extra AUXARGs > > > to report its size, initialiser location and alignment. The stubs > > > in libc/gen/tls.c would be extended to provide support for > > > allocating the TLS blocks in the static case. > > > > > > I was under the impression that no-one particularly wanted to > > > support pthreads in statically linked binaries? > > > > The thread guys don't want to support static thread libraries ;-) > > But I proposed this a few months ago (year?) in -current and there > > was some reluctance. Imp was one that was against it (from what I > > can remember). The reason given was speed of static binaries is > > faster than dynamic. I didn't force the issue any more than that. > > That's how I recall it anyways. I'll have to search the list > > archives to see if I can find the thread. > > Found it. > > > http://docs.freebsd.org/mail/archive/2003/freebsd-arch/20030330.freeb >sd-arch.html > > Look for "Not providing static libraries", Mar 26, 2003, freebsd-arch > > Note that Solaris doesn't have static thread libraries. I'm not sure > about Linux... Looks like I'll have to look into getting TLS to work in the static case. Sigh. From owner-freebsd-threads@FreeBSD.ORG Thu Aug 5 20:03:24 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8A7BF16A4CE; Thu, 5 Aug 2004 20:03:24 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3D46C43D62; Thu, 5 Aug 2004 20:03:24 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.11/8.12.11) id i75K3IlM069898; Thu, 5 Aug 2004 15:03:18 -0500 (CDT) (envelope-from dan) Date: Thu, 5 Aug 2004 15:03:18 -0500 From: Dan Nelson To: freebsd-current@freebsd.org Message-ID: <20040805200317.GA6978@dan.emsphone.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: freebsd-threads@freebsd.org Subject: Fatal trap 12 in kern_ptrace X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 20:03:24 -0000 Recently I've been seeing libpthreaded processes just hang suddenly. ps shows them in the STOPped state, and ps -H shows that all threads are idle except for one, which is waiting on a lock (I've seen ufs and wait on different occasions). Killing the process results in an instant system freeze. I tried gdb'ing one this time, and was rewarded with the following trap: kernel trap 12 with interrupts disabled Fatal trap 12: page fault while in kernel mode cpuid = 0; apic id = 03 fault virtual address = 0x44 fault code = supervisor write, page not present instruction pointer = 0x8:0xc058ae4c stack pointer = 0x10:0xdef5db84 frame pointer = 0x10:0xdef5dc04 code segment = base 0x0, limit 0xfffff, type 0x1b = DPL 0, pres 1, def32 1, gran 1 processor eflags = resume, IOPL = 0 current process = 63683 (gdb) At this point the system froze so I couldn't get a full stack trace, but: $ addr2line -f -e kernel.debug 0xc058ae4c kern_ptrace ../../../kern/sys_process.c:659 658 if (saved_pid <= PID_MAX) { 659 p->p_xthread->td_flags &= ~TDF_XSIG; 660 p->p_xthread->td_xsig = data; It looks like p_xthread is null when it shouldn't be. This is an Aug 02 kernel, so no PREEMPTION. -- Dan Nelson dnelson@allantgroup.com From owner-freebsd-threads@FreeBSD.ORG Thu Aug 5 23:23:47 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 607E716A4CE for ; Thu, 5 Aug 2004 23:23:47 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1AF3943D55; Thu, 5 Aug 2004 23:23:47 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from [127.0.0.1] (davidxu@localhost [127.0.0.1]) i75NNjNJ092097; Thu, 5 Aug 2004 23:23:46 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4112C264.4040807@freebsd.org> Date: Fri, 06 Aug 2004 07:27:32 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.7.1) Gecko/20040730 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Doug Rabson References: <200408050940.36506.dfr@nlsystems.com> <411248DA.3080607@freebsd.org> <200408051553.51692.dfr@nlsystems.com> In-Reply-To: <200408051553.51692.dfr@nlsystems.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2004 23:23:47 -0000 I am thinking about debugger tls support, giving a link_map address, how do I find a modules's tlsindex in FreeBSD ? Linux put a l_tls_modid to link_map. David Xu From owner-freebsd-threads@FreeBSD.ORG Fri Aug 6 08:26:50 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C64C716A4CE; Fri, 6 Aug 2004 08:26:50 +0000 (GMT) Received: from itchy.rabson.org (mailgate.nlsystems.com [80.177.232.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id C279943D41; Fri, 6 Aug 2004 08:26:47 +0000 (GMT) (envelope-from dfr@nlsystems.com) Received: from ns0.nlsystems.com (ns0.nlsystems.com [80.177.232.243]) by itchy.rabson.org (8.12.11/8.12.11) with ESMTP id i768QhEX035528; Fri, 6 Aug 2004 09:26:43 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: David Xu Date: Fri, 6 Aug 2004 09:26:45 +0100 User-Agent: KMail/1.6.2 References: <200408050940.36506.dfr@nlsystems.com> <200408051553.51692.dfr@nlsystems.com> <4112C264.4040807@freebsd.org> In-Reply-To: <4112C264.4040807@freebsd.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200408060926.45767.dfr@nlsystems.com> X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on itchy.rabson.org X-Virus-Scanned: clamd / ClamAV version 0.71, clamav-milter version 0.71 X-Virus-Status: Clean cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2004 08:26:50 -0000 On Friday 06 August 2004 00:27, David Xu wrote: > I am thinking about debugger tls support, giving a link_map address, > how do I find a modules's tlsindex in FreeBSD ? > Linux put a l_tls_modid to link_map. That might be the simplest way. If you add the new field at the end of struct link_map, then there shouldn't be any ABI issues since rtld is the only thing that allocates these structures. From owner-freebsd-threads@FreeBSD.ORG Fri Aug 6 12:43:52 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 94B4216A4CE; Fri, 6 Aug 2004 12:43:52 +0000 (GMT) Received: from mail.qubesoft.com (gate.qubesoft.com [217.169.36.34]) by mx1.FreeBSD.org (Postfix) with ESMTP id C60C843D2F; Fri, 6 Aug 2004 12:43:51 +0000 (GMT) (envelope-from dfr@nlsystems.com) Received: from bluebottle.qubesoft.com (bluebottle.qubesoft.com [192.168.1.2]) by mail.qubesoft.com (8.12.9/8.12.9) with ESMTP id i76ChnGR032399; Fri, 6 Aug 2004 13:43:50 +0100 (BST) (envelope-from dfr@nlsystems.com) Received: from builder02.qubesoft.com (builder02.qubesoft.com [192.168.1.8]) i76ChmON066742; Fri, 6 Aug 2004 13:43:49 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: Daniel Eischen In-Reply-To: References: Content-Type: text/plain Message-Id: <1091796228.4367.5.camel@builder02.qubesoft.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 06 Aug 2004 13:43:48 +0100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV version 'clamd / ClamAV version 0.65', clamav-milter version '0.60p' cc: David Xu cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2004 12:43:52 -0000 On Thu, 2004-08-05 at 16:19, Daniel Eischen wrote: > On Thu, 5 Aug 2004, Daniel Eischen wrote: > > > On Thu, 5 Aug 2004, Doug Rabson wrote: > > > > > I haven't tried to support static linked TLS at all. The plan is to get > > > the kernel to size the TLS segment and add extra AUXARGs to report its > > > size, initialiser location and alignment. The stubs in libc/gen/tls.c > > > would be extended to provide support for allocating the TLS blocks in > > > the static case. > > > > > > I was under the impression that no-one particularly wanted to support > > > pthreads in statically linked binaries? > > > > The thread guys don't want to support static thread libraries ;-) > > But I proposed this a few months ago (year?) in -current and there > > was some reluctance. Imp was one that was against it (from what I > > can remember). The reason given was speed of static binaries is > > faster than dynamic. I didn't force the issue any more than that. > > That's how I recall it anyways. I'll have to search the list > > archives to see if I can find the thread. > > Found it. > > http://docs.freebsd.org/mail/archive/2003/freebsd-arch/20030330.freebsd-arch.html > > Look for "Not providing static libraries", Mar 26, 2003, freebsd-arch > > Note that Solaris doesn't have static thread libraries. I'm not sure about > Linux... I thought I was in luck when I noticed the AT_PHDR entry but unfortunately its NULL in static programs. I reckon I can fix that in the kernel since the phdrs are definately inside the first load segment. From owner-freebsd-threads@FreeBSD.ORG Fri Aug 6 12:59:26 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 76E9316A4CF for ; Fri, 6 Aug 2004 12:59:26 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C15B43D4C; Fri, 6 Aug 2004 12:59:26 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from [127.0.0.1] (davidxu@localhost [127.0.0.1]) i76CxMRF093940; Fri, 6 Aug 2004 12:59:24 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4113818E.5010601@freebsd.org> Date: Fri, 06 Aug 2004 21:03:10 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.7.1) Gecko/20040730 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Doug Rabson References: <1091796228.4367.5.camel@builder02.qubesoft.com> In-Reply-To: <1091796228.4367.5.camel@builder02.qubesoft.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2004 12:59:26 -0000 Doug Rabson wrote: >> http://docs.freebsd.org/mail/archive/2003/freebsd-arch/20030330.freebsd-arch.html >> >>Look for "Not providing static libraries", Mar 26, 2003, freebsd-arch >> >>Note that Solaris doesn't have static thread libraries. I'm not sure about >>Linux... >> >> > >I thought I was in luck when I noticed the AT_PHDR entry but >unfortunately its NULL in static programs. I reckon I can fix that in >the kernel since the phdrs are definately inside the first load segment. > > > I hope the current tls structure will be kept both in rtld and libpthread, I have already done tls debugger support locally this afternoon. From owner-freebsd-threads@FreeBSD.ORG Fri Aug 6 13:15:28 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 581DF16A4CE; Fri, 6 Aug 2004 13:15:28 +0000 (GMT) Received: from mail.qubesoft.com (gate.qubesoft.com [217.169.36.34]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD62B43D58; Fri, 6 Aug 2004 13:15:27 +0000 (GMT) (envelope-from dfr@nlsystems.com) Received: from bluebottle.qubesoft.com (bluebottle.qubesoft.com [192.168.1.2]) by mail.qubesoft.com (8.12.9/8.12.9) with ESMTP id i76DFQGR033416; Fri, 6 Aug 2004 14:15:26 +0100 (BST) (envelope-from dfr@nlsystems.com) Received: from builder02.qubesoft.com (builder02.qubesoft.com [192.168.1.8]) i76DFQON067219; Fri, 6 Aug 2004 14:15:26 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: David Xu In-Reply-To: <4113818E.5010601@freebsd.org> References: <1091796228.4367.5.camel@builder02.qubesoft.com> <4113818E.5010601@freebsd.org> Content-Type: text/plain Message-Id: <1091798125.4367.8.camel@builder02.qubesoft.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 06 Aug 2004 14:15:26 +0100 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV version 'clamd / ClamAV version 0.65', clamav-milter version '0.60p' cc: freebsd-threads@freebsd.org Subject: Re: Pthread patches for TLS X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2004 13:15:28 -0000 On Fri, 2004-08-06 at 14:03, David Xu wrote: > Doug Rabson wrote: > > >> http://docs.freebsd.org/mail/archive/2003/freebsd-arch/20030330.freebsd-arch.html > >> > >>Look for "Not providing static libraries", Mar 26, 2003, freebsd-arch > >> > >>Note that Solaris doesn't have static thread libraries. I'm not sure about > >>Linux... > >> > >> > > > >I thought I was in luck when I noticed the AT_PHDR entry but > >unfortunately its NULL in static programs. I reckon I can fix that in > >the kernel since the phdrs are definately inside the first load segment. > > > > > > > I hope the current tls structure will be kept both in rtld and libpthread, > I have already done tls debugger support locally this afternoon. > Static support won't affect how libpthread works at all. All that will happen is that the stub _rtld_allocate_tls() in libc will provide the TLS support for static binaries. From owner-freebsd-threads@FreeBSD.ORG Fri Aug 6 20:19:02 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F23D516A4CE; Fri, 6 Aug 2004 20:19:01 +0000 (GMT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6BA9043D45; Fri, 6 Aug 2004 20:19:01 +0000 (GMT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id i76KIxXd020691; Fri, 6 Aug 2004 16:18:59 -0400 (EDT) Date: Fri, 6 Aug 2004 16:18:59 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Robert Watson In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: threads@freebsd.org cc: davidxu@freebsd.org Subject: Re: A way to build and install libpthread as 1:1 as well as M:N? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: deischen@freebsd.org List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2004 20:19:02 -0000 On Mon, 19 Jul 2004, Robert Watson wrote: > On Sun, 18 Jul 2004, Daniel Eischen wrote: > > > > The issue here is my keeping everything in sync and making sure testing is > > > reproduceable. If I'm manually building and installing threading > > > libraries, I'm likely to screw it up. I was hoping for a mechanism in > > > buildworld/installworld so that it all happens automatically, reducing the > > > chances of user error, stale library versions, etc. > > > > Well, like I said, if we can agree on a place to put the 1:1 version and > > what to call it, we can make it happen. My suggestion is to keep the > > libraries named the same, install them in different places, and use > > LD_LIBRARY_PATH to switch between them. > > > > Should I just do it, or is more discussion needed? > > Other than the need for something like it, I don't have much opinion on > the mechanism by which it's accomplished. I think that what you suggest > sounds pretty reasonable to me. I'd be fine with a libpthread11, a > lib/foo/libpthread, or whatever makes the most sense to you. I guess > maybe I have a slight preference for libpthread11, but agree that the > benefits of being able to use LD_LIBRARY_PATH are substantial and probably > more important than the slight asthetic preference. Well, it didn't add much to the library to allow either 1:1 or M:N. Here's a patch that lets you run in 1:1 mode if LIBPTHREAD_SYSTEM_SCOPE is defined in the environment. I'm not stuck on its name, so feel free to suggest something else. http://people.freebsd.org/~deischen/kse/libpthread.diffs Warning (*), you can still force 1:1 mode if you build the library with -DSYSTEM_SCOPE_ONLY, so be sure to remove this when rebuilding libpthread. (*) I think it's still useful for archs that don't run in M:N yet. -- Dan Eischen From owner-freebsd-threads@FreeBSD.ORG Fri Aug 6 22:22:13 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D689E16A4CE; Fri, 6 Aug 2004 22:22:13 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CF0F043D48; Fri, 6 Aug 2004 22:22:13 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from [127.0.0.1] (davidxu@localhost [127.0.0.1]) i76MMCM8065955; Fri, 6 Aug 2004 22:22:12 GMT (envelope-from davidxu@freebsd.org) Message-ID: <41140578.6060009@freebsd.org> Date: Sat, 07 Aug 2004 06:26:00 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.7.1) Gecko/20040730 X-Accept-Language: en-us, en MIME-Version: 1.0 To: deischen@freebsd.org References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: threads@freebsd.org cc: Robert Watson Subject: Re: A way to build and install libpthread as 1:1 as well as M:N? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2004 22:22:14 -0000 Daniel Eischen wrote: >Well, it didn't add much to the library to allow either 1:1 or M:N. >Here's a patch that lets you run in 1:1 mode if LIBPTHREAD_SYSTEM_SCOPE >is defined in the environment. I'm not stuck on its name, so feel >free to suggest something else. > > http://people.freebsd.org/~deischen/kse/libpthread.diffs > >Warning (*), you can still force 1:1 mode if you build the library >with -DSYSTEM_SCOPE_ONLY, so be sure to remove this when rebuilding >libpthread. > >(*) I think it's still useful for archs that don't run in M:N yet. > > > Looks fine to me, please go ahead.