作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试编写获取页面并在 Linux 内核中将其返回 PTE(页表项)的代码。
函数的原型(prototype)应该是这样的:
static pte_t getPteOfPage(struct page *page);
我试图在页面的struct描述中找到该页面的PTE,但是比较复杂。
谁能告诉我怎么做?
最佳答案
查看 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函数实现,一个很好的例子。
关于linux - 在 linux 中获取页面的 pte,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18591405/
我在 StackOverflow 和其他地方看到了很多与此类似的问题,但没有一个直接解决我的问题。我正在 THREE.js 中使用凸包生成器生成 n 边多面体。我想将方形纹理映射到每个多面体的每个面上
我是一名优秀的程序员,十分优秀!