From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31091 invoked by alias); 26 Jan 2004 21:48:09 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 31024 invoked from network); 26 Jan 2004 21:48:07 -0000 Received: from unknown (HELO palrel11.hp.com) (156.153.255.246) by sources.redhat.com with SMTP; 26 Jan 2004 21:48:07 -0000 Received: from hplms2.hpl.hp.com (hplms2.hpl.hp.com [15.0.152.33]) by palrel11.hp.com (Postfix) with ESMTP id 5852D1C02908; Tue, 27 Jan 2004 05:18:07 -0800 (PST) Received: from napali.hpl.hp.com (napali.hpl.hp.com [15.4.89.123]) by hplms2.hpl.hp.com (8.12.10/8.12.10/HPL-PA Hub) with ESMTP id i0QLlhOH015508; Mon, 26 Jan 2004 13:47:43 -0800 (PST) Received: from napali.hpl.hp.com (napali [127.0.0.1]) by napali.hpl.hp.com (8.12.9/8.12.9/Debian-5) with ESMTP id i0QLlhQj010438; Mon, 26 Jan 2004 13:47:43 -0800 Received: (from davidm@localhost) by napali.hpl.hp.com (8.12.9/8.12.9/Debian-5) id i0QLlgvl010434; Mon, 26 Jan 2004 13:47:42 -0800 From: David Mosberger MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16405.35582.830546.716126@napali.hpl.hp.com> Date: Mon, 26 Jan 2004 21:48:00 -0000 To: Ulrich Drepper Cc: davidm@hpl.hp.com, GNU libc hackers Subject: Re: enabling caching for dl_iterate_phdr() In-Reply-To: <4012D162.1000502@redhat.com> References: <16387.9755.753294.37588@napali.hpl.hp.com> <200401170057.i0H0vQag022225@magilla.sf.frob.com> <20040116232931.GL6413@sunsite.ms.mff.cuni.cz> <16399.6885.708290.614809@napali.hpl.hp.com> <20040122062944.GC6811@sunsite.ms.mff.cuni.cz> <16402.2189.718828.875017@napali.hpl.hp.com> <4012D162.1000502@redhat.com> Reply-To: davidm@hpl.hp.com X-URL: http://www.hpl.hp.com/personal/David_Mosberger/ X-SW-Source: 2004-01/txt/msg00102.txt.bz2 >>>>> On Sat, 24 Jan 2004 12:11:14 -0800, Ulrich Drepper said: Uli> David Mosberger wrote: >> Attached is an updated patch. "make check subdirs=elf" passes >> all tests (including the new tst-dlmodcount test). Uli> I've applied the patch. Thanks! In the meantime, it occurred to me that we can get rid of one of the "unsigned long long" variables by taking advantage of the fact that "_dl_nloaded == _dl_load_adds - _dl_load_subs" (provided there are never more than 0xffffffff shared objects loaded). Apart from saving 8 bytes of global data, it also has the advantage that it makes code maintenance a bit easier. The rule is very simple now: wherever _dl_nloaded gets incremented, _dl_load_adds needs to be incremented as well. If it looks OK to you, please apply (it was "make subdirs=elf check" tested). Thanks, --david ChangeLog 2004-01-26 David Mosberger * elf/link.h (struct dl_phdr_info): Fix typo in comment. * elf/rtld.c (dl_main): After incrementing dl_nloaded, also increment dl_load_adds. * elf/dl-iteratephdr.c (__dl_iterate_phdr): Replace GL(dl_load_subs) with equivalent GL(dl_load_adds - GL(dl_nloaded). (dl_iterate_phdr): Likewise. * elf/dl-close.c (_dl_close): Delete increment of GL(dl_load_subs). * elf/dl-support.c: Remove global variable _dl_load_subs. * sysdeps/generic/ldsodefs.h (struct rtld_global): Remove _dl_load_subs member. Index: elf/dl-close.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-close.c,v retrieving revision 1.99 diff -u -r1.99 dl-close.c --- elf/dl-close.c 24 Jan 2004 20:07:38 -0000 1.99 +++ elf/dl-close.c 26 Jan 2004 21:42:35 -0000 @@ -319,7 +319,6 @@ /* Notify the debugger we are about to remove some loaded objects. */ _r_debug.r_state = RT_DELETE; _dl_debug_state (); - ++GL(dl_load_subs); #ifdef USE_TLS size_t tls_free_start; Index: elf/dl-iteratephdr.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-iteratephdr.c,v retrieving revision 1.10 diff -u -r1.10 dl-iteratephdr.c --- elf/dl-iteratephdr.c 24 Jan 2004 20:07:51 -0000 1.10 +++ elf/dl-iteratephdr.c 26 Jan 2004 21:42:35 -0000 @@ -49,7 +49,7 @@ info.dlpi_phdr = l->l_phdr; info.dlpi_phnum = l->l_phnum; info.dlpi_adds = GL(dl_load_adds); - info.dlpi_subs = GL(dl_load_subs); + info.dlpi_subs = GL(dl_load_adds) - GL(dl_nloaded); ret = callback (&info, sizeof (struct dl_phdr_info), data); if (ret) break; @@ -87,7 +87,7 @@ info.dlpi_phdr = _dl_phdr; info.dlpi_phnum = _dl_phnum; info.dlpi_adds = GL(dl_load_adds); - info.dlpi_subs = GL(dl_load_subs); + info.dlpi_subs = GL(dl_load_adds) - GL(dl_nloaded); ret = (*callback) (&info, sizeof (struct dl_phdr_info), data); if (ret) return ret; Index: elf/dl-support.c =================================================================== RCS file: /cvs/glibc/libc/elf/dl-support.c,v retrieving revision 1.80 diff -u -r1.80 dl-support.c --- elf/dl-support.c 24 Jan 2004 20:08:29 -0000 1.80 +++ elf/dl-support.c 26 Jan 2004 21:42:35 -0000 @@ -73,8 +73,6 @@ /* Incremented whenever something may have been added to dl_loaded. */ unsigned long long _dl_load_adds; -/* Incremented whenever something may have been removed from dl_loaded. */ -unsigned long long _dl_load_subs; /* Fake scope. In dynamically linked binaries this is the scope of the main application but here we don't have something like this. So Index: elf/link.h =================================================================== RCS file: /cvs/glibc/libc/elf/link.h,v retrieving revision 1.77 diff -u -r1.77 link.h --- elf/link.h 24 Jan 2004 20:08:50 -0000 1.77 +++ elf/link.h 26 Jan 2004 21:42:35 -0000 @@ -103,7 +103,7 @@ /* Note: the next two members were introduced after the first version of this structure was available. Check the SIZE - argument pass to the dl_iterate_phdr() callback to determine + argument passed to the dl_iterate_phdr() callback to determine whether or not they are provided. */ /* Incremented when a new object may have been added. */ Index: elf/rtld.c =================================================================== RCS file: /cvs/glibc/libc/elf/rtld.c,v retrieving revision 1.310 diff -u -r1.310 rtld.c --- elf/rtld.c 24 Jan 2004 08:33:44 -0000 1.310 +++ elf/rtld.c 26 Jan 2004 21:42:35 -0000 @@ -1020,6 +1020,7 @@ GL(dl_loaded)->l_next = &GL(dl_rtld_map); GL(dl_rtld_map).l_prev = GL(dl_loaded); ++GL(dl_nloaded); + ++GL(dl_load_adds); /* If LD_USE_LOAD_BIAS env variable has not been seen, default to not using bias for non-prelinked PIEs and libraries Index: sysdeps/generic/ldsodefs.h =================================================================== RCS file: /cvs/glibc/libc/sysdeps/generic/ldsodefs.h,v retrieving revision 1.89 diff -u -r1.89 ldsodefs.h --- sysdeps/generic/ldsodefs.h 24 Jan 2004 20:10:18 -0000 1.89 +++ sysdeps/generic/ldsodefs.h 26 Jan 2004 21:42:36 -0000 @@ -267,8 +267,6 @@ /* Incremented whenever something may have been added to dl_loaded. */ EXTERN unsigned long long _dl_load_adds; - /* Incremented whenever something may have been removed from dl_loaded. */ - EXTERN unsigned long long _dl_load_subs; #ifndef MAP_ANON /* File descriptor referring to the zero-fill device. */