- 论坛徽章:
- 0
|
说一下我的理解, 不对之处请指正。
从代码看, virtual 这一项只有在定义了 WANT_PAGE_VIRTUAL时才会被编译, 而这个宏在绝大多数体系结构下都是未定义的。所以virtual这个变量的重要性不大。
注释说它是“内核虚拟地址”: /* Kernel virtual address (NULL if not kmapped, ie. highmem) */
但是实际编程中都是用 page_address() 来获得内核虚拟地址。
直接映射区的页面分配给用户空间,page中的virtual会被修改吗?
不会, 仍然是内核空间的虚拟地址。
高端内存被分配给内核空间和用户空间时,其virtual会如何修改?
会被修改为映射后的内核空间虚拟地址, 跟用户空间地址无关。
如果页面用作多个进程间的共享内存时,其virtual的数值应该如何修改?
不变, 仍然是内核空间的虚拟地址。- /*
- 139 * On machines where all RAM is mapped into kernel address space,
- 140 * we can simply calculate the virtual address. On machines with
- 141 * highmem some memory is mapped into kernel virtual memory
- 142 * dynamically, so we need a place to store that address.
- 143 * Note that this field could be 16 bits on x86 ... ;)
- 144 *
- 145 * Architectures with slow multiplication can define
- 146 * WANT_PAGE_VIRTUAL in asm/page.h
- 147 */
- 148#if defined(WANT_PAGE_VIRTUAL)
- 149 void *virtual; /* Kernel virtual address (NULL if
- 150 not kmapped, ie. highmem) */
- 151#endif /* WANT_PAGE_VIRTUAL */
复制代码 另:
在宏WANT_PAGE_VIRTUAL有定义时,page_address()直接返回virtual的值:- #if defined(WANT_PAGE_VIRTUAL)
- #define page_address(page) ((page)->virtual)
复制代码 而通常情况WANT_PAGE_VIRTUAL未定义,page_address()需要计算, 见highmem.c里面的page_address()函数。
|
|