contigmalloc for low address in SI_SUB_KMEM

Matthew Dillon dillon at apollo.backplane.com
Tue Sep 9 23:12:02 PDT 2003


:I'm slowly beginning to understand what's happening there; pmap_init()
:tries to allocate about 1.7Mbytes of memory block via kmem_alloc(),
:and as kmem_alloc() calls vm_page_grab() with VM_ALLOC_ZERO, lower
:addresses are consumed first(because free blocks are queued in descending
:order at the bottom of vm_page_startup(), I suppose).
:
:My workaround at the moment is to allocate some amount of memory by
:kmem_alloc() in vm_mem_init() before pmap_init(), and mem_free() it
:afterwards.

    I think the correct solution is going to be to modify vm_add_new_page()
    to alternate.  The first page it adds to the head, the next page it
    adds to the tail, and so forth.  We would then fix vm_page_startup()
    to add pages starting with low memory and moving upwards.

    The result will be that low physical addresses will be in the middle
    of the list and thus initial allocations (whether VM_ALLOC_ZERO or not)
    will always get higher addresses.  For those people who aren't familiar
    with the VM system, pre-zero'd pages are allocated from one end of
    hash bucket's list while potentially non-zero'd pages are allocated from
    the other end.

    I'm at BSDCon so this may not get fixed until Saturday, but the solution
    is straightforward.

							-Matt






More information about the Bugs mailing list