When accessing a given address, how does the Linux kernel know that a particular page is mmaped?
-
I want to know, given an address X, how does the Linux kernel figure out that X is an mmaped page? Is there a special flag in the page table entry? Does the access generate a page fault ? If so, how does the handler find out it is an mmaped address?
-
Answer:
When you first access an mmaped page, the page fault handler runs. On most architectures, this invokes an architecture-specific function named do_page_fault(). This function checks some basics: Is this kernel memory? If not, are we in an interrupt handler? If not, the kernel attempts to find the memory range within one of the vm_area_struct structures associated with this process's address space. The vm_area_struct structure describes regions of the process address space that share page fault behaviorâfor example, paging in an mmaped file. The kernel calls these regions virtual memory areas or VMAs. If a VMA containing the faulted address exists and is valid for the type of access performed, the kernel then invokes handle_mm_fault() to perform whatever action is needed to page in the contents of the requested page. The vm_area_struct will describe the mmaped file and allow handle_mm_fault() to page in the requisite data. The short summary: Yes, a page fault occurs and the page fault handler is executed. The fact that the memory address corresponds to an mmaped page is noted by the vm_area_struct structure for that particular address.
Robert Love at Quora Visit the source
Related Q & A:
- How to boot linux kernel without bootloader?Best solution by Super User
- How to deal with timeout when accessing a web service?Best solution by Stack Overflow
- How to sort a particular page in gridview?Best solution by dotnetfox.com
- How can I find out who owns a particular Yahoo email address?Best solution by Yahoo! Answers
- How can I find out who owns a particular email address?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.