[英]How to serve a page fault in the linux kernel?
我正在一個需要在Linux內核中進行大量修改的項目。 在其中一項修改中,我必須更改頁面錯誤處理程序的工作方式。 我想攔截來自特定進程的頁面錯誤,並通過從另一台計算機上復制數據來滿足它們的可能。
第一步,我想編寫一些實驗代碼,這些代碼可以幫助我了解Linux如何滿足頁面錯誤,以及如何告訴該過程當前無法解決頁面錯誤,並且需要在網絡上重試。晚點。
因此,我想以一種有助於我理解以上所有內容的方式修改handle_mm_fault
。 像這樣:
int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long address, unsigned int flags)
{
/* some code */
if(current->pid == my_target_pid)
{
/*
1. Chose randomly between 1 and 2 -> rand_num
2. if rand_num from (1) is 1 then allocate a block of memory, write 'X's to it and then give it to the process and then return.
3. if rand_num from (1) is 2 then tell process to come back later and then return.
*/
}
/* rest of handle_mm_fault for all other process here */
}
您可以看一下struct vm_operations_struct
。 它的功能成員'fault'用於處理頁面錯誤情況
您描述的問題聽起來像頁面要求數據中止。 首先,由於來自內核空間或用戶空間的無效頁面映射,可能會發生數據中止。 handle_mm_fault是為Linux中的用戶空間修復頁表的子例程。 據我所知,您的設計必須涵蓋以下內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.