Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Apr 2012 19:37:11 -0700 (PDT)
From:      Sushanth Rai <sushanth_rai@yahoo.com>
To:        freebsd-hackers@freebsd.org
Subject:   mlockall() on freebsd 7.2 + amd64 returns EAGAIN
Message-ID:  <1334025431.77315.YahooMailClassic@web180011.mail.gq1.yahoo.com>

next in thread | raw e-mail | index | archive | help
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




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