28 Oct, 2016

1 commit

  • gen_pool_alloc_algo() iterates over the chunks of a pool trying to find
    a contiguous block of memory that satisfies the allocation request.

    The shortcut

    if (size > atomic_read(&chunk->avail))
    continue;

    makes the loop skip over chunks that do not have enough bytes left to
    fulfill the request. There are two situations, though, where an
    allocation might still fail:

    (1) The available memory is not contiguous, i.e. the request cannot
    be fulfilled due to external fragmentation.

    (2) A race condition. Another thread runs the same code concurrently
    and is quicker to grab the available memory.

    In those situations, the loop calls pool->algo() to search the entire
    chunk, and pool->algo() returns some value that is >= end_bit to
    indicate that the search failed. This return value is then assigned to
    start_bit. The variables start_bit and end_bit describe the range that
    should be searched, and this range should be reset for every chunk that
    is searched. Today, the code fails to reset start_bit to 0. As a
    result, prefixes of subsequent chunks are ignored. Memory allocations
    might fail even though there is plenty of room left in these prefixes of
    those other chunks.

    Fixes: 7f184275aa30 ("lib, Make gen_pool memory allocator lockless")
    Link: http://lkml.kernel.org/r/1477420604-28918-1-git-send-email-danielmentz@google.com
    Signed-off-by: Daniel Mentz
    Reviewed-by: Mathieu Desnoyers
    Acked-by: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Daniel Mentz
     

23 Dec, 2015

3 commits


05 Sep, 2015

2 commits

  • This change fills devm_gen_pool_create()/gen_pool_get() "name" argument
    stub with contents and extends of_gen_pool_get() functionality on this
    basis.

    If there is no associated platform device with a device node passed to
    of_gen_pool_get(), the function attempts to get a label property or device
    node name (= repeats MTD OF partition standard) and seeks for a named
    gen_pool registered by device of the parent device node.

    The main idea of the change is to allow registration of independent
    gen_pools under the same umbrella device, say "partitions" on "storage
    device", the original functionality of one "partition" per "storage
    device" is untouched.

    [akpm@linux-foundation.org: fix constness in devres_find()]
    [dan.carpenter@oracle.com: freeing const data pointers]
    Signed-off-by: Vladimir Zapolskiy
    Cc: Philipp Zabel
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Cc: Nicolas Ferre
    Cc: Alexandre Belloni
    Cc: Jean-Christophe Plagniol-Villard
    Cc: Shawn Guo
    Cc: Sascha Hauer
    Cc: Mauro Carvalho Chehab
    Cc: Arnd Bergmann
    Signed-off-by: Dan Carpenter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vladimir Zapolskiy
     
  • This change modifies gen_pool_get() and devm_gen_pool_create() client
    interfaces adding one more argument "name" of a gen_pool object.

    Due to implementation gen_pool_get() is capable to retrieve only one
    gen_pool associated with a device even if multiple gen_pools are created,
    fortunately right at the moment it is sufficient for the clients, hence
    provide NULL as a valid argument on both producer devm_gen_pool_create()
    and consumer gen_pool_get() sides.

    Because only one created gen_pool per device is addressable, explicitly
    add a restriction to devm_gen_pool_create() to create only one gen_pool
    per device, this implies two possible error codes returned by the
    function, account it on client side (only misc/sram). This completes
    client side changes related to genalloc updates.

    [akpm@linux-foundation.org: gen_pool_get() cleanup]
    Signed-off-by: Vladimir Zapolskiy
    Cc: Philipp Zabel
    Cc: Greg Kroah-Hartman
    Cc: Russell King
    Cc: Nicolas Ferre
    Cc: Alexandre Belloni
    Cc: Jean-Christophe Plagniol-Villard
    Cc: Shawn Guo
    Cc: Sascha Hauer
    Cc: Mauro Carvalho Chehab
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vladimir Zapolskiy
     

01 Jul, 2015

