Date: Tue, 20 Dec 2011 12:10:47 +0200 From: Andriy Gapon <avg@FreeBSD.org> To: Ganael LAPLANCHE <ganael.laplanche@martymac.org> Cc: freebsd-stable@FreeBSD.org Subject: Re: Using mmap(2) with a hint address Message-ID: <4EF05F27.8030902@FreeBSD.org> In-Reply-To: <20111220080437.M63044@martymac.org> References: <20111220080437.M63044@martymac.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4EF05F27.8030902>
