Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Apr 2012 11:41:24 -0700 (PDT)
From:      Sushanth Rai <sushanth_rai@yahoo.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        alc@freebsd.org, freebsd-hackers@freebsd.org
Subject:   Re: mlockall() on freebsd 7.2 + amd64 returns EAGAIN
Message-ID:  <1334601684.58522.YahooMailClassic@web180001.mail.gq1.yahoo.com>
In-Reply-To: <20120413214536.GL2358@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
Many thanks. I verified the patch you provided and it works fine.=0A=0ASush=
anth=0A=0A=0A> Oh, I see. The problem is the VM_MAP_WIRE_NOHOLES flag.=0A> =
Since we=0A> map only the initial stack fragment even for the=0A> MCL_WIREF=
UTURE maps,=0A> there is a hole in the stack region.=0A> =0A> In fact, for =
MCL_WIREFUTURE, we probably should map the=0A> whole=0A> stack at once, pre=
faulting all pages.=0A> =0A> Below are two patches. The change for vm_mmap.=
c would fix=0A> your immediate=0A> problem by allowing holes in wired regio=
n.=0A> =0A> The change for vm_map.c prefaults the whole stack instead of=0A=
> the=0A> initial fragment. The single-threaded programs still get a=0A> fa=
ult=0A> on stack growth.=0A> =0A> diff --git a/sys/vm/vm_map.c b/sys/vm/vm_=
map.c=0A> index 6198629..2fd18d1 100644=0A> --- a/sys/vm/vm_map.c=0A> +++ b=
/sys/vm/vm_map.c=0A> @@ -3259,7 +3259,10 @@ vm_map_stack(vm_map_t map,=0A> =
vm_offset_t addrbos, vm_size_t max_ssize,=0A>  =A0=A0=A0 =A0 =A0 addrbos + =
max_ssize <=0A> addrbos)=0A>  =A0=A0=A0 =A0=A0=A0 return=0A> (KERN_NO_SPACE=
);=0A>  =0A> -=A0=A0=A0 init_ssize =3D (max_ssize < sgrowsiz) ?=0A> max_ssi=
ze : sgrowsiz;=0A> +=A0=A0=A0 if (map->flags & MAP_WIREFUTURE)=0A> +=A0=A0=
=A0 =A0=A0=A0 init_ssize =3D=0A> max_ssize;=0A> +=A0=A0=A0 else=0A> +=A0=A0=
=A0 =A0=A0=A0 init_ssize =3D=0A> (max_ssize < sgrowsiz) ? max_ssize : sgrow=
siz;=0A>  =0A>  =A0=A0=A0 PROC_LOCK(curthread->td_proc);=0A>  =A0=A0=A0 vme=
mlim =3D lim_cur(curthread->td_proc,=0A> RLIMIT_VMEM);=0A> diff --git a/sys=
/vm/vm_mmap.c b/sys/vm/vm_mmap.c=0A> index 2588c85..3fccd9e 100644=0A> --- =
a/sys/vm/vm_mmap.c=0A> +++ b/sys/vm/vm_mmap.c=0A> @@ -1561,9 +1561,11 @@ vm=
_mmap(vm_map_t map, vm_offset_t=0A> *addr, vm_size_t size, vm_prot_t prot,=
=0A>  =A0=A0=A0 =A0=A0=A0=A0=A0* If the=0A> process has requested that all =
future mappings=0A>  =A0=A0=A0 =A0=A0=A0=A0=A0* be=0A> wired, then heed thi=
s.=0A>  =A0=A0=A0 =A0=A0=A0=A0=A0*/=0A> -=A0=A0=A0 =A0=A0=A0 if (map->flags=
=0A> & MAP_WIREFUTURE)=0A> +=A0=A0=A0 =A0=A0=A0 if (map->flags=0A> & MAP_WI=
REFUTURE) {=0A>  =A0=A0=A0 =A0=A0=A0 =A0=A0=A0=0A> vm_map_wire(map, *addr, =
*addr + size,=0A> -=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=0A> =A0 =A0 VM_MAP_WIRE_US=
ER | VM_MAP_WIRE_NOHOLES);=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=0A> =A0 =A0 V=
M_MAP_WIRE_USER | ((flags & MAP_STACK) ?=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=
=0A> =A0 =A0 VM_MAP_WIRE_HOLESOK : VM_MAP_WIRE_NOHOLES));=0A> +=A0=A0=A0 =
=A0=A0=A0 }=0A>  =A0=A0=A0 } else {=0A>  =A0=A0=A0 =A0=A0=A0 /*=0A>  =A0=A0=
=A0 =A0=A0=A0=A0=A0* If this=0A> mapping was accounted for in the vnode's=
=0A> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1334601684.58522.YahooMailClassic>