2013-09-03 3 views
1

페이지를 가져 와서 Linux 커널에서 PTE (페이지 테이블 항목)를 반환하는 코드를 작성하려고합니다.리눅스에서 페이지를 가져옵니다.

함수의 프로토 타입은 다음과 같이해야한다 :

static pte_t getPteOfPage(struct page *page); 

내가 페이지의 구조체 설명에서 페이지의 PTE를 찾으려고하지만, 더 복잡하다.

누구든지 어떻게 할 수 있습니까?

+0

try_to_unmap()을 확인하십시오. 한 페이지를 다른 프로세스 공간에 매핑 할 수 있으므로 페이지에 많은 ptes가있을 수 있습니다. – firo

답변

1

walk_page_range 기능을 살펴 보는 좋은 출발점입니다.

/** 
143 * walk_page_range - walk a memory map's page tables with a callback 
144 * @addr: starting address 
145 * @end: ending address 
146 * @walk: set of callbacks to invoke for each level of the tree 
147 * 
148 * Recursively walk the page table for the memory area in a VMA, 
149 * calling supplied callbacks. Callbacks are called in-order (first 
150 * PGD, first PUD, first PMD, first PTE, second PTE... second PMD, 
151 * etc.). If lower-level callbacks are omitted, walking depth is reduced. 
152 * 
153 * Each callback receives an entry pointer and the start and end of the 
154 * associated range, and a copy of the original mm_walk for access to 
155 * the ->private or ->mm fields. 
156 * 
157 * Usually no locks are taken, but splitting transparent huge page may 
158 * take page table lock. And the bottom level iterator will map PTE 
159 * directories from highmem if necessary. 
160 * 
161 * If any callback returns a non-zero value, the walk is aborted and 
162 * the return value is propagated back to the caller. Otherwise 0 is returned. 
163 * 
164 * walk->mm->mmap_sem must be held for at least read if walk->hugetlb_entry 
165 * is !NULL. 
166 */ 

좋은 예를 들면 walk_page_range 함수 구현을 참조하십시오.

+0

함수'pte_page()'는 페이지의'pte_t'를 반환하지만 x86에서는 그렇지 않습니다. 거기에 또 다른 기능이 있습니까? – Ygandelsman

관련 문제