[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: i386 mm



"A. Supreeth Reddy" wrote:
> 
> Hi Joseph,
>                 After reading your doc and seeing the mm/init.c, page_alloc.c code. I have
> the following picture of the VM following the full mm initialisation
> (considering CONFIG_HIGHMEM is not defined).
> 
>                 1 MB mark                                               3Gb mark                3Gb+128Mb                                       4Gb
> 
> +-----------------------------------------+-----------------+---------------
> --------------------+
>                 |       1MB - 3Gb - User memory         |Used for kernel        | 1 Gb - 128Mb mapped
> by kernel       |
>                 |            Not mapped by kernel               | page tables   |Allocated for Zone based
> management|
>                 |Dynamically allocated page_tables???   |                       |Slab kmem_butctl and slabs
> placed  |
>                 |                                                       | vmalloc calls ??| here ???                                    |
> 
> +-----------------------------------------+-----------------+---------------
> --------------------+
> 
>                 Is this correct ?? I know there are many more things missing from above,
> could you tell me which all.
> 
> TIA,
> Sup.
> 
> -
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/
> IRC Channel:   irc.openprojects.net / #kernelnewbies
> Web Page:      http://www.surriel.com/kernelnewbies.shtml

Supreeth,

Your diagram was cut up terribly by my mail client, and I'm not
sure how to reconstruct it, but here's what I believe:

- User VM begins at 4K (since the first virtual page is never
mapped), and extends to 3GB. User processes share (a copy of)
the kernel virtual mapping staring at 3GB.

- Kernel code and data occupy the kernel virtual range starting
at 3GB+1MB, ending at _end_text (I think, don't have the code
in front of me at the moment).

- In 2.2 kernels, it was clear that boot-time memory allocations
were performed simply by (essentially) incrementing _end_text
to reserve additional pages above the loaded kernel,
so it was obvious how that data was laid out relative to the
loaded kernel. I haven't looked at the 2.4 bootmem allocator in
detail, but I assume that in simple cases it does basically
the same thing. So, just above the loaded kernel data you have
the page tables that map as much of physical memory as
possible (all of it, usually, unless you have over 900MB of
memory or so). Then there are pagetables for fixmaps and
(if necessary) kmap(). Then kmem_cache data, and assorted
other boot-time-allocated stuff. So the area reserved by the
kernel extends (in VM) from 3GB+1MB to 3GB+1MB+N, where N
is the size of the kernel image plus all the boot-time-allocated
data. Call that point KERNEL_END.

- The kernel page tables map physical memory starting at 3B, up to
4GB-128MB if necessary; this mapping is permanent for the life
of the system. Physical pages greater than 1GB-128MB
are not mapped; the kernel can only access them using kmap().

- Pages > KERNEL_END and < 4GB-128MB are mapped by the kernel
and managed by the zone allocator; they may be reserved by
the kernel at any time for various purposes (eg, for process
page tables), or may be mapped into process VM at addresses
< 3GB (in which case the process page tables map the page
twice, once at the user virtual address and again at
PAGE_OFFSET+<physical_address>).

- Physical pages that can't be permanently mapped between PAGE_OFFSET
and 4GB-128MB are not mapped by the permanent kernel pagetables,
but may be temporarily mapped into the 4GB-128MB...4GB range using
kmap()/kunmap(). These pages can also be mapped into user
VM in the usual way.

- Some pages containing data that's not used after boot, and
that lie in the PAGE_OFFSET...KERNEL_END range, are freed
by the kernel and available to the zone allocator.

I've been rather busy with other things, but I hope to
get back to documenting the MM within the next couple days.

-- Joe Knapka
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.surriel.com/kernelnewbies.shtml