From owner-freebsd-stable@FreeBSD.ORG Tue Dec 20 10:10:52 2011 Return-Path: Delivered-To: freebsd-stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0719106564A for ; Tue, 20 Dec 2011 10:10:52 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 1A6878FC0A for ; Tue, 20 Dec 2011 10:10:51 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id MAA25760; Tue, 20 Dec 2011 12:10:48 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1Rcwem-000JCC-3j; Tue, 20 Dec 2011 12:10:48 +0200 Message-ID: <4EF05F27.8030902@FreeBSD.org> Date: Tue, 20 Dec 2011 12:10:47 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:8.0) Gecko/20111206 Thunderbird/8.0 MIME-Version: 1.0 To: Ganael LAPLANCHE References: <20111220080437.M63044@martymac.org> In-Reply-To: <20111220080437.M63044@martymac.org> X-Enigmail-Version: undefined Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: freebsd-stable@FreeBSD.org Subject: Re: Using mmap(2) with a hint address X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2011 10:10:52 -0000 on 20/12/2011 10:08 Ganael LAPLANCHE said the following: > Hi folks, > > I am trying to use mmap(2) with a hint address. Unfortunately, this address > seems to be ignored and I never manage to get the desired one, while it > seems to be free. [snip] > Using MAP_FIXED, I can get the desired address, but it is overkill (it > replaces > any previous mappings and its use is discouraged, see mmap(2)) and > should not > be needed here. > > Am I doing something wrong here ? Can the following code explain what you are seeing? /* * XXX for non-fixed mappings where no hint is provided or * the hint would fall in the potential heap space, * place it after the end of the largest possible heap. * * There should really be a pmap call to determine a reasonable * location. */ PROC_LOCK(td->td_proc); if (addr == 0 || (addr >= round_page((vm_offset_t)vms->vm_taddr) && addr < round_page((vm_offset_t)vms->vm_daddr + lim_max(td->td_proc, RLIMIT_DATA)))) addr = round_page((vm_offset_t)vms->vm_daddr + lim_max(td->td_proc, RLIMIT_DATA)); PROC_UNLOCK(td->td_proc); -- Andriy Gapon