This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
On Thu, Aug 23, 2001 at 06:22:35PM +0200, Andreas Jaeger wrote: > Ulrich Drepper <drepper@redhat.com> writes: > > > Andreas Jaeger <aj@suse.de> writes: > > > >> Since Jakub's patch for sorting of relocations in binutils has been > >> approved, I've updated his patch for caching symbol lookup. > >> > >> Ok to commit? > > > > One more change: create two cache variables. One for the versioned > > looked, one for the unversioned. Since the versioned functions are > > never called with version==NULL this will eliminate one test and one > > assignment in each of the unversioned functions. > > Ok, will do that later today. Here it is: 2001-08-23 Jakub Jelinek <jakub@redhat.com> * elf/dl-lookup.c (lookup_cache, lookup_cache_versioned): New. (_dl_lookup_symbol): Lookup relocations in cache and store successfull lookups in cache. (_dl_lookup_versioned_symbol): Likewise. * elf/dl-reloc.c (_dl_relocate_object): Initialize cache for relocation lookup. * elf/rtld.c (print_statistics): Output _dl_num_cache_relocations. * sysdeps/generic/ldsodefs.h (struct lookup_cache): New. (lookup_cache, lookup_cache_versioned): New. --- libc/elf/dl-lookup.c.jj Thu Aug 23 18:56:20 2001 +++ libc/elf/dl-lookup.c Thu Aug 23 19:06:34 2001 @@ -60,6 +60,7 @@ struct sym_val /* Statistics function. */ unsigned long int _dl_num_relocations; +unsigned long int _dl_num_cache_relocations; /* We have two different situations when looking up a simple: with or @@ -184,6 +185,8 @@ _dl_do_lookup_versioned (const char *und const struct r_found_version *const version, struct link_map *skip, int noexec, int noplt); +struct lookup_cache lookup_cache, lookup_cache_versioned; + /* Search loaded objects' symbol tables for a definition of the symbol UNDEF_NAME. */ @@ -201,6 +204,17 @@ _dl_lookup_symbol (const char *undef_nam int noexec = elf_machine_lookup_noexec_p (reloc_type); int noplt = elf_machine_lookup_noplt_p (reloc_type); + /* First check if we can find it in the cache. */ + if (__builtin_expect (*ref == lookup_cache.sym, 0) + && lookup_cache.map == undef_map + && lookup_cache.noexec == noexec + && lookup_cache.noplt == noplt) + { + ++_dl_num_cache_relocations; + *ref = lookup_cache.ret; + return lookup_cache.value; + } + ++_dl_num_relocations; /* Search the relevant loaded objects for a definition. */ @@ -229,6 +243,10 @@ _dl_lookup_symbol (const char *undef_nam break; } + lookup_cache.sym = *ref; + lookup_cache.noexec = noexec; + lookup_cache.noplt = noplt; + if (__builtin_expect (current_value.s == NULL, 0)) { if (*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK) @@ -238,6 +256,8 @@ _dl_lookup_symbol (const char *undef_nam ? reference_name : (_dl_argv[0] ?: "<main program>")), make_string (undefined_msg, undef_name)); + lookup_cache.ret = NULL; + lookup_cache.value = 0; *ref = NULL; return 0; } @@ -254,6 +274,8 @@ _dl_lookup_symbol (const char *undef_nam if (__builtin_expect (protected == 0, 1)) { + lookup_cache.ret = current_value.s; + lookup_cache.value = LOOKUP_VALUE (current_value.m); *ref = current_value.s; return LOOKUP_VALUE (current_value.m); } @@ -270,9 +292,13 @@ _dl_lookup_symbol (const char *undef_nam if (protected_value.s == NULL || protected_value.m == undef_map) { + lookup_cache.ret = current_value.s; + lookup_cache.value = LOOKUP_VALUE (current_value.m); *ref = current_value.s; return LOOKUP_VALUE (current_value.m); } + lookup_cache.ret = *ref; + lookup_cache.value = LOOKUP_VALUE (undef_map); return LOOKUP_VALUE (undef_map); } @@ -379,6 +405,18 @@ _dl_lookup_versioned_symbol (const char int noexec = elf_machine_lookup_noexec_p (reloc_type); int noplt = elf_machine_lookup_noplt_p (reloc_type); + /* First check if we can find it in the cache. */ + if (__builtin_expect (*ref == lookup_cache_versioned.sym, 0) + && lookup_cache_versioned.map == undef_map + && lookup_cache_versioned.noexec == noexec + && lookup_cache_versioned.noplt == noplt + && lookup_cache_versioned.version == version) + { + ++_dl_num_cache_relocations; + *ref = lookup_cache_versioned.ret; + return lookup_cache_versioned.value; + } + ++_dl_num_relocations; /* Search the relevant loaded objects for a definition. */ @@ -430,6 +468,11 @@ _dl_lookup_versioned_symbol (const char } } + lookup_cache_versioned.sym = *ref; + lookup_cache_versioned.noexec = noexec; + lookup_cache_versioned.noplt = noplt; + lookup_cache_versioned.version = version; + if (__builtin_expect (current_value.s == NULL, 0)) { if (*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK) @@ -440,6 +483,8 @@ _dl_lookup_versioned_symbol (const char : (_dl_argv[0] ?: "<main program>")), make_string (undefined_msg, undef_name, ", version ", version->name ?: NULL)); + lookup_cache_versioned.ret = NULL; + lookup_cache_versioned.value = 0; *ref = NULL; return 0; } @@ -457,6 +502,8 @@ _dl_lookup_versioned_symbol (const char if (__builtin_expect (protected == 0, 1)) { + lookup_cache_versioned.ret = current_value.s; + lookup_cache_versioned.value = LOOKUP_VALUE (current_value.m); *ref = current_value.s; return LOOKUP_VALUE (current_value.m); } @@ -473,10 +520,14 @@ _dl_lookup_versioned_symbol (const char if (protected_value.s == NULL || protected_value.m == undef_map) { + lookup_cache_versioned.ret = current_value.s; + lookup_cache_versioned.value = LOOKUP_VALUE (current_value.m); *ref = current_value.s; return LOOKUP_VALUE (current_value.m); } + lookup_cache_versioned.ret = *ref; + lookup_cache_versioned.value = LOOKUP_VALUE (undef_map); return LOOKUP_VALUE (undef_map); } } @@ -605,7 +656,7 @@ _dl_do_lookup (const char *undef_name, u struct link_map *skip, int noexec, int noplt) { return do_lookup (undef_name, hash, ref, result, scope, i, skip, noexec, - noplt); + noplt); } static int --- libc/elf/rtld.c.jj Thu Aug 23 18:56:24 2001 +++ libc/elf/rtld.c Thu Aug 23 19:00:23 2001 @@ -127,6 +127,7 @@ static hp_timing_t relocate_time; static hp_timing_t load_time; #endif extern unsigned long int _dl_num_relocations; /* in dl-lookup.c */ +extern unsigned long int _dl_num_cache_relocations; /* in dl-lookup.c */ static ElfW(Addr) _dl_start_final (void *arg, struct link_map *bootstrap_map_p, hp_timing_t start_time); @@ -1524,6 +1525,8 @@ print_statistics (void) #endif _dl_debug_printf (" number of relocations: %lu\n", _dl_num_relocations); + _dl_debug_printf (" number of relocations from cache: %lu\n", + _dl_num_cache_relocations); #ifndef HP_TIMING_NONAVAIL /* Time spend while loading the object and the dependencies. */ --- libc/elf/dl-reloc.c.jj Thu Aug 23 18:56:20 2001 +++ libc/elf/dl-reloc.c Thu Aug 23 19:03:26 2001 @@ -89,7 +89,14 @@ cannot make segment writable for relocat : l->l_addr) #include "dynamic-link.h" + /* Start symbol lookup caching for this object. */ + lookup_cache.map = l; + lookup_cache_versioned.map = l; + ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling); + + lookup_cache.map = NULL; + lookup_cache_versioned.map = NULL; if (__builtin_expect (consider_profiling, 0)) { --- libc/sysdeps/generic/ldsodefs.h.jj Thu Aug 23 18:56:39 2001 +++ libc/sysdeps/generic/ldsodefs.h Thu Aug 23 19:04:04 2001 @@ -327,6 +327,20 @@ extern void _dl_map_object_deps (struct /* Cache the locations of MAP's hash table. */ extern void _dl_setup_hash (struct link_map *map) internal_function; +/* This holds symbol lookup cache. */ +struct lookup_cache + { + const ElfW(Sym) *sym; + struct link_map *map; + const struct r_found_version *version; + int noexec; + int noplt; + lookup_t value; + const ElfW(Sym) *ret; + }; + +extern struct lookup_cache lookup_cache, lookup_cache_versioned; + /* Search loaded objects' symbol tables for a definition of the symbol referred to by UNDEF. *SYM is the symbol table entry containing the Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |