Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Apr 2012 18:33:44 -0700 (PDT)
From:      Sushanth Rai <sushanth_rai@yahoo.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: mlockall() on freebsd 7.2 + amd64 returns EAGAIN
Message-ID:  <1334108024.348.YahooMailClassic@web180005.mail.gq1.yahoo.com>
In-Reply-To: <20120410095726.GU2358@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
=0A> > I don't know if that has anything to do with failure.=0A> The snippe=
t of code that returns failure in vm_fault() is=0A> the following:=0A> > =
=0A> > if (fs.pindex >=3D fs.object->size) {=0A> >=A0 =A0=0A> =A0=A0=A0unlo=
ck_and_deallocate(&fs);=0A> >=A0 =A0 =A0=A0=A0return=0A> (KERN_PROTECTION_F=
AILURE);=0A> > }=0A> > =0A> > Any help would be appreciated.=0A> =0A> This =
might be a bug fixed in r191810, but I am not sure.=0A> =0A=0AI tried that =
fix but it didn't work. What seems to happen is that libm is mmap'ed beyond=
 the size of the file. From truss o/p, I see the following:=0A=0Aopen("/lib=
/libm.so.5",O_RDONLY,030577200)=09 =3D 3 (0x3)=0Afstat(3,{ mode=3D-r--r--r-=
- ,inode=3D918533,size=3D115560,blksize=3D4096 }) =3D 0 (0x0)=0Aread(3,"\^?=
ELF\^B\^A\^A\t\0\0\0\0\0\0\0"...,4096) =3D 4096 (0x1000)=0Ammap(0x0,1155072=
,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_NOCORE,3,0x0) =3D 34366242816 (0x80063=
4000)=0A=0ASo the size of the file is 115560 but mmap() length is 1155072. =
The memory map of the file corresponding to libm as seen from running 'cat =
/proc/<mypid>/map' is the following:=0A=0A0x800634000 0x80064c000 24 0 0xff=
ffff002553eca8 r-x 108 54 0x0 COW NC vnode /lib/libm.so.5=0A0x80064c000 0x8=
0064d000 1 0 0xffffff01d79b0a20 r-x 1 0 0x3100 COW NNC vnode /lib/libm.so.5=
=0A0x80064d000 0x80074c000 3 0 0xffffff002553eca8 r-x 108 54 0x0 COW NC vno=
de /lib/libm.so.5=0A0x80074c000 0x80074e000 2 0 0xffffff01d79f1288 rw- 1 0 =
0x3100 COW NNC vnode /lib/libm.so.5=0A=0A=0Awhen the program tries to fault=
-in all the pages as part of call to mlockall(), the following check in vm_=
fault() fails when trying to fault-in 0x800651000.=0A=0Aif (fs.pindex >=3D =
fs.object->size) {=0A     unlock_and_deallocate(&fs);=0A     return (KERN_P=
ROTECTION_FAILURE);=0A}=0A=0Asince the object size corresponds to size of l=
ibm and fault address is one page beyond the object size. Is this a bug ?=
=0A=0AThanks,=0ASushanth=0A=0A



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