• Andi Kleen's avatar
    [PATCH] Fix small vmalloc per allocation limit · 1dbd4652
    Andi Kleen authored
    The vmap vmalloc rework in 2.5 had a unintended side effect.  vmalloc uses
    kmalloc now to allocate an array with a list of pages.  kmalloc has a 128K
    maximum.  This limits the vmalloc maximum size to 64MB on a 64bit system
    with 4K pages.  That limit causes problems with other subsystems, e.g.
    iptables relies on allocating large vmallocs for its rule sets.
    
    This is a bug IMHO - on 64bit platforms there shouldn't be such a low limit
    on the vmalloc size.  And even on 32bit it's too small for custom kernels
    with enlarged vmalloc area.
    
    Another problem is that this makes vmalloc unreliable.  After the system
    has been running for some time it is unlikely that kmalloc will be able to
    allocate >order 2 pages due to memory fragmentation.
    
    This patch takes the easy way out for fixing this by just allocating this
    array with vmalloc when it is larger than a page.  While more complicated
    and intrusive solutions would be possible they didn't use vmalloc
    recursively they didn't seem it worth to handle this very infrequent case.
    
    Please note that the vmalloc recursion is strictly bounded because each
    nested allocation will generate a much smaller stack frame.  Also the
    kernel stack can handle even a few recursion steps easily because vmalloc
    has only a small stack frame.
    Signed-off-by: default avatarAndi Kleen <ak@suse.de>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    1dbd4652
vmalloc.c 13.8 KB