This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH][BZ #15533] Avoid unnecessary slowdown from profiling with audit
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Sat, 25 May 2013 04:22:28 +0400 (MSK)
- Subject: [PATCH][BZ #15533] Avoid unnecessary slowdown from profiling with audit
Hello,
Presently, using the rtld-audit interfaces introduces a slowdown due to
enabling profiling instrumentation (as if LD_AUDIT implied LD_PROFILE).
However, instrumenting is only necessary if one of audit libraries provides
PLT hooks (la_plt{enter,exit} symbols). Otherwise, the slowdown can be
avoided.
In the synthetic test attached to the bugzilla issue, the slowdown is 19x. On
another application I tested, the slowdown from profiling was 10%. The
current behavior strongly discourages using the audit interface when
compromising performance is not desired.
The following patch adjusts the logic that enables profiling to iterate over
all audit modules and check if any of those provides a PLT hook.
I have an FSF copyright assignment as a GCC contributor (but I do not have
commit access in glibc).
Thanks.
2013-05-25 Alexander Monakov <amonakov@ispras.ru>
* elf/dl-reloc.c (_dl_relocate_object): Enable profiling only if one
of audit libraries provides PLT hooks.
diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
index 73d98f8..675e15b 100644
--- a/elf/dl-reloc.c
+++ b/elf/dl-reloc.c
@@ -167,7 +167,16 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
#ifdef SHARED
/* If we are auditing, install the same handlers we need for profiling. */
if ((reloc_mode & __RTLD_AUDIT) == 0)
- consider_profiling |= GLRO(dl_audit) != NULL;
+ {
+ struct audit_ifaces *afct = GLRO(dl_audit);
+ for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
+ {
+ /* Profiling is needed only if PLT hooks are provided. */
+ if (afct->ARCH_LA_PLTENTER != NULL || afct->ARCH_LA_PLTEXIT != NULL)
+ consider_profiling = 1;
+ afct = afct->next;
+ }
+ }
#elif defined PROF
/* Never use dynamic linker profiling for gprof profiling code. */
# define consider_profiling 0
--
1.8.2.1