Memory-Debuging: How to get locked pages information in user space/kernel space in linux

ぃ、小莉子 提交于 2019-12-11 15:32:05

问题


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:


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.



来源:https://stackoverflow.com/questions/54984296/memory-debuging-how-to-get-locked-pages-information-in-user-space-kernel-space

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!