2 commits

  • To be consistent with other kernel interface namings, rename
    of_get_named_gen_pool() to of_gen_pool_get(). In the original function
    name "_named" suffix references to a device tree property, which contains
    a phandle to a device and the corresponding device driver is assumed to
    register a gen_pool object.

    Due to a weak relation and to avoid any confusion (e.g. in future
    possible scenario if gen_pool objects are named) the suffix is removed.

    [sfr@canb.auug.org.au: crypto/marvell/cesa - fix up for of_get_named_gen_pool() rename]
    Signed-off-by: Vladimir Zapolskiy
    Cc: Nicolas Ferre
    Cc: Philipp Zabel
    Cc: Shawn Guo
    Cc: Sascha Hauer
    Cc: Alexandre Belloni
    Cc: Russell King
    Cc: Mauro Carvalho Chehab
    Cc: Vinod Koul
    Cc: Takashi Iwai
    Cc: Jaroslav Kysela
    Signed-off-by: Stephen Rothwell
    Cc: Herbert Xu
    Cc: Boris BREZILLON
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vladimir Zapolskiy
     
  • To be consistent with other genalloc interface namings, rename
    dev_get_gen_pool() to gen_pool_get(). The original omitted "dev_" prefix
    is removed, since it points to argument type of the function, and so it
    does not bring any useful information.

    [akpm@linux-foundation.org: update arch/arm/mach-socfpga/pm.c]
    Signed-off-by: Vladimir Zapolskiy
    Acked-by: Nicolas Ferre
    Cc: Philipp Zabel
    Cc: Shawn Guo
    Cc: Sascha Hauer
    Cc: Alexandre Belloni
    Cc: Russell King
    Cc: Mauro Carvalho Chehab
    Cc: Vinod Koul
    Cc: Takashi Iwai
    Cc: Jaroslav Kysela
    Cc: Mark Brown
    Cc: Nicolas Ferre
    Cc: Alan Tull
    Cc: Dinh Nguyen
    Cc: Kevin Hilman
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vladimir Zapolskiy
     

14 Feb, 2015

1 commit

  • devm_gen_pool_create() calls devres_alloc() and dereferences its result
    without checking whether devres_alloc() succeeded. Check for error and
    bail out if it happened.

    Coverity-id 1016493.

    Signed-off-by: Jan Kara
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Kara
     

13 Feb, 2015

2 commits


04 Dec, 2014

1 commit


10 Oct, 2014

2 commits

  • After allocating an address from a particular genpool, there is no good
    way to verify if that address actually belongs to a genpool. Introduce
    addr_in_gen_pool which will return if an address plus size falls
    completely within the genpool range.

    Signed-off-by: Laura Abbott
    Acked-by: Will Deacon
    Reviewed-by: Olof Johansson
    Reviewed-by: Catalin Marinas
    Cc: Arnd Bergmann
    Cc: David Riley
    Cc: Ritesh Harjain
    Cc: Russell King
    Cc: Thierry Reding
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Laura Abbott
     
  • One of the more common algorithms used for allocation is to align the
    start address of the allocation to the order of size requested. Add this
    as an algorithm option for genalloc.

    Signed-off-by: Laura Abbott
    Acked-by: Will Deacon
    Acked-by: Olof Johansson
    Reviewed-by: Catalin Marinas
    Cc: Arnd Bergmann
    Cc: David Riley
    Cc: Ritesh Harjain
    Cc: Russell King
    Cc: Thierry Reding
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Laura Abbott
     

26 Sep, 2014

1 commit


30 Jan, 2014

