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] |
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?
Andreas
2001-08-23 Jakub Jelinek <jakub@redhat.com>
* elf/dl-lookup.c (_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: Define lookup_cache for holding
symbol cache entries.
============================================================
Index: elf/dl-lookup.c
--- elf/dl-lookup.c 2001/08/23 06:02:45 1.79
+++ elf/dl-lookup.c 2001/08/23 13:00:36
@@ -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;
+
/* Search loaded objects' symbol tables for a definition of the symbol
UNDEF_NAME. */
@@ -201,6 +204,18 @@ _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
+ && lookup_cache.version == NULL)
+ {
+ ++_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 +244,11 @@ _dl_lookup_symbol (const char *undef_nam
break;
}
+ lookup_cache.sym = *ref;
+ lookup_cache.noexec = noexec;
+ lookup_cache.noplt = noplt;
+ lookup_cache.version = NULL;
+
if (__builtin_expect (current_value.s == NULL, 0))
{
if (*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
@@ -238,6 +258,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 +276,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 +294,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 +407,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.sym, 0)
+ && lookup_cache.map == undef_map
+ && lookup_cache.noexec == noexec
+ && lookup_cache.noplt == noplt
+ && lookup_cache.version == version)
+ {
+ ++_dl_num_cache_relocations;
+ *ref = lookup_cache.ret;
+ return lookup_cache.value;
+ }
+
++_dl_num_relocations;
/* Search the relevant loaded objects for a definition. */
@@ -430,6 +470,11 @@ _dl_lookup_versioned_symbol (const char
}
}
+ lookup_cache.sym = *ref;
+ lookup_cache.noexec = noexec;
+ lookup_cache.noplt = noplt;
+ lookup_cache.version = version;
+
if (__builtin_expect (current_value.s == NULL, 0))
{
if (*ref == NULL || ELFW(ST_BIND) ((*ref)->st_info) != STB_WEAK)
@@ -440,6 +485,8 @@ _dl_lookup_versioned_symbol (const char
: (_dl_argv[0] ?: "<main program>")),
make_string (undefined_msg, undef_name,
", version ", version->name ?: NULL));
+ lookup_cache.ret = NULL;
+ lookup_cache.value = 0;
*ref = NULL;
return 0;
}
@@ -457,6 +504,8 @@ _dl_lookup_versioned_symbol (const char
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);
}
@@ -473,10 +522,14 @@ _dl_lookup_versioned_symbol (const char
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);
}
}
@@ -605,7 +658,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
============================================================
Index: elf/dl-reloc.c
--- elf/dl-reloc.c 2001/08/11 08:51:49 1.55
+++ elf/dl-reloc.c 2001/08/23 13:00:36
@@ -89,7 +89,12 @@ cannot make segment writable for relocat
: l->l_addr)
#include "dynamic-link.h"
+ /* Start symbol lookup caching for this object. */
+ lookup_cache.map = l;
+
ELF_DYNAMIC_RELOCATE (l, lazy, consider_profiling);
+
+ lookup_cache.map = NULL;
if (__builtin_expect (consider_profiling, 0))
{
============================================================
Index: elf/rtld.c
--- elf/rtld.c 2001/08/11 07:27:31 1.202
+++ elf/rtld.c 2001/08/23 13:00:36
@@ -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. */
============================================================
Index: sysdeps/generic/ldsodefs.h
--- sysdeps/generic/ldsodefs.h 2001/08/23 06:02:46 1.28
+++ sysdeps/generic/ldsodefs.h 2001/08/23 13:00:36
@@ -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;
+
/* Search loaded objects' symbol tables for a definition of the symbol
referred to by UNDEF. *SYM is the symbol table entry containing the
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |