2009-02-24 48 views

回答

8

進程使用的頁面及其在物理內存中的位置不是靜態的信息片段。但是,您所尋求的信息應在page tables之內。一個change走進內核可能是幾乎正是你要尋找的:

author Arjan van de Ven <[email protected]> 2008-04-17 15:40:45 (GMT) 
committer Ingo Molnar <[email protected]>     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 <[email protected]> 
Cc: [email protected] 
Cc: [email protected] 
Cc: [email protected] 
Signed-off-by: Ingo Molnar <[email protected]> 
Signed-off-by: Thomas Gleixner <[email protected]> 

所添加的功能是通過一個新的配置選項(X86_PTDUMP)啓用。

2

可能想要start here來討論進程虛擬內存如何映射到物理內存。這將爲您提供一個很好的開始,以便確定您需要掛鉤到內核以訪問存儲該信息的頁表等。

0

好吧,由於在Linux下完成事情的方式,一個進程可能在一個實例中擁有內存,然後由於分頁而不再存在。

http://en.wikipedia.org/wiki/Paging

本質上講,這意味着計算機切換出來它不會在某一時刻需要,使內存可以用於別的數據。

我不確定這是否有幫助,但我建議您查看頁面表和目錄,因爲您可以使用它們轉換爲物理地址。

0

您可能可以使用pmap -d [pid]這個......不幸的是,您必須在所有進程上運行它以查看哪個返回給定內存地址的結果。當然,它不如內核模塊高效(如果在尋找內存的時候你可能不會得到結果)。

+2

我不相信這是正確的。 `pmap`報告虛擬地址。物理地址僅針對設備進行報告,而不針對使用此命令的主內存進行報告。至少從我所知道的。 – 2010-05-15 10:29:18

相關問題