Is there any way to get locked pages(virtual memory pages) information in user space/kernel space in linux .
I want to know details like: Who locked the pages ? how many pages are locked ? Process name who locked the page ?
Also let me know the memory debugging techniques in kernel space as well as user space.
For each page in memory the is flag assigned to it, Virtual memory page is locked using
mlock
,mlockall()
etc API, it assigned theVM_LOCKED
flag to page.Two options to know the locked pages detail:
Use cat
/sys/kernel/debug/page_owner >> page_owner.txt
To enable debug:kernel menuconfig PAGE_OWNER=y
add"page_owner=on"
to boot cmdline.cat /sys/kernel/debug/page_owner >> page_owner.txt
In linux source code type:
/tool/vm/page-types.c
, then compile it and iterate through all pid entries in/proc/
and use the following option for application:./test -p $PID -L >> test_output.txt
. It will give you all page details with flags, then you can find locked pages in memory.