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 2/2] elf: Use nocancel pread64() instead of lseek()+read()


On 10/3/19 11:31 AM, Yann Droneaud wrote:
> Hi,
> 
> Le lundi 05 août 2019 à 21:56 +0000, Leandro Pereira a écrit :
>> Transforms this, when linking in a shared object:
>>
>>   openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
>>   read(3, "\177ELF\2\1\1\3"..., 832) = 832
>>   lseek(3, 792, SEEK_SET)           = 792
>>   read(3, "\4\0\0\0\24\0\0\0"..., 68) = 68
>>   fstat(3, {st_mode=S_IFREG|0755, st_size=6699224, ...}) = 0
>>   lseek(3, 792, SEEK_SET)           = 792
>>   read(3, "\4\0\0\0\24\0\0\0"..., 68) = 68
>>   lseek(3, 864, SEEK_SET)           = 864
>>   read(3, "\4\0\0\0\20\0\0\0"..., 32) = 32
>>
>> Into this:
>>
>>   openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
>>   read(3, "\177ELF\2\1\1\3"..., 832) = 832
>>   pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) = 68
>>   fstat(3, {st_mode=S_IFREG|0755, st_size=6699224, ...}) = 0
>>   pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) = 68
>>   pread(3, "\4\0\0\0\20\0\0\0"..., 32, 864) = 32
>>
> 
> I confirm the behavior. And the usefulness of the patch.
> 
> Anyway I'm quite surprised ld.so is reading twice 68 bytes at the same
> 792 offset. Moreover, the first read already brought 28 bytes out of
> 68.
> 
> Could these read() be replaced by a call to mmap(), then using mremap()
> to brought the shared object in memory after initial inspection ?

It might be possible. It's an optimization that would probably require
some refactoring and review of the current logic in the DSO loading.

Happy to review patches :-)

-- 
Cheers,
Carlos.


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