1. 08 Dec, 2011 23 commits
    • Tejun Heo's avatar
      memblock: Reimplement memblock allocation using reverse free area iterator · 7bd0b0f0
      Tejun Heo authored
      Now that all early memory information is in memblock when enabled, we
      can implement reverse free area iterator and use it to implement NUMA
      aware allocator which is then wrapped for simpler variants instead of
      the confusing and inefficient mending of information in separate NUMA
      aware allocator.
      
      Implement for_each_free_mem_range_reverse(), use it to reimplement
      memblock_find_in_range_node() which in turn is used by all allocators.
      
      The visible allocator interface is inconsistent and can probably use
      some cleanup too.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      7bd0b0f0
    • Tejun Heo's avatar
      memblock: Kill early_node_map[] · 0ee332c1
      Tejun Heo authored
      Now all ARCH_POPULATES_NODE_MAP archs select HAVE_MEBLOCK_NODE_MAP -
      there's no user of early_node_map[] left.  Kill early_node_map[] and
      replace ARCH_POPULATES_NODE_MAP with HAVE_MEMBLOCK_NODE_MAP.  Also,
      relocate for_each_mem_pfn_range() and helper from mm.h to memblock.h
      as page_alloc.c would no longer host an alternative implementation.
      
      This change is ultimately one to one mapping and shouldn't cause any
      observable difference; however, after the recent changes, there are
      some functions which now would fit memblock.c better than page_alloc.c
      and dependency on HAVE_MEMBLOCK_NODE_MAP instead of HAVE_MEMBLOCK
      doesn't make much sense on some of them.  Further cleanups for
      functions inside HAVE_MEMBLOCK_NODE_MAP in mm.h would be nice.
      
      -v2: Fix compile bug introduced by mis-spelling
       CONFIG_HAVE_MEMBLOCK_NODE_MAP to CONFIG_MEMBLOCK_HAVE_NODE_MAP in
       mmzone.h.  Reported by Stephen Rothwell.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Chen Liqin <liqin.chen@sunplusct.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      0ee332c1
    • Tejun Heo's avatar
      score: Use HAVE_MEMBLOCK_NODE_MAP · a2bf79e7
      Tejun Heo authored
      score used early_node_map[] just to prime free_area_init_nodes().  Now
      memblock can be used for the same purpose and early_node_map[] is
      scheduled to be dropped.  Use memblock instead.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Chen Liqin <liqin.chen@sunplusct.com>
      Cc: Lennox Wu <lennox.wu@gmail.com>
      a2bf79e7
    • Tejun Heo's avatar
      s390: Use HAVE_MEMBLOCK_NODE_MAP · ff38df37
      Tejun Heo authored
      s390 used early_node_map[] just to prime free_area_init_nodes().  Now
      memblock can be used for the same purpose and early_node_map[] is
      scheduled to be dropped.  Use memblock instead.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: linux-s390@vger.kernel.org
      ff38df37
    • Tejun Heo's avatar
      mips: Use HAVE_MEMBLOCK_NODE_MAP · 9d15ffc8
      Tejun Heo authored
      mips used early_node_map[] just to prime free_area_init_nodes().  Now
      memblock can be used for the same purpose and early_node_map[] is
      scheduled to be dropped.  Use memblock instead.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: linux-mips@linux-mips.org
      9d15ffc8
    • Tejun Heo's avatar
      ia64: Use HAVE_MEMBLOCK_NODE_MAP · 98e4ae8a
      Tejun Heo authored
      ia64 used early_node_map[] just to prime free_area_init_nodes().  Now
      memblock can be used for the same purpose and early_node_map[] is
      scheduled to be dropped.  Use memblock instead.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: linux-ia64@vger.kernel.org
      98e4ae8a
    • Tejun Heo's avatar
      SuperH: Use HAVE_MEMBLOCK_NODE_MAP · 534cfbee
      Tejun Heo authored
      sh doesn't access early_node_map[] directly and enabling
      HAVE_MEMBLOCK_NODE_MAP is trivial - replacing add_active_range() calls
      with memblock_set_node() and selecting HAVE_MEMBLOCK_NODE_MAP is
      enough.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: linux-sh@vger.kernel.org
      534cfbee
    • Tejun Heo's avatar
      sparc: Use HAVE_MEMBLOCK_NODE_MAP · 2a4814df
      Tejun Heo authored
      sparc doesn't access early_node_map[] directly and enabling
      HAVE_MEMBLOCK_NODE_MAP is trivial - replacing add_active_range() calls
      with memblock_set_node() and selecting HAVE_MEMBLOCK_NODE_MAP is
      enough.
      
      -v2: Use select in Kconfig instead as suggested by Sam Ravnborg.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatar"David S. Miller" <davem@davemloft.net>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: sparclinux@vger.kernel.org
      2a4814df
    • Tejun Heo's avatar
      powerpc: Use HAVE_MEMBLOCK_NODE_MAP · 1d7cfe18
      Tejun Heo authored
      powerpc doesn't access early_node_map[] directly and enabling
      HAVE_MEMBLOCK_NODE_MAP is trivial - replacing add_active_range() calls
      with memblock_set_node() and selecting HAVE_MEMBLOCK_NODE_MAP is
      enough.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      1d7cfe18
    • Tejun Heo's avatar
      memblock: Implement memblock_add_node() · 7fb0bc3f
      Tejun Heo authored
      Implement memblock_add_node() which can add a new memblock memory
      region with specific node ID.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      7fb0bc3f
    • Tejun Heo's avatar
      memblock: s/memblock_analyze()/memblock_allow_resize()/ and update users · 1aadc056
      Tejun Heo authored
      The only function of memblock_analyze() is now allowing resize of
      memblock region arrays.  Rename it to memblock_allow_resize() and
      update its users.
      
      * The following users remain the same other than renaming.
      
        arm/mm/init.c::arm_memblock_init()
        microblaze/kernel/prom.c::early_init_devtree()
        powerpc/kernel/prom.c::early_init_devtree()
        openrisc/kernel/prom.c::early_init_devtree()
        sh/mm/init.c::paging_init()
        sparc/mm/init_64.c::paging_init()
        unicore32/mm/init.c::uc32_memblock_init()
      
      * In the following users, analyze was used to update total size which
        is no longer necessary.
      
        powerpc/kernel/machine_kexec.c::reserve_crashkernel()
        powerpc/kernel/prom.c::early_init_devtree()
        powerpc/mm/init_32.c::MMU_init()
        powerpc/mm/tlb_nohash.c::__early_init_mmu()  
        powerpc/platforms/ps3/mm.c::ps3_mm_add_memory()
        powerpc/platforms/embedded6xx/wii.c::wii_memory_fixups()
        sh/kernel/machine_kexec.c::reserve_crashkernel()
      
      * x86/kernel/e820.c::memblock_x86_fill() was directly setting
        memblock_can_resize before populating memblock and calling analyze
        afterwards.  Call memblock_allow_resize() before start populating.
      
      memblock_can_resize is now static inside memblock.c.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      1aadc056
    • Tejun Heo's avatar
      memblock: Track total size of regions automatically · 1440c4e2
      Tejun Heo authored
      Total size of memory regions was calculated by memblock_analyze()
      requiring explicitly calling the function between operations which can
      change memory regions and possible users of total size, which is
      cumbersome and fragile.
      
      This patch makes each memblock_type track total size automatically
      with minor modifications to memblock manipulation functions and remove
      requirements on calling memblock_analyze().  [__]memblock_dump_all()
      now also dumps the total size of reserved regions.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      1440c4e2
    • Tejun Heo's avatar
      powerpc: Cleanup memblock usage · 6fbef13c
      Tejun Heo authored
      * early_init_devtree(): Total memory size is aligned to PAGE_SIZE;
        however, alignment isn't enforced if memory_limit is explicitly
        specified.  Simplify the logic and always apply PAGE_SIZE alignment.
      
      * MMU_init(): memblock regions is truncated by directly modifying
        memblock.memory.cnt.  This is incomplete (reserved array is not
        truncated) and unnecessarily low level hindering further memblock
        improvments.  Use memblock_enforce_memory_limit() instead.
      
      * wii_memory_fixups(): Unnecessarily low level direct manipulation of
        memblock regions.  The same result can be achieved using properly
        abstracted operations.  Reimplement using memblock API.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      6fbef13c
    • Tejun Heo's avatar
      memblock: Reimplement memblock_enforce_memory_limit() using __memblock_remove() · c0ce8fef
      Tejun Heo authored
      With recent updates, the basic memblock operations are robust enough
      that there's no reason for memblock_enfore_memory_limit() to directly
      manipulate memblock region arrays.  Reimplement it using
      __memblock_remove().
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      c0ce8fef
    • Tejun Heo's avatar
      memblock: Make memblock functions handle overflowing range @size · eb18f1b5
      Tejun Heo authored
      Allow memblock users to specify range where @base + @size overflows
      and automatically cap it at maximum.  This makes the interface more
      robust and specifying till-the-end-of-memory easier.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      eb18f1b5
    • Tejun Heo's avatar
      memblock: Reimplement __memblock_remove() using memblock_isolate_range() · 71936180
      Tejun Heo authored
      __memblock_remove()'s open coded region manipulation can be trivially
      replaced with memblock_islate_range().  This increases code sharing
      and eases improving region tracking.
      
      This pulls memblock_isolate_range() out of HAVE_MEMBLOCK_NODE_MAP.
      Make it use memblock_get_region_node() instead of assuming rgn->nid is
      available.
      
      -v2: Fixed build failure on !HAVE_MEMBLOCK_NODE_MAP caused by direct
           rgn->nid access.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      71936180
    • Tejun Heo's avatar
      memblock: Separate out memblock_isolate_range() from memblock_set_node() · 6a9ceb31
      Tejun Heo authored
      memblock_set_node() operates in three steps - break regions crossing
      boundaries, set nid and merge back regions.  This patch separates the
      first part into a separate function - memblock_isolate_range(), which
      breaks regions crossing range boundaries and returns range index range
      for regions properly contained in the specified memory range.
      
      This doesn't introduce any behavior change and will be used to further
      unify region handling.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      6a9ceb31
    • Tejun Heo's avatar
      memblock: Kill memblock_init() · fe091c20
      Tejun Heo authored
      memblock_init() initializes arrays for regions and memblock itself;
      however, all these can be done with struct initializers and
      memblock_init() can be removed.  This patch kills memblock_init() and
      initializes memblock with struct initializer.
      
      The only difference is that the first dummy entries don't have .nid
      set to MAX_NUMNODES initially.  This doesn't cause any behavior
      difference.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      fe091c20
    • Tejun Heo's avatar
      memblock: Kill sentinel entries at the end of static region arrays · c5a1cb28
      Tejun Heo authored
      memblock no longer depends on having one more entry at the end during
      addition making the sentinel entries at the end of region arrays not
      too useful.  Remove the sentinels.  This eases further updates.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      c5a1cb28
    • Tejun Heo's avatar
      memblock: Add __memblock_dump_all() · 4ff7b82f
      Tejun Heo authored
      Add __memblock_dump_all() which dumps memblock configuration whether
      memblock_debug is enabled or not.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      4ff7b82f
    • Tejun Heo's avatar
      memblock: Use memblock_reserve() in memblock internal functions · 9c8c27e2
      Tejun Heo authored
      Make memblock_double_array(), __memblock_alloc_base() and
      memblock_alloc_nid() use memblock_reserve() instead of calling
      memblock_add_region() with reserved array directly.  This eases
      debugging and updates to memblock_add_region().
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      9c8c27e2
    • Tejun Heo's avatar
      memblock: Make memblock_{add|remove|free|reserve}() return int and update prototypes · 581adcbe
      Tejun Heo authored
      memblock_{add|remove|free|reserve}() return either 0 or -errno but had
      long as return type.  Chage it to int.  Also, drop 'extern' from all
      prototypes in memblock.h - they are unnecessary and used
      inconsistently (especially if mm.h is included in the picture).
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Yinghai Lu <yinghai@kernel.org>
      581adcbe
    • Tejun Heo's avatar
      memblock: Fix include breakages caused by 24aa0788 · 1c16d242
      Tejun Heo authored
      24aa0788 (memblock, x86: Replace memblock_x86_reserve/free_range()
      with generic ones) removed arch/x86/include/asm/memblock.h and dropped
      its inclusion from include/linux/memblock.h which breaks other
      architectures which depended on the generic memblock.h pulling in the
      arch specific one.
      
      However, the proper fix isn't adding back the asm inclusion.  memblock
      doesn't have any arch dependent part and doesn't need arch specific
      header file and asm/memblock.h files are either practically empty or
      contain mostly unrelated arch specific stuff.
      
      * In microblaze, sh, powerpc, sparc and openrisc, asm/memblock.h is
        either empty or just contains unused MEMBLOCK_DBG() macro.  Remove
        them.
      
      * In arm and unicore32, asm/memblock.h contains arch specific stuff.
        Include it directly from its users.  It might be a good idea to
        rename the header file to avoid confusion.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatar"H. Peter Anvin" <hpa@zytor.com>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      1c16d242
  2. 28 Nov, 2011 1 commit
    • Tejun Heo's avatar
      Merge branch 'master' into x86/memblock · d4bbf7e7
      Tejun Heo authored
      Conflicts & resolutions:
      
      * arch/x86/xen/setup.c
      
      	dc91c728 "xen: allow extra memory to be in multiple regions"
      	24aa0788 "memblock, x86: Replace memblock_x86_reserve/free..."
      
      	conflicted on xen_add_extra_mem() updates.  The resolution is
      	trivial as the latter just want to replace
      	memblock_x86_reserve_range() with memblock_reserve().
      
      * drivers/pci/intel-iommu.c
      
      	166e9278 "x86/ia64: intel-iommu: move to drivers/iommu/"
      	5dfe8660 "bootmem: Replace work_with_active_regions() with..."
      
      	conflicted as the former moved the file under drivers/iommu/.
      	Resolved by applying the chnages from the latter on the moved
      	file.
      
      * mm/Kconfig
      
      	66616720 "memblock: add NO_BOOTMEM config symbol"
      	c378ddd5 "memblock, x86: Make ARCH_DISCARD_MEMBLOCK a config option"
      
      	conflicted trivially.  Both added config options.  Just
      	letting both add their own options resolves the conflict.
      
      * mm/memblock.c
      
      	d1f0ece6 "mm/memblock.c: small function definition fixes"
      	ed7b56a7 "memblock: Remove memblock_memory_can_coalesce()"
      
      	confliected.  The former updates function removed by the
      	latter.  Resolution is trivial.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      d4bbf7e7
  3. 27 Nov, 2011 2 commits
  4. 26 Nov, 2011 4 commits
  5. 24 Nov, 2011 10 commits