From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 16 18:41:31 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 81F6F1065673 for ; Mon, 16 Apr 2012 18:41:31 +0000 (UTC) (envelope-from sushanth_rai@yahoo.com) Received: from nm19.bullet.mail.sp2.yahoo.com (nm19.bullet.mail.sp2.yahoo.com [98.139.91.89]) by mx1.freebsd.org (Postfix) with SMTP id 52FBC8FC12 for ; Mon, 16 Apr 2012 18:41:31 +0000 (UTC) Received: from [98.139.91.63] by nm19.bullet.mail.sp2.yahoo.com with NNFMP; 16 Apr 2012 18:41:25 -0000 Received: from [98.139.44.82] by tm3.bullet.mail.sp2.yahoo.com with NNFMP; 16 Apr 2012 18:41:25 -0000 Received: from [127.0.0.1] by omp1019.access.mail.sp2.yahoo.com with NNFMP; 16 Apr 2012 18:41:25 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 319528.1707.bm@omp1019.access.mail.sp2.yahoo.com Received: (qmail 72234 invoked by uid 60001); 16 Apr 2012 18:41:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1334601684; bh=GXmL2gMXEykrxapPPJivO8hjViWNzGf0q/Wm32tf+zs=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=m256cddN8yQ2cWqDLfiYIY81mGdtI4FARQ0taTXMYsssWNk0O+9LHwnqYJwedwom7Cvod+53rLJFEy1oFRFjAF3jJfUv/thHaKcWGc2nt2jSHkjHWZNm1SJiwIfRkEOeh04pDL79Ilrx2VyOzp9H0SA1vT9iUZyE2FSgS4R+7Ns= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=0Ftq1xcT0XmCtdFz1nBfnwN48nwF4Yr4yaRq6oSzwPDShqJ2k5oR+m6he0tS8ib0D8W1uJ99lvE6AjiVhd5FYk6TQpvx86O17zsM/xEWBBE5uosN08aBZw4jm4ucExh+5x+ONQ98KzCrcnmdokBcwImQdl3IozB2J9CsErjzjm8=; X-YMail-OSG: a48na58VM1k4XAFYvtuhiG.6PGtBaCzxkZHbO2IjSZ7akyd h9iU43SC5QeIgQ7bQP5JjUxofblc0giEbiAEekqgXFD2j5BVPlVJZJMTHk5l 4sVS1svE2k79f92WOU79TsQLeBWSfOdx0gsmWzFYYYrLqMAf8Eyyt3VCMjPK IKM8FyrTjhsW6mDUXxVUPamK3JLVbPtvYbsu1CuR7ij5VVlVH0Uzu.eENs6V 9znX3zwI9PrKvc8YHdHHkdAfObaABmApyBbFCBP5pJHDlvmFh9Ha_FnipgwE OqXtsAn.ykaZSsnN8ZvZTUmZkuixwHmKvXhpZI8IO7QxEbpTPbLl8lSq0wrc BDL21WbRkB4tfry83ogk9_3iC0_nZ3xGKtmW_d6fppaC4zVI0MVDnfgfQY7N Wx.ezCzUHrvBu2fk7VllcgbCCewCwPrqe8r82xYvnMf.iIvMFTasKhNiaRv_ UpvrI Received: from [75.62.238.5] by web180001.mail.gq1.yahoo.com via HTTP; Mon, 16 Apr 2012 11:41:24 PDT X-Mailer: YahooMailClassic/15.0.5 YahooMailWebService/0.8.117.340979 Message-ID: <1334601684.58522.YahooMailClassic@web180001.mail.gq1.yahoo.com> Date: Mon, 16 Apr 2012 11:41:24 -0700 (PDT) From: Sushanth Rai To: Konstantin Belousov In-Reply-To: <20120413214536.GL2358@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: alc@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: mlockall() on freebsd 7.2 + amd64 returns EAGAIN X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2012 18:41:31 -0000 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>