public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@scylladb.com>
To: libc-alpha@sourceware.org
Subject: [PATCH v2 1/2] count number of loaded objects in each namespace only once
Date: Fri, 05 Aug 2016 07:41:00 -0000	[thread overview]
Message-ID: <1470382826-6022-2-git-send-email-gleb@scylladb.com> (raw)
In-Reply-To: <1470382826-6022-1-git-send-email-gleb@scylladb.com>

_ns_nloaded already has count of all objects in a namespace, no need to
add it while iterating over all objects.
---
 elf/dl-iteratephdr.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index 1cb6e26..e4e7205 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -48,17 +48,18 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
 #ifdef SHARED
   const void *caller = RETURN_ADDRESS (0);
   for (Lmid_t cnt = GL(dl_nns) - 1; cnt > 0; --cnt)
-    for (struct link_map *l = GL(dl_ns)[cnt]._ns_loaded; l; l = l->l_next)
-      {
-	/* We have to count the total number of loaded objects.  */
-	nloaded += GL(dl_ns)[cnt]._ns_nloaded;
-
-	if (caller >= (const void *) l->l_map_start
-	    && caller < (const void *) l->l_map_end
-	    && (l->l_contiguous
-		|| _dl_addr_inside_object (l, (ElfW(Addr)) caller)))
-	  ns = cnt;
-      }
+    {
+      /* We have to count the total number of loaded objects.  */
+      nloaded += GL(dl_ns)[cnt]._ns_nloaded;
+      for (struct link_map *l = GL(dl_ns)[cnt]._ns_loaded; l; l = l->l_next)
+        {
+          if (caller >= (const void *) l->l_map_start
+              && caller < (const void *) l->l_map_end
+              && (l->l_contiguous
+                  || _dl_addr_inside_object (l, (ElfW(Addr)) caller)))
+            ns = cnt;
+        }
+    }
 #endif
 
   for (l = GL(dl_ns)[ns]._ns_loaded; l != NULL; l = l->l_next)
-- 
2.5.5

  parent reply	other threads:[~2016-08-05  7:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05  7:41 [PATCH v2 0/2] " Gleb Natapov
2016-08-05  7:41 ` [PATCH v2 2/2] add test for correct calculation of dl_phdr_info.dlpi_subs Gleb Natapov
2016-08-05  7:41 ` Gleb Natapov [this message]
2016-09-07 17:00 ` [PATCH v2 0/2] count number of loaded objects in each namespace only once Gleb Natapov
2016-09-21  8:12   ` Gleb Natapov
  -- strict thread matches above, loose matches on Subject: below --
2016-08-03 13:53 Gleb Natapov
2016-08-03 13:53 ` [PATCH v2 1/2] " Gleb Natapov
2016-08-05  3:31   ` Mike Frysinger

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=1470382826-6022-2-git-send-email-gleb@scylladb.com \
    --to=gleb@scylladb.com \
    --cc=libc-alpha@sourceware.org \
    /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).