• G
    mtd: create function to perform large allocations · 33b53716
    Grant Erickson 提交于
    Introduce a common function to handle large, contiguous kmalloc buffer
    allocations by exponentially backing off on the size of the requested
    kernel transfer buffer until it succeeds or until the requested
    transfer buffer size falls below the page size.
    
    This helps ensure the operation can succeed under low-memory, highly-
    fragmented situations albeit somewhat more slowly.
    
    Artem: so this patch solves the problem that the kernel tries to kmalloc too
    large buffers, which (a) may fail and does fail - people complain about this,
    and (b) slows down the system in case of high memory fragmentation, because
    the kernel starts dropping caches, writing back, swapping, etc. But we do not
    really have to allocate a lot of memory to do the I/O, we may do this even with
    as little as one min. I/O unit (NAND page) of RAM. So the idea of this patch is
    that if the user asks to read or write a lot, we try to kmalloc a lot, with GFP
    flags which make the kernel _not_ drop caches, etc. If we can allocate it - good,
    if not - we try to allocate twice as less, and so on, until we reach the min.
    I/O unit size, which is our last resort allocation and use the normal
    GFP_KERNEL flag.
    
    Artem: re-write the allocation function so that it makes sure the allocated
    buffer is aligned to the min. I/O size of the flash.
    Signed-off-by: NGrant Erickson <marathon96@gmail.com>
    Tested-by: NBen Gardiner <bengardiner@nanometrics.ca>
    Tested-by: NStefano Babic <sbabic@denx.de>
    Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
    Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
    33b53716
mtd.h 12.2 KB