From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18177 invoked by alias); 27 Oct 2006 08:29:52 -0000 Received: (qmail 18160 invoked by uid 22791); 27 Oct 2006 08:29:51 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 27 Oct 2006 08:29:44 +0000 Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id k9R8TcqP015316; Fri, 27 Oct 2006 10:29:38 +0200 Received: (from jj@localhost) by sunsite.mff.cuni.cz (8.13.1/8.13.1/Submit) id k9R8Tbu5015314; Fri, 27 Oct 2006 10:29:37 +0200 Date: Fri, 27 Oct 2006 08:29:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] SINGLE_THREAD_P in ld.so Message-ID: <20061027082937.GO5868@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00017.txt.bz2 Hi! When trying to optimize the {_dl_{,profile_}fixup,dl{,v}sym} vs. dlopen/dlclose locking, I missed the fact that SINGLE_THREAD_P is unconditionally defined to 1 in ld.so. The result is that al the __rtld_mrlock_* stuff is ATM optimized out in ld.so. This patch fixes that. 2006-10-27 Jakub Jelinek * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (SINGLE_THREAD_P): Define to THREAD_SELF->header.multiple_threads. * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (SINGLE_THREAD_P): Likewise. --- libc/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h.jj 2004-09-06 03:12:02.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h 2006-10-24 10:22:00.000000000 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -163,7 +163,13 @@ extern int __local_multiple_threads attr #else -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h.jj 2004-07-06 06:25:45.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h 2006-10-24 10:22:11.000000000 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2002. @@ -216,7 +216,13 @@ __GC_##name: \ #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h.jj 2006-10-17 11:21:51.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h 2006-10-24 10:22:11.000000000 +0200 @@ -143,7 +143,13 @@ #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h.jj 2004-07-06 06:25:44.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h 2006-10-24 10:22:00.000000000 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2003. @@ -109,7 +109,13 @@ L(pseudo_end): #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h.jj 2004-07-06 06:25:44.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h 2006-10-24 10:22:00.000000000 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2003. @@ -122,7 +122,13 @@ extern int __local_multiple_threads attr #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h.jj 2006-01-04 21:03:07.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h 2006-10-24 10:22:00.000000000 +0200 @@ -113,7 +113,13 @@ #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h.jj 2006-01-04 21:03:07.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h 2006-10-24 10:22:00.000000000 +0200 @@ -124,7 +124,13 @@ #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h.jj 2005-03-31 12:00:15.000000000 +0200 +++ libc/nptl/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h 2006-10-24 10:22:11.000000000 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2002. @@ -132,7 +132,13 @@ extern int __local_multiple_threads attr #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h.jj 2006-03-06 02:34:01.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h 2006-10-24 10:22:00.000000000 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2002. @@ -100,7 +100,13 @@ __##syscall_name##_nocancel: \ #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h.jj 2006-03-06 02:34:01.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h 2006-10-24 10:22:00.000000000 +0200 @@ -98,7 +98,13 @@ __##syscall_name##_nocancel: \ #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif --- libc/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h.jj 2005-12-30 23:18:03.000000000 +0100 +++ libc/nptl/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h 2006-10-24 10:22:00.000000000 +0200 @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -157,7 +157,13 @@ #elif !defined __ASSEMBLER__ -# define SINGLE_THREAD_P (1) +# ifdef IS_IN_rtld +# define SINGLE_THREAD_P \ + __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0, 1) +# else +# define SINGLE_THREAD_P (1) +# endif # define NO_CANCELLATION 1 #endif Jakub