From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 13 20:17:57 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39B08106566B for ; Wed, 13 Jun 2012 20:17:57 +0000 (UTC) (envelope-from alan.l.cox@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 03DC28FC15 for ; Wed, 13 Jun 2012 20:17:56 +0000 (UTC) Received: by pbbro2 with SMTP id ro2so2946338pbb.13 for ; Wed, 13 Jun 2012 13:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=7ZkN7AZfnLIi7Oztf3jG+UBAiXY+AfatK7aQSFjxce8=; b=E0ruN/fPPlc45VYk6T5dBjad5IQJvyQGj+fPOJay2R+tDaF94PSCg9Lg3zWyE4DUA5 9LFrf9euXqEX3IVX4DIkbZZguD2ivZ05/6BLCanvW89atbRGCIISRVdHbyKWTOPI53QW 5Xdv7cs8gcnMPFXtaHrRZRtFdHm5ox1J2upc4TyY+6nlRXODbjRyFgEnnYgEc9yQajyl OilEY41K7AM39kiS3kg6U6KBYVXVXUNUtWukRq9Q3fezwDJjrcxO+jao3+jwjY4tb6Ut Gg9noaavq9326St032zR8LU29Lf5ZFeF1P9PZicuG9zS7X1qeqB9p7z5UrlEdM69DWBF eSDA== MIME-Version: 1.0 Received: by 10.68.132.201 with SMTP id ow9mr53823163pbb.160.1339618676484; Wed, 13 Jun 2012 13:17:56 -0700 (PDT) Received: by 10.68.226.7 with HTTP; Wed, 13 Jun 2012 13:17:56 -0700 (PDT) In-Reply-To: <20120613191205.GU2337@deviant.kiev.zoral.com.ua> References: <1339259223.36051.328.camel@revolution.hippie.lan> <20120609165217.GO85127@deviant.kiev.zoral.com.ua> <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> Date: Wed, 13 Jun 2012 15:17:56 -0500 Message-ID: From: Alan Cox To: Konstantin Belousov Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Ian Lepore , freebsd-hackers@freebsd.org, Wojciech Puchar Subject: Re: Rtld object tasting [Was: Re: wired memory - again!] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: alc@freebsd.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 20:17:57 -0000 On Wed, Jun 13, 2012 at 2:12 PM, Konstantin Belousov 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 > 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