arm: remove CONFIG_ARCH_HAS_HOLES_MEMORYMODEL
authorMike Rapoport <rppt@linux.ibm.com>
Tue, 15 Dec 2020 03:09:55 +0000 (19:09 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 15 May 2022 17:54:46 +0000 (19:54 +0200)
commit 5e545df3292fbd3d5963c68980f1527ead2a2b3f upstream.

ARM is the only architecture that defines CONFIG_ARCH_HAS_HOLES_MEMORYMODEL
which in turn enables memmap_valid_within() function that is intended to
verify existence  of struct page associated with a pfn when there are holes
in the memory map.

However, the ARCH_HAS_HOLES_MEMORYMODEL also enables HAVE_ARCH_PFN_VALID
and arch-specific pfn_valid() implementation that also deals with the holes
in the memory map.

The only two users of memmap_valid_within() call this function after
a call to pfn_valid() so the memmap_valid_within() check becomes redundant.

Remove CONFIG_ARCH_HAS_HOLES_MEMORYMODEL and memmap_valid_within() and rely
entirely on ARM's implementation of pfn_valid() that is now enabled
unconditionally.

Link: https://lkml.kernel.org/r/20201101170454.9567-9-rppt@kernel.org
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Meelis Roos <mroos@linux.ee>
Cc: Michael Schmitz <schmitzmic@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Reported-by: kernel test robot <lkp@intel.com>
Fixes: 8dd559d53b3b ("arm: ioremap: don't abuse pfn_valid() to check if pfn is in RAM")
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13 files changed:
Documentation/vm/memory-model.rst
arch/arm/Kconfig
arch/arm/mach-bcm/Kconfig
arch/arm/mach-davinci/Kconfig
arch/arm/mach-exynos/Kconfig
arch/arm/mach-highbank/Kconfig
arch/arm/mach-omap2/Kconfig
arch/arm/mach-s5pv210/Kconfig
arch/arm/mach-tango/Kconfig
fs/proc/kcore.c
include/linux/mmzone.h
mm/mmzone.c
mm/vmstat.c

index 58a12376b7df71dd1d8c534f6b468792a94e6b79..94db75ba7fbe289902d636240d52419d479977d9 100644 (file)
@@ -52,8 +52,7 @@ wrapper :c:func:`free_area_init`. Yet, the mappings array is not
 usable until the call to :c:func:`memblock_free_all` that hands all
 the memory to the page allocator.
 
-If an architecture enables `CONFIG_ARCH_HAS_HOLES_MEMORYMODEL` option,
-it may free parts of the `mem_map` array that do not cover the
+An architecture may free parts of the `mem_map` array that do not cover the
 actual physical pages. In such case, the architecture specific
 :c:func:`pfn_valid` implementation should take the holes in the
 `mem_map` into account.
index 4b36bbcf5a5b419a4c265cb73d10e90f13a14890..a1622b9290fd5f629931f8405b003b4dde116553 100644 (file)
@@ -26,7 +26,7 @@ config ARM
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
        select ARCH_HAVE_CUSTOM_GPIO_H
        select ARCH_HAS_GCOV_PROFILE_ALL
-       select ARCH_KEEP_MEMBLOCK if HAVE_ARCH_PFN_VALID || KEXEC
+       select ARCH_KEEP_MEMBLOCK
        select ARCH_MIGHT_HAVE_PC_PARPORT
        select ARCH_NO_SG_CHAIN if !ARM_HAS_SG_CHAIN
        select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
@@ -521,7 +521,6 @@ config ARCH_S3C24XX
 config ARCH_OMAP1
        bool "TI OMAP1"
        depends on MMU
-       select ARCH_HAS_HOLES_MEMORYMODEL
        select ARCH_OMAP
        select CLKDEV_LOOKUP
        select CLKSRC_MMIO
@@ -1518,9 +1517,6 @@ config OABI_COMPAT
          UNPREDICTABLE (in fact it can be predicted that it won't work
          at all). If in doubt say N.
 
-config ARCH_HAS_HOLES_MEMORYMODEL
-       bool
-
 config ARCH_SPARSEMEM_ENABLE
        bool
 
@@ -1528,7 +1524,7 @@ config ARCH_SPARSEMEM_DEFAULT
        def_bool ARCH_SPARSEMEM_ENABLE
 
 config HAVE_ARCH_PFN_VALID
-       def_bool ARCH_HAS_HOLES_MEMORYMODEL || !SPARSEMEM
+       def_bool y
 
 config HIGHMEM
        bool "High Memory Support"
index 5e5f1fabc3d409f4a5e2e6f6ab453b6e718d6d04..634d1bc3c0114fc99e17dd2dc697b2e653545110 100644 (file)
@@ -214,7 +214,6 @@ config ARCH_BRCMSTB
        select HAVE_ARM_ARCH_TIMER
        select BRCMSTB_L2_IRQ
        select BCM7120_L2_IRQ
-       select ARCH_HAS_HOLES_MEMORYMODEL
        select ZONE_DMA if ARM_LPAE
        select SOC_BRCMSTB
        select SOC_BUS
index 02b180ad724540c022d861aab5c6929f37af8060..4d3b7d0418c408d5a43e92f60226086c55eedb1e 100644 (file)
@@ -5,7 +5,6 @@ menuconfig ARCH_DAVINCI
        depends on ARCH_MULTI_V5
        select DAVINCI_TIMER
        select ZONE_DMA
-       select ARCH_HAS_HOLES_MEMORYMODEL
        select PM_GENERIC_DOMAINS if PM
        select PM_GENERIC_DOMAINS_OF if PM && OF
        select REGMAP_MMIO
index 9dab1f50a02f83c35d6beaed5769cbace59485b4..fc01137628e4bcaa37c607407271d8498de948bd 100644 (file)
@@ -8,7 +8,6 @@
 menuconfig ARCH_EXYNOS
        bool "Samsung EXYNOS"
        depends on ARCH_MULTI_V7
-       select ARCH_HAS_HOLES_MEMORYMODEL
        select ARCH_SUPPORTS_BIG_ENDIAN
        select ARM_AMBA
        select ARM_GIC
index 1bc68913d62c1fb24cbfa1cca10bfdc01a6b06e8..9de38ce8124f2b75c2c675ddba91a3408726c264 100644 (file)
@@ -2,7 +2,6 @@
 config ARCH_HIGHBANK
        bool "Calxeda ECX-1000/2000 (Highbank/Midway)"
        depends on ARCH_MULTI_V7
-       select ARCH_HAS_HOLES_MEMORYMODEL
        select ARCH_SUPPORTS_BIG_ENDIAN
        select ARM_AMBA
        select ARM_ERRATA_764369 if SMP
index fdb6743760a2ef90e36ee3c3787176791e535fc7..0211f4aa8cc754d1aab1ca04bf0f1667d5132e71 100644 (file)
@@ -94,7 +94,7 @@ config SOC_DRA7XX
 config ARCH_OMAP2PLUS
        bool
        select ARCH_HAS_BANDGAP
-       select ARCH_HAS_HOLES_MEMORYMODEL
+       select ARCH_HAS_RESET_CONTROLLER
        select ARCH_OMAP
        select CLKSRC_MMIO
        select GENERIC_IRQ_CHIP
index 03984a791879115e29fdae2b7595cced965ef94d..69ff1bb89f38f709a63dfe1bcd5e5030257354f8 100644 (file)
@@ -8,7 +8,6 @@
 config ARCH_S5PV210
        bool "Samsung S5PV210/S5PC110"
        depends on ARCH_MULTI_V7
-       select ARCH_HAS_HOLES_MEMORYMODEL
        select ARM_VIC
        select CLKSRC_SAMSUNG_PWM
        select COMMON_CLK_SAMSUNG
index 25b2fd4348617ec1a65dc54803e3c9996cabd02b..a9eeda36aeb1535d2c2ef465de7fbaa4a6631da5 100644 (file)
@@ -3,7 +3,6 @@ config ARCH_TANGO
        bool "Sigma Designs Tango4 (SMP87xx)"
        depends on ARCH_MULTI_V7
        # Cortex-A9 MPCore r3p0, PL310 r3p2
-       select ARCH_HAS_HOLES_MEMORYMODEL
        select ARM_ERRATA_754322
        select ARM_ERRATA_764369 if SMP
        select ARM_ERRATA_775420
index e2ed8e08cc7adc2b6bb7739e245002ca53f5c873..d1cabccc02b7a729207c434e77d92095ef066381 100644 (file)
@@ -193,8 +193,6 @@ kclist_add_private(unsigned long pfn, unsigned long nr_pages, void *arg)
                return 1;
 
        p = pfn_to_page(pfn);
-       if (!memmap_valid_within(pfn, p, page_zone(p)))
-               return 1;
 
        ent = kmalloc(sizeof(*ent), GFP_KERNEL);
        if (!ent)
index e4f9df955040f46cda31c9c56f2ef2e5033977c0..b138ddad619e8db52e04f0f3b6a1342edd482863 100644 (file)
@@ -1438,37 +1438,6 @@ void memory_present(int nid, unsigned long start, unsigned long end);
 #define pfn_valid_within(pfn) (1)
 #endif
 
-#ifdef CONFIG_ARCH_HAS_HOLES_MEMORYMODEL
-/*
- * pfn_valid() is meant to be able to tell if a given PFN has valid memmap
- * associated with it or not. This means that a struct page exists for this
- * pfn. The caller cannot assume the page is fully initialized in general.
- * Hotplugable pages might not have been onlined yet. pfn_to_online_page()
- * will ensure the struct page is fully online and initialized. Special pages
- * (e.g. ZONE_DEVICE) are never onlined and should be treated accordingly.
- *
- * In FLATMEM, it is expected that holes always have valid memmap as long as
- * there is valid PFNs either side of the hole. In SPARSEMEM, it is assumed
- * that a valid section has a memmap for the entire section.
- *
- * However, an ARM, and maybe other embedded architectures in the future
- * free memmap backing holes to save memory on the assumption the memmap is
- * never used. The page_zone linkages are then broken even though pfn_valid()
- * returns true. A walker of the full memmap must then do this additional
- * check to ensure the memmap they are looking at is sane by making sure
- * the zone and PFN linkages are still valid. This is expensive, but walkers
- * of the full memmap are extremely rare.
- */
-bool memmap_valid_within(unsigned long pfn,
-                                       struct page *page, struct zone *zone);
-#else
-static inline bool memmap_valid_within(unsigned long pfn,
-                                       struct page *page, struct zone *zone)
-{
-       return true;
-}
-#endif /* CONFIG_ARCH_HAS_HOLES_MEMORYMODEL */
-
 #endif /* !__GENERATING_BOUNDS.H */
 #endif /* !__ASSEMBLY__ */
 #endif /* _LINUX_MMZONE_H */
index 4686fdc23bb966223d40a39fa11187f89e582dec..f337831affc2dbb94e22e9bd39a8e7f60566df61 100644 (file)
@@ -72,20 +72,6 @@ struct zoneref *__next_zones_zonelist(struct zoneref *z,
        return z;
 }
 
-#ifdef CONFIG_ARCH_HAS_HOLES_MEMORYMODEL
-bool memmap_valid_within(unsigned long pfn,
-                                       struct page *page, struct zone *zone)
-{
-       if (page_to_pfn(page) != pfn)
-               return false;
-
-       if (page_zone(page) != zone)
-               return false;
-
-       return true;
-}
-#endif /* CONFIG_ARCH_HAS_HOLES_MEMORYMODEL */
-
 void lruvec_init(struct lruvec *lruvec)
 {
        enum lru_list lru;
index a8222041bd44d648a4c8b5a1e5e345314efb050e..240fe2153ca9e1df0de25d69205513b023b97f30 100644 (file)
@@ -1444,10 +1444,6 @@ static void pagetypeinfo_showblockcount_print(struct seq_file *m,
                if (!page)
                        continue;
 
-               /* Watch for unexpected holes punched in the memmap */
-               if (!memmap_valid_within(pfn, page, zone))
-                       continue;
-
                if (page_zone(page) != zone)
                        continue;