[PATCH 2/5] elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533)

John Mellor-Crummey johnmc@rice.edu
Wed Jul 7 20:53:45 GMT 2021


Forian is correct that what the HPCToolkit team wants is to use la_symbind without la_ltenter/la_pltexit defined.  We don’t want the overhead from the profiling trampoline just to get the la_symbind call.
--
John Mellor-Crummey		Professor
Dept of Computer Science	Rice University
email: johnmc@rice.edu		phone: 713-348-5179

> On Jul 7, 2021, at 3:15 PM, Florian Weimer <fweimer@redhat.com> wrote:
> 
> * Adhemerval Zanella:
> 
>> On 07/07/2021 16:20, Florian Weimer wrote:
>>> * Adhemerval Zanella via Libc-alpha:
>>> 
>>>> diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c
>>>> index e13a672ade..998cfef099 100644
>>>> --- a/elf/dl-reloc.c
>>>> +++ b/elf/dl-reloc.c
>>>> @@ -181,7 +181,18 @@ _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->symbind != NULL
>>>> +	      || afct->ARCH_LA_PLTENTER != NULL
>>>> +	      || afct->ARCH_LA_PLTEXIT != NULL)
>>>> +	    consider_profiling = 1;
>>>> +	  afct = afct->next;
>>>> +	}
>>>> +    }
>>> 
>>> Is the afct->symbind check really necessary?  Looking at _dl_fixup, it
>>> should be safe to call symbind with just the standard trampoline.
>> 
>> Yes, elf/tst-audit18b check specifically for this.  Without it,
>> returning LA_FLG_BINDFROM | LA_FLG_BINDTO from la_objopen() won't
>> trigger a la_symbind{32,64}.
> 
> Hmm, I'm surprised we get a la_symbind call with BIND_NOW at all.  And
> for BIND_NOW the choice of trampoline really should not matter anyway.
> 
> Anyway, I think we have a feature request that without
> la_ltenter/la_pltexit defined, the presence of la_symbind should not
> incur the overhead from the profiling trampoline.  The afct->symbind
> check defeats that.
> 
> Thanks,
> Florian
> 



More information about the Libc-alpha mailing list