Page table queries

Mulyadi Santosa mulyadi.santosa at gmail.com
Sat Feb 19 03:40:02 EST 2011


Hi :)

I'll try to help...

On Sat, Feb 19, 2011 at 13:10, anish singh <anish198519851985 at gmail.com> wrote:
> As i understood whenver a user space program is run it is represented in
> kernel using VMA which is managed by struct mm_struct
> and whenever the program is trying to read/write to a memory location in
> user space it will be directed to physical address using PAGE TABLE
> translation done by struct mm_struct(done in kernel space).Am i right?

i think not "done" but mm_struct points to PGD that represent's the
whole process address space. Using information provided there, MMU
does translation.

> Suppose a simple driver wants the user to directly access its device memory
> then we use mmap.This mmap associates a set of user space virtual address
> with device driver memory and it is done by creating kernel page tables for
> the user space virtual addresses.Is the page table translation done
> everytime whenever user space does read/write to the device memory??

if it's recently translated, quite likely it is already cached in TLB
(translation look aside buffer)

> In .nopage function call we return the page associated with the physical
> address which the user wants to associate with user space virtual address.Is
> the page address returned by the nopage function same as seen by the user or
> will it be converted to user space virtual address(range between 0-2 GB)?

AFAIK, nopage is one of the functions that handle minor page fault, no?

Anyway, memory allocation, usually start by kernel allocates a page.
Then it is "handed" to user space memory allocator.

So, in the start, the page might have kernel mode address, but in the
end it has user mode address. But kernel is still the one that tracks
all the page...be it anonymous or non anonymous ones.

Does it help? :)



-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com



More information about the Kernelnewbies mailing list