Memory-Debuging: How to get locked pages informati

2019-08-30 09:57发布

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.

1条回答
甜甜的少女心
2楼-- · 2019-08-30 10:40

For each page in memory the is flag assigned to it, Virtual memory page is locked using mlock, mlockall() etc API, it assigned the VM_LOCKED flag to page.

Two options to know the locked pages detail:

  1. 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

  2. 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.

查看更多
登录 后发表回答