From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121513 invoked by alias); 3 Oct 2019 17:10:30 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 121505 invoked by uid 89); 3 Oct 2019 17:10:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1 spammy=H*i:sk:ef6eb54, H*f:sk:ef6eb54, H*MI:sk:ef6eb54 X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1570122627; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=in97xPh+R7EiKpqbcq7+7Y6mTTt2rs62Dd+76eW2c+w=; b=DBR1SjveEp9jh6KLJr22zyjCKFuE9DA9Ootq2pwcFaLtF2NMCiyx8lomd15UDf4IES8m6F 6E70XLlrAZBFSYVnQZ8sTDWC2XBV+CIx66XFWoDcSarbifDj96XEYGss5UeYQA5Zv+9PuA G3i3xQqvMleY4RO96B7pqkqnyh4ak6k= Return-Path: Subject: Re: [PATCH 2/2] elf: Use nocancel pread64() instead of lseek()+read() To: Yann Droneaud , "libc-alpha@sourceware.org" Cc: Leandro Pereira References: From: Carlos O'Donell Message-ID: Date: Thu, 03 Oct 2019 17:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2019-10/txt/msg00069.txt.bz2 On 10/3/19 11:31 AM, Yann Droneaud wrote: > Hi, >=20 > Le lundi 05 ao=C3=BBt 2019 =C3=A0 21:56 +0000, Leandro Pereira a =C3=A9cr= it : >> Transforms this, when linking in a shared object: >> >> openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) =3D 3 >> read(3, "\177ELF\2\1\1\3"..., 832) =3D 832 >> lseek(3, 792, SEEK_SET) =3D 792 >> read(3, "\4\0\0\0\24\0\0\0"..., 68) =3D 68 >> fstat(3, {st_mode=3DS_IFREG|0755, st_size=3D6699224, ...}) =3D 0 >> lseek(3, 792, SEEK_SET) =3D 792 >> read(3, "\4\0\0\0\24\0\0\0"..., 68) =3D 68 >> lseek(3, 864, SEEK_SET) =3D 864 >> read(3, "\4\0\0\0\20\0\0\0"..., 32) =3D 32 >> >> Into this: >> >> openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) =3D 3 >> read(3, "\177ELF\2\1\1\3"..., 832) =3D 832 >> pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) =3D 68 >> fstat(3, {st_mode=3DS_IFREG|0755, st_size=3D6699224, ...}) =3D 0 >> pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) =3D 68 >> pread(3, "\4\0\0\0\20\0\0\0"..., 32, 864) =3D 32 >> >=20 > I confirm the behavior. And the usefulness of the patch. >=20 > 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. >=20 > 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 :-) --=20 Cheers, Carlos.