public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: David Mosberger <davidm@napali.hpl.hp.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: davidm@hpl.hp.com, GNU libc hackers <libc-hacker@sources.redhat.com>
Subject: Re: enabling caching for dl_iterate_phdr()
Date: Mon, 26 Jan 2004 21:48:00 -0000	[thread overview]
Message-ID: <16405.35582.830546.716126@napali.hpl.hp.com> (raw)
In-Reply-To: <4012D162.1000502@redhat.com>

>>>>> On Sat, 24 Jan 2004 12:11:14 -0800, Ulrich Drepper <drepper@redhat.com> 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  <davidm@hpl.hp.com>

	* 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.  */

  reply	other threads:[~2004-01-26 21:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <16387.9755.753294.37588@napali.hpl.hp.com>
2004-01-17  0:57 ` Roland McGrath
2004-01-17  1:39   ` Jakub Jelinek
2004-01-17  1:40     ` Roland McGrath
2004-01-17  1:51     ` David Mosberger
2004-01-22  0:35     ` David Mosberger
2004-01-22  8:39       ` Jakub Jelinek
2004-01-24  5:54         ` David Mosberger
2004-01-24 20:27           ` Ulrich Drepper
2004-01-26 21:48             ` David Mosberger [this message]
2004-01-26 22:39               ` Ulrich Drepper
2004-01-26 22:58                 ` Roland McGrath
2004-01-26 23:03                 ` David Mosberger
2003-12-16 19:55 David Mosberger
2003-12-23 22:24 ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16405.35582.830546.716126@napali.hpl.hp.com \
    --to=davidm@napali.hpl.hp.com \
    --cc=davidm@hpl.hp.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).