This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] count number of loaded objects in each namespace only once


Ping?

On Sun, Jul 24, 2016 at 03:24:20PM +0300, Gleb Natapov wrote:
> _ns_nloaded already has count of all objects in a namespace, no need to
> add it while iterating over all objects.
> 
> diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
> index 1cb6e26..4db6938 100644
> --- a/elf/dl-iteratephdr.c
> +++ b/elf/dl-iteratephdr.c
> @@ -47,18 +47,18 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
>    Lmid_t ns = 0;
>  #ifdef SHARED
>    const void *caller = RETURN_ADDRESS (0);
> -  for (Lmid_t cnt = GL(dl_nns) - 1; cnt > 0; --cnt)
> +  for (Lmid_t cnt = GL(dl_nns) - 1; cnt > 0; --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)
>        {
> -	/* 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;
>        }
> +  }
>  #endif
>  
>    for (l = GL(dl_ns)[ns]._ns_loaded; l != NULL; l = l->l_next)
> --
> 			Gleb.

--
			Gleb.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]