Date: Wed, 13 Jun 2012 15:17:56 -0500 From: Alan Cox <alan.l.cox@gmail.com> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Ian Lepore <freebsd@damnhippie.dyndns.org>, freebsd-hackers@freebsd.org, Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl> Subject: Re: Rtld object tasting [Was: Re: wired memory - again!] Message-ID: <CAJUyCcPHjfJss0QhNCYnTy_30m5Sc5V-RJH_LpzDJbxas0ybzA@mail.gmail.com> In-Reply-To: <20120613191205.GU2337@deviant.kiev.zoral.com.ua> References: <alpine.BSF.2.00.1206090920030.84632@wojtek.tensor.gdynia.pl> <1339259223.36051.328.camel@revolution.hippie.lan> <20120609165217.GO85127@deviant.kiev.zoral.com.ua> <alpine.BSF.2.00.1206092244550.9248@wojtek.tensor.gdynia.pl> <1339512694.36051.362.camel@revolution.hippie.lan> <20120612204508.GP2337@deviant.kiev.zoral.com.ua> <1339593249.73426.5.camel@revolution.hippie.lan> <20120613191205.GU2337@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jun 13, 2012 at 2:12 PM, Konstantin Belousov <kostikbel@gmail.com>wrote: > On Wed, Jun 13, 2012 at 07:14:09AM -0600, Ian Lepore wrote: > > http://lists.freebsd.org/pipermail/freebsd-arm/2012-January/003288.html > > The map_object.c patch is step in the almost right direction, I wanted > to remove the static page-sized buffer from get_elf_header for long time. > It works because rtld always holds bind_lock exclusively while loading > an object. There is no need to copy the first page after it is mapped. > > commit 0f6f8629af1345acded7c0c685d3ff7b4d9180d6 > Author: Konstantin Belousov <kib@freebsd.org> > Date: Wed Jun 13 22:04:18 2012 +0300 > > Eliminate the static buffer used to read the first page of the mapped > object, and eliminate the pread(2) call as well. Mmap the first page > of the object temporaly, and unmap it on error or last use. > > Fix several cases were the whole mapping of the object leaked on error. > > Potentially, this leaves one-page gap between succeeding dlopen(3), > but there are other mmap(2) consumers as well. > > I suggest adding MAP_PREFAULT_READ to the mmap(2) call. A heuristic in vm_map_pmap_enter() would trigger automatic mapping for small files, but if the object file is larger than 96 pages then you need to explicitly specific MAP_PREFAULT_READ. Alan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJUyCcPHjfJss0QhNCYnTy_30m5Sc5V-RJH_LpzDJbxas0ybzA>