Satvik
Satvik

Reputation: 11208

mlock stacking in linux

If the same process locks two addresses sharing part of the same page in the memory. Will unlocking one address unlock the shared page? The documentation on lock stacking is pretty unclear about this after the recent version of linux kernel allowing unprivileged processes to lock memory.

Upvotes: 1

Views: 375

Answers (1)

TheCodeArtist
TheCodeArtist

Reputation: 22487

  • Memory locks do not stack, that is, pages which have been locked several times by calls to mlock() or mlockall() will be unlocked by a single call to munlock() for the corresponding range or by munlockall().

  • Pages which are mapped to several locations or by several processes stay locked into RAM as long as they are locked at least at one location or by at least one process.

Reference : Notes of mlock(2) man page.

Upvotes: 2

Related Questions