1. 18 Nov, 2017 1 commit
  2. 28 Oct, 2016 1 commit
    • Daniel Mentz's avatar
      lib/genalloc.c: start search from start of chunk · 62e931fa
      Daniel Mentz authored
      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))
      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: 7f184275 ("lib, Make gen_pool memory allocator lockless")
      Link: http://lkml.kernel.org/r/1477420604-28918-1-git-send-email-danielmentz@google.comSigned-off-by: default avatarDaniel Mentz <danielmentz@google.com>
      Reviewed-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  3. 22 Dec, 2015 3 commits
  4. 04 Sep, 2015 2 commits
    • Vladimir Zapolskiy's avatar
      genalloc: add support of multiple gen_pools per device · c98c3635
      Vladimir Zapolskiy authored
      This change fills devm_gen_pool_create()/gen_pool_get() "name" argument
      stub with contents and extends of_gen_pool_get() functionality on this
      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: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
      Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Sascha Hauer <kernel@pengutronix.de>
      Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    • Vladimir Zapolskiy's avatar
      genalloc: add name arg to gen_pool_get() and devm_gen_pool_create() · 73858173
      Vladimir Zapolskiy authored
      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: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
      Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
      Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Sascha Hauer <kernel@pengutronix.de>
      Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  5. 01 Jul, 2015 2 commits
    • Vladimir Zapolskiy's avatar
      genalloc: rename of_get_named_gen_pool() to of_gen_pool_get() · abdd4a70
      Vladimir Zapolskiy authored
      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: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: Shawn Guo <shawn.guo@linaro.org>
      Cc: Sascha Hauer <kernel@pengutronix.de>
      Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
      Cc: Vinod Koul <vinod.koul@intel.com>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Boris BREZILLON <boris.brezillon@free-electrons.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    • Vladimir Zapolskiy's avatar
      genalloc: rename dev_get_gen_pool() to gen_pool_get() · 0030edf2
      Vladimir Zapolskiy authored
      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: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Acked-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: Shawn Guo <shawn.guo@linaro.org>
      Cc: Sascha Hauer <kernel@pengutronix.de>
      Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
      Cc: Vinod Koul <vinod.koul@intel.com>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
      Cc: Alan Tull <atull@opensource.altera.com>
      Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
      Cc: Kevin Hilman <khilman@linaro.org>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  6. 14 Feb, 2015 1 commit
  7. 13 Feb, 2015 2 commits
  8. 03 Dec, 2014 1 commit
  9. 10 Oct, 2014 2 commits
  10. 26 Sep, 2014 1 commit
  11. 30 Jan, 2014 1 commit
    • Lad, Prabhakar's avatar
      lib/genalloc.c: add check gen_pool_dma_alloc() if dma pointer is not NULL · 0368dfd0
      Lad, Prabhakar authored
      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:
      This patch fixes the above.
      [akpm@linux-foundation.org: update kerneldoc]
      Signed-off-by: default avatarLad, Prabhakar <prabhakar.csengg@gmail.com>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: Nicolin Chen <b42378@freescale.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Sachin Kamat <sachin.kamat@linaro.org>
      Cc: <stable@vger.kernel.org>	[3.13.x]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  12. 13 Nov, 2013 1 commit
    • Nicolin Chen's avatar
      lib/genalloc: add a helper function for DMA buffer allocation · 684f0d3d
      Nicolin Chen authored
      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: default avatarNicolin Chen <b42378@freescale.com>
      Cc: "Hans J. Koch" <hjk@hansjkoch.de>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Eric Miao <eric.y.miao@gmail.com>
      Cc: Grant Likely <grant.likely@linaro.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: Kevin Hilman <khilman@deeprootsystems.com>
      Cc: Liam Girdwood <lgirdwood@gmail.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Sekhar Nori <nsekhar@ti.com>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Vinod Koul <vinod.koul@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  13. 11 Sep, 2013 3 commits
  14. 30 Apr, 2013 1 commit
    • Philipp Zabel's avatar
      genalloc: add devres support, allow to find a managed pool by device · 9375db07
      Philipp Zabel authored
      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: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
      Acked-by: default avatarGrant Likely <grant.likely@secretlab.ca>
      Tested-by: default avatarMichal Simek <monstr@monstr.eu>
      Cc: Fabio Estevam <fabio.estevam@freescale.com>
      Cc: Matt Porter <mporter@ti.com>
      Cc: Dong Aisheng <dong.aisheng@linaro.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Javier Martin <javier.martin@vista-silicon.com>
      Cc: Huang Shijie <shijie8@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  15. 25 Oct, 2012 1 commit
    • Thadeu Lima de Souza Cascardo's avatar
      genalloc: stop crashing the system when destroying a pool · eedce141
      Thadeu Lima de Souza Cascardo authored
      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
      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
        [root@phantom-lp2 foo]# cat foo.c
        #include <linux/kernel.h>
        #include <linux/module.h>
        #include <linux/init.h>
        #include <linux/genalloc.h>
        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) {
                        return ret;
                return 0;
        static __exit void foo_exit(void)
        [root@phantom-lp2 foo]# zcat /proc/config.gz | grep SLOB
        [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: default avatarThadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Benjamin Gaignard <benjamin.gaignard@stericsson.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  16. 05 Oct, 2012 1 commit
    • Benjamin Gaignard's avatar
      genalloc: make it possible to use a custom allocation algorithm · ca279cf1
      Benjamin Gaignard authored
      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
      ./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: default avatarBenjamin Gaignard <benjamin.gaignard@stericsson.com>
      Cc: Huang Ying <ying.huang@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  17. 07 Mar, 2012 1 commit
  18. 03 Aug, 2011 1 commit
    • Huang Ying's avatar
      lib, Make gen_pool memory allocator lockless · 7f184275
      Huang Ying authored
      This version of the gen_pool memory allocator supports lockless
      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: default avatarHuang Ying <ying.huang@intel.com>
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Reviewed-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLen Brown <len.brown@intel.com>
  19. 25 May, 2011 1 commit
  20. 29 Jun, 2010 1 commit
  21. 30 Mar, 2010 1 commit
    • Tejun Heo's avatar
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo authored
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit 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.
      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
      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
      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
      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: default avatarTejun Heo <tj@kernel.org>
      Guess-its-ok-by: default avatarChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
  22. 16 Dec, 2009 1 commit
  23. 17 Jun, 2009 1 commit
  24. 17 Jul, 2007 1 commit
  25. 21 Feb, 2007 1 commit
  26. 02 Oct, 2006 2 commits
  27. 23 Jun, 2006 1 commit
  28. 28 Nov, 2005 1 commit
  29. 22 Jun, 2005 1 commit
    • Jes Sorensen's avatar
      [PATCH] ia64 uncached alloc · f14f75b8
      Jes Sorensen authored
      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
      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: default avatarJes Sorensen <jes@wildopensource.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>