1 commit

  • In the gen_pool_dma_alloc() the dma pointer can be NULL and while
    assigning gen_pool_virt_to_phys(pool, vaddr) to dma caused the following
    crash on da850 evm:

    Unable to handle kernel NULL pointer dereference at virtual address 00000000
    Internal error: Oops: 805 [#1] PREEMPT ARM
    Modules linked in:
    CPU: 0 PID: 1 Comm: swapper Tainted: G W 3.13.0-rc1-00001-g0609e45-dirty #5
    task: c4830000 ti: c4832000 task.ti: c4832000
    PC is at gen_pool_dma_alloc+0x30/0x3c
    LR is at gen_pool_virt_to_phys+0x74/0x80
    Process swapper, call trace:
    gen_pool_dma_alloc+0x30/0x3c
    davinci_pm_probe+0x40/0xa8
    platform_drv_probe+0x1c/0x4c
    driver_probe_device+0x98/0x22c
    __driver_attach+0x8c/0x90
    bus_for_each_dev+0x6c/0x8c
    bus_add_driver+0x124/0x1d4
    driver_register+0x78/0xf8
    platform_driver_probe+0x20/0xa4
    davinci_init_late+0xc/0x14
    init_machine_late+0x1c/0x28
    do_one_initcall+0x34/0x15c
    kernel_init_freeable+0xe4/0x1ac
    kernel_init+0x8/0xec

    This patch fixes the above.

    [akpm@linux-foundation.org: update kerneldoc]
    Signed-off-by: Lad, Prabhakar
    Cc: Philipp Zabel
    Cc: Nicolin Chen
    Cc: Joe Perches
    Cc: Sachin Kamat
    Cc: [3.13.x]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Lad, Prabhakar
     

13 Nov, 2013

1 commit

  • When using pool space for DMA buffer, there might be duplicated calling of
    gen_pool_alloc() and gen_pool_virt_to_phys() in each implementation.

    Thus it's better to add a simple helper function, a compatible one to the
    common dma_alloc_coherent(), to save some code.

    Signed-off-by: Nicolin Chen
    Cc: "Hans J. Koch"
    Cc: Dan Williams
    Cc: Eric Miao
    Cc: Grant Likely
    Cc: Greg Kroah-Hartman
    Cc: Haojian Zhuang
    Cc: Jaroslav Kysela
    Cc: Kevin Hilman
    Cc: Liam Girdwood
    Cc: Mark Brown
    Cc: Mauro Carvalho Chehab
    Cc: Rob Herring
    Cc: Russell King
    Cc: Sekhar Nori
    Cc: Takashi Iwai
    Cc: Vinod Koul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nicolin Chen
     

12 Sep, 2013

3 commits

  • The documentation mentions a "name" parameter, which does not exist. This
    commit removes such mention from the function documentation.

    Signed-off-by: Emilio López
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Emilio López
     
  • Use the helper function instead of __GFP_ZERO.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • In struct gen_pool_chunk, end_addr means the end address of memory chunk
    (inclusive), but in the implementation it is treated as address + size of
    memory chunk (exclusive), so it points to the address plus one instead of
    correct ending address.

    The ending address of memory chunk plus one will cause overflow on the
    memory chunk including the last address of memory map, e.g. when starting
    address is 0xFFF00000 and size is 0x100000 on 32bit machine, ending
    address will be 0x100000000.

    Use correct ending address like starting address + size - 1.

    [akpm@linux-foundation.org: add comment to struct gen_pool_chunk:end_addr]
    Signed-off-by: Joonyoung Shim
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joonyoung Shim
     

30 Apr, 2013

1 commit

  • This patch adds three exported functions to lib/genalloc.c:
    devm_gen_pool_create, dev_get_gen_pool, and of_get_named_gen_pool.

    devm_gen_pool_create is a managed version of gen_pool_create that keeps
    track of the pool via devres and allows the management code to
    automatically destroy it after device removal.

    dev_get_gen_pool retrieves the gen_pool for a given device, if it was
    created with devm_gen_pool_create, using devres_find.

    of_get_named_gen_pool retrieves the gen_pool for a given device node and
    property name, where the property must contain a phandle pointing to a
    platform device node. The corresponding platform device is then fed into
    dev_get_gen_pool and the resulting gen_pool is returned.

    [akpm@linux-foundation.org: make the of_get_named_gen_pool() stub static, fixing a zillion link errors]
    [akpm@linux-foundation.org: squish "struct device declared inside parameter list" warning]
    Signed-off-by: Philipp Zabel
    Acked-by: Grant Likely
    Tested-by: Michal Simek
    Cc: Fabio Estevam
    Cc: Matt Porter
    Cc: Dong Aisheng
    Cc: Greg Kroah-Hartman
    Cc: Rob Herring
    Cc: Paul Gortmaker
    Cc: Javier Martin
    Cc: Huang Shijie
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Philipp Zabel
     

26 Oct, 2012

1 commit

  • The genalloc code uses the bitmap API from include/linux/bitmap.h and
    lib/bitmap.c, which is based on long values. Both bitmap_set from
    lib/bitmap.c and bitmap_set_ll, which is the lockless version from
    genalloc.c, use BITMAP_LAST_WORD_MASK to set the first bits in a long in
    the bitmap.

    That one uses (1 << bits) - 1, 0b111, if you are setting the first three
    bits. This means that the API counts from the least significant bits
    (LSB from now on) to the MSB. The LSB in the first long is bit 0, then.
    The same works for the lookup functions.

    The genalloc code uses longs for the bitmap, as it should. In
    include/linux/genalloc.h, struct gen_pool_chunk has unsigned long
    bits[0] as its last member. When allocating the struct, genalloc should
    reserve enough space for the bitmap. This should be a proper number of
    longs that can fit the amount of bits in the bitmap.

    However, genalloc allocates an integer number of bytes that fit the
    amount of bits, but may not be an integer amount of longs. 9 bytes, for
    example, could be allocated for 70 bits.

    This is a problem in itself if the Least Significat Bit in a long is in
    the byte with the largest address, which happens in Big Endian machines.
    This means genalloc is not allocating the byte in which it will try to
    set or check for a bit.

    This may end up in memory corruption, where genalloc will try to set the
    bits it has not allocated. In fact, genalloc may not set these bits
    because it may find them already set, because they were not zeroed since
    they were not allocated. And that's what causes a BUG when
    gen_pool_destroy is called and check for any set bits.

    What really happens is that genalloc uses kmalloc_node with __GFP_ZERO
    on gen_pool_add_virt. With SLAB and SLUB, this means the whole slab
    will be cleared, not only the requested bytes. Since struct
    gen_pool_chunk has a size that is a multiple of 8, and slab sizes are
    multiples of 8, we get lucky and allocate and clear the right amount of
    bytes.

    Hower, this is not the case with SLOB or with older code that did memset
    after allocating instead of using __GFP_ZERO.

    So, a simple module as this (running 3.6.0), will cause a crash when
    rmmod'ed.

    [root@phantom-lp2 foo]# cat foo.c
    #include
    #include
    #include
    #include

    MODULE_LICENSE("GPL");
    MODULE_VERSION("0.1");

    static struct gen_pool *foo_pool;

    static __init int foo_init(void)
    {
    int ret;
    foo_pool = gen_pool_create(10, -1);
    if (!foo_pool)
    return -ENOMEM;
    ret = gen_pool_add(foo_pool, 0xa0000000, 32 << 10, -1);
    if (ret) {
    gen_pool_destroy(foo_pool);
    return ret;
    }
    return 0;
    }

    static __exit void foo_exit(void)
    {
    gen_pool_destroy(foo_pool);
    }

    module_init(foo_init);
    module_exit(foo_exit);
    [root@phantom-lp2 foo]# zcat /proc/config.gz | grep SLOB
    CONFIG_SLOB=y
    [root@phantom-lp2 foo]# insmod ./foo.ko
    [root@phantom-lp2 foo]# rmmod foo
    ------------[ cut here ]------------
    kernel BUG at lib/genalloc.c:243!
    cpu 0x4: Vector: 700 (Program Check) at [c0000000bb0e7960]
    pc: c0000000003cb50c: .gen_pool_destroy+0xac/0x110
    lr: c0000000003cb4fc: .gen_pool_destroy+0x9c/0x110
    sp: c0000000bb0e7be0
    msr: 8000000000029032
    current = 0xc0000000bb0e0000
    paca = 0xc000000006d30e00 softe: 0 irq_happened: 0x01
    pid = 13044, comm = rmmod
    kernel BUG at lib/genalloc.c:243!
    [c0000000bb0e7ca0] d000000004b00020 .foo_exit+0x20/0x38 [foo]
    [c0000000bb0e7d20] c0000000000dff98 .SyS_delete_module+0x1a8/0x290
    [c0000000bb0e7e30] c0000000000097d4 syscall_exit+0x0/0x94
    --- Exception: c00 (System Call) at 000000800753d1a0
    SP (fffd0b0e640) is in userspace

    Signed-off-by: Thadeu Lima de Souza Cascardo
    Cc: Paul Gortmaker
    Cc: Benjamin Gaignard
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thadeu Lima de Souza Cascardo
     

06 Oct, 2012

1 commit

  • Premit use of another algorithm than the default first-fit one. For
    example a custom algorithm could be used to manage alignment requirements.

    As I can't predict all the possible requirements/needs for all allocation
    uses cases, I add a "free" field 'void *data' to pass any needed
    information to the allocation function. For example 'data' could be used
    to handle a structure where you store the alignment, the expected memory
    bank, the requester device, or any information that could influence the
    allocation algorithm.

    An usage example may look like this:
    struct my_pool_constraints {
    int align;
    int bank;
    ...
    };

    unsigned long my_custom_algo(unsigned long *map, unsigned long size,
    unsigned long start, unsigned int nr, void *data)
    {
    struct my_pool_constraints *constraints = data;
    ...
    deal with allocation contraints
    ...
    return the index in bitmap where perform the allocation
    }

    void create_my_pool()
    {
    struct my_pool_constraints c;
    struct gen_pool *pool = gen_pool_create(...);
    gen_pool_add(pool, ...);
    gen_pool_set_algo(pool, my_custom_algo, &c);
    }

    Add of best-fit algorithm function:
    most of the time best-fit is slower then first-fit but memory fragmentation
    is lower. The random buffer allocation/free tests don't show any arithmetic
    relation between the allocation time and fragmentation but the
    best-fit algorithm
    is sometime able to perform the allocation when the first-fit can't.

    This new algorithm help to remove static allocations on ESRAM, a small but
    fast on-chip RAM of few KB, used for high-performance uses cases like DMA
    linked lists, graphic accelerators, encoders/decoders. On the Ux500
    (in the ARM tree) we have define 5 ESRAM banks of 128 KB each and use of
    static allocations becomes unmaintainable:
    cd arch/arm/mach-ux500 && grep -r ESRAM .
    ./include/mach/db8500-regs.h:/* Base address and bank offsets for ESRAM */
    ./include/mach/db8500-regs.h:#define U8500_ESRAM_BASE 0x40000000
    ./include/mach/db8500-regs.h:#define U8500_ESRAM_BANK_SIZE 0x00020000
    ./include/mach/db8500-regs.h:#define U8500_ESRAM_BANK0 U8500_ESRAM_BASE
    ./include/mach/db8500-regs.h:#define U8500_ESRAM_BANK1 (U8500_ESRAM_BASE + U8500_ESRAM_BANK_SIZE)
    ./include/mach/db8500-regs.h:#define U8500_ESRAM_BANK2 (U8500_ESRAM_BANK1 + U8500_ESRAM_BANK_SIZE)
    ./include/mach/db8500-regs.h:#define U8500_ESRAM_BANK3 (U8500_ESRAM_BANK2 + U8500_ESRAM_BANK_SIZE)
    ./include/mach/db8500-regs.h:#define U8500_ESRAM_BANK4 (U8500_ESRAM_BANK3 + U8500_ESRAM_BANK_SIZE)
    ./include/mach/db8500-regs.h:#define U8500_ESRAM_DMA_LCPA_OFFSET 0x10000
    ./include/mach/db8500-regs.h:#define U8500_DMA_LCPA_BASE
    (U8500_ESRAM_BANK0 + U8500_ESRAM_DMA_LCPA_OFFSET)
    ./include/mach/db8500-regs.h:#define U8500_DMA_LCLA_BASE U8500_ESRAM_BANK4

    I want to use genalloc to do dynamic allocations but I need to be able to
    fine tune the allocation algorithm. I my case best-fit algorithm give
    better results than first-fit, but it will not be true for every use case.

    Signed-off-by: Benjamin Gaignard
    Cc: Huang Ying
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Benjamin Gaignard
     

08 Mar, 2012

1 commit


03 Aug, 2011

1 commit

  • This version of the gen_pool memory allocator supports lockless
    operation.

    This makes it safe to use in NMI handlers and other special
    unblockable contexts that could otherwise deadlock on locks. This is
    implemented by using atomic operations and retries on any conflicts.
    The disadvantage is that there may be livelocks in extreme cases. For
    better scalability, one gen_pool allocator can be used for each CPU.

    The lockless operation only works if there is enough memory available.
    If new memory is added to the pool a lock has to be still taken. So
    any user relying on locklessness has to ensure that sufficient memory
    is preallocated.

    The basic atomic operation of this allocator is cmpxchg on long. On
    architectures that don't have NMI-safe cmpxchg implementation, the
    allocator can NOT be used in NMI handler. So code uses the allocator
    in NMI handler should depend on CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG.

    Signed-off-by: Huang Ying
    Reviewed-by: Andi Kleen
    Reviewed-by: Mathieu Desnoyers
    Cc: Andrew Morton
    Signed-off-by: Len Brown

    Huang Ying
     

25 May, 2011

1 commit


30 Jun, 2010

1 commit

  • bitmap_find_next_zero_area requires the size of the bitmap, we instead
    passed the last suitable position. This made it impossible to allocate
    from the end of the pool.

    Fixes a regression introduced by 243797f59b748f679ab88d456fcc4f92236d724b
    ("genalloc: use bitmap_find_next_zero_area").

    Signed-off-by: Imre Deak
    Cc: Zygo Blaxell
    Cc: Tejun Heo
    Acked-by: Akinobu Mita
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Imre Deak
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

16 Dec, 2009

1 commit


17 Jun, 2009

1 commit

  • There is a call to write_lock() in gen_pool_destroy which is not balanced
    by any corresponding write_unlock(). This causes problems with preemption
    because the preemption-disable counter is incremented in the write_lock()
    call, but never decremented by any call to write_unlock(). This bug is
    gen_pool_destroy, and one of them is non-x86 arch-specific code.

    Signed-off-by: Zygo Blaxell
    Cc: Jiri Kosina
    Cc: Steve Wise
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Zygo Blaxell
     

18 Jul, 2007

1 commit

  • kmalloc_node() and kmem_cache_alloc_node() were not available in a zeroing
    variant in the past. But with __GFP_ZERO it is possible now to do zeroing
    while allocating.

    Use __GFP_ZERO to remove the explicit clearing of memory via memset whereever
    we can.

    Signed-off-by: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     

21 Feb, 2007

1 commit

  • lib/genalloc.c: In function 'gen_pool_alloc':
    lib/genalloc.c:151: warning: passing argument 2 of '__set_bit' from incompatible pointer type
    lib/genalloc.c: In function 'gen_pool_free':
    lib/genalloc.c:190: warning: passing argument 2 of '__clear_bit' from incompatible pointer type

    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

02 Oct, 2006

2 commits


23 Jun, 2006

1 commit

  • Modify the gen_pool allocator (lib/genalloc.c) to utilize a bitmap scheme
    instead of the buddy scheme. The purpose of this change is to eliminate
    the touching of the actual memory being allocated.

    Since the change modifies the interface, a change to the uncached allocator
    (arch/ia64/kernel/uncached.c) is also required.

    Both Andrey Volkov and Jes Sorenson have expressed a desire that the
    gen_pool allocator not write to the memory being managed. See the
    following:

    http://marc.theaimsgroup.com/?l=linux-kernel&m=113518602713125&w=2
    http://marc.theaimsgroup.com/?l=linux-kernel&m=113533568827916&w=2

    Signed-off-by: Dean Nelson
    Cc: Andrey Volkov
    Acked-by: Jes Sorensen
    Cc: "Luck, Tony"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dean Nelson
     

29 Nov, 2005

1 commit

  • genalloc improperly stores the sizes of freed chunks, allocates overlapping
    memory regions, and oopses after its in-band data is overwritten.

    Signed-off-by: Chris Humbert
    Cc: Jes Sorensen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Chris Humbert
     

22 Jun, 2005

1 commit

  • This patch contains the ia64 uncached page allocator and the generic
    allocator (genalloc). The uncached allocator was formerly part of the SN2
    mspec driver but there are several other users of it so it has been split
    off from the driver.

    The generic allocator can be used by device driver to manage special memory
    etc. The generic allocator is based on the allocator from the sym53c8xx_2
    driver.

    Various users on ia64 needs uncached memory. The SGI SN architecture requires
    it for inter-partition communication between partitions within a large NUMA
    cluster. The specific user for this is the XPC code. Another application is
    large MPI style applications which use it for synchronization, on SN this can
    be done using special 'fetchop' operations but it also benefits non SN
    hardware which may use regular uncached memory for this purpose. Performance
    of doing this through uncached vs cached memory is pretty substantial. This
    is handled by the mspec driver which I will push out in a seperate patch.

    Rather than creating a specific allocator for just uncached memory I came up
    with genalloc which is a generic purpose allocator that can be used by device
    drivers and other subsystems as they please. For instance to handle onboard
    device memory. It was derived from the sym53c7xx_2 driver's allocator which
    is also an example of a potential user (I am refraining from modifying sym2
    right now as it seems to have been under fairly heavy development recently).

    On ia64 memory has various properties within a granule, ie. it isn't safe to
    access memory as uncached within the same granule as currently has memory
    accessed in cached mode. The regular system therefore doesn't utilize memory
    in the lower granules which is mixed in with device PAL code etc. The
    uncached driver walks the EFI memmap and pulls out the spill uncached pages
    and sticks them into the uncached pool. Only after these chunks have been
    utilized, will it start converting regular cached memory into uncached memory.
    Hence the reason for the EFI related code additions.

    Signed-off-by: Jes Sorensen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jes Sorensen