mlockall() on freebsd 7.2 + amd64 returns EAGAIN
Sushanth Rai
sushanth_rai at yahoo.com
Tue Apr 10 02:37:13 UTC 2012
Hello,
I have a simple program that links with the math library. The only thing that program does is to call mlockall(MCL_CURRENT | MCL_FUTURE). This call to mlockall fails with EAGAIN. I figured out that kernel vm_fault() is returning KERN_PROTECTION_FAILURE when it tries to fault-in the mmap'ed math library address. But I can't figure why.
The /proc/<mypid>/map returns the following for the process:
0x800634000 0x80064c000 24 0 0xffffff0025571510 r-x 104 52 0x1000 COW NC vnode /lib/libm.so.5
0x80064c000 0x80064d000 1 0 0xffffff016f11c5e8 r-x 1 0 0x3100 COW NNC vnode /lib/libm.so.5
0x80064d000 0x80074c000 4 0 0xffffff0025571510 r-x 104 52 0x1000 COW NC vnode /lib/libm.so.5
Since ntpd calls mlockall with same option and links with math library too, I look at map o/p of ntpd, which looks slightly different "resident" column (3rd column) on 3rd line:
0x800682000 0x80069a000 8 0 0xffffff0025571510 r-x 100 50 0x1000 COW NC vnode /lib/libm.so.5
0x80069a000 0x80069b000 1 0 0xffffff0103b85870 r-x 1 0 0x3100 COW NNC vnode /lib/libm.so.5
0x80069b000 0x80079a000 0 0 0xffffff0025571510 r-x 100 50 0x1000 COW NC vnode /lib/libm.so.5
I don't know if that has anything to do with failure. The snippet of code that returns failure in vm_fault() is the following:
if (fs.pindex >= fs.object->size) {
unlock_and_deallocate(&fs);
return (KERN_PROTECTION_FAILURE);
}
Any help would be appreciated.
Thanks,
Sushanth
More information about the freebsd-hackers
mailing list