Linux - 识别拥有物理内存中特定地址的进程

ava*_*lys 4 linux kernel module linux-kernel

在Linux下,如何判断具体进程拥有/正在使用物理内存中的给定地址?

我知道这可能需要编写一个内核模块来访问一些内核数据结构并将结果返回给用户 - 我需要知道它是如何完成的,无论它有多复杂.

Mar*_*son 8

进程使用的页面及其在物理内存中的位置不是静态信息.但是,您寻找的信息应该在页面表中.一个改变走进这可能是几乎一模一样,你要寻找的内核:

author  Arjan van de Ven <arjan@linux.intel.com>    2008-04-17 15:40:45 (GMT) 
committer   Ingo Molnar <mingo@elte.hu>                 2008-04-17 15:40:45 (GMT)
commit  926e5392ba8a388ae32ca0d2714cc2c73945c609 (patch)
tree    2718b50b8b66a3614f47d3246b080ee8511b299e
parent  2596e0fae094be9354b29ddb17e6326a18012e8c (diff) 

x86: add code to dump the (kernel) page tables for visual inspection by kernel developers 

This patch adds code to the kernel to have an (optional)
/proc/kernel_page_tables debug file that basically dumps the kernel
pagetables; this allows us kernel developers to verify that nothing
fishy is going on and that the various mappings are set up correctly.
This was quite useful in finding various change_page_attr() bugs, and
is very likely to be useful in the future as well. 

Signed-off-by:Arjan van de Ven <arjan@linux.intel.com> 
Cc: mingo@elte.hu 
Cc: tglx@tglx.de 
Cc: hpa@zytor.com 
Signed-off-by: Ingo Molnar <mingo@elte.hu> 
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Run Code Online (Sandbox Code Playgroud)

添加的功能由新的配置选项(X86_PTDUMP)启用.