Why? Why SetPageReserved is needed when map a kernel space to user space?
I am confused by this question for long time, no clear answer about this question when google, the only anser is SetPageReserved is used to prevent the page mapped into user space swapping out!! But the page is also mapped by a kernel virtual address, how can it be swapped out? In other word, if I don't use SetPageReserved when I remap a kernel virtual address into user space, what's the bad result???? Thanks very much!! |
Quote:
PS: If you're not already familiar with them, Google for the kernel APIs copy_from_user()/copy_to_user(), and the user-space API "mmap()". In general, the kernel isn't allowed to access user-space memory directly. |
Quote:
|
User space don't know that these virtual address is from kernel space. They will be swapped out when they think it is necessary.
|
Quote:
|
When user space do mmap, it will map kernel memory to user space normally and call SetPageReserved. For your case, I don't see any different from normal case.
|
Quote:
|
Strange, but it is
Quote:
|
As noted, this bit stops a "race condition" that could otherwise exist between this code and the swapper. If two pieces of code (the user, and the kernel) are relying upon a particular physical-page, that page is now a shared resource between the two for the duration, and it is necessary to guarantee that the page will not be "stolen" in the meantime. The bit indicates among other things that this page is not a candidate for stealing.
|
Though the pages are reserved via a kernel driver, it is meant to be accessed via user space. As a result, the PTE (page table entries) do not know if the pfn belongs to user space or kernel space (even though they are allocated via kernel driver).
This is why they are marked with SetPageReserved. |
All times are GMT -5. The time now is 04:37 AM. |