The page fault loop for the same address happens in my UML. But for both my UML and the mainline (I am using 3.7.1) kernel, the addresses that trigger the page fault (in the child thread) are covered by certain vm areas. I use gdb to trace the function call and notice that mmap_region() is never called during the execution of the child task. I am guessing it's because the child task does not use large enough memory space to have the UML installed mapping for it.

The major change I did to my kernel is to modify the vm areas pointers of certain child tasks to share the vm area structure of its parent task. So the parent task's vm areas are shared (as long as VM_DONTCOPY is not set) among some of its child tasks.

On Thu, Apr 11, 2013 at 9:04 AM, richard -rw- weinberger <> wrote:
On Thu, Apr 11, 2013 at 6:15 AM, Terry Hsu <> wrote:
> Hi Richard, thanks for replying. I did go back to see the code and try to
> understand what exactly is going on in UML, but still no luck.
> The faulted address is covered by one of the vm areas of the task, so it
> passed the vma sanity check at the beginning of handle_page_fault(). I print
> out the PTEs of the task and I notice one strange thing: when the fault
> happens for the first time, the PTE does not exist; the PTE is present when
> the second fault happens for the same address (but still a page fault); in
> the third page fault (same address), the PTE does not exist anymore.
> So in my case, the faulted address does not require a new vma to be
> installed.

But this is a feature added by you?
We are not talking about a mainline kernel, right? 

> Also I've looked into copy_mm() to see how pages are copied from parent task
> to its child. I do not understand the purpose of the  the special mapping
> installed by UML. It seems that every new task with a new mm_struct will
> have one special mapping at the head of its vma list.

The special mapping (the SKAS stub) is needed to install new mapping
from the host
side of UML.
Currently the stub pages have a vma, this will go away such that they
have only a PTE.