Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3171882pxx; Mon, 2 Nov 2020 01:46:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJ/npQIJD/xFrFXVQRll5vTv5XqPUk9nFlQou2TLqqoY+fRs+PB/ycwikYGNb+qjSymLIg X-Received: by 2002:a50:d5dd:: with SMTP id g29mr10023694edj.379.1604310360964; Mon, 02 Nov 2020 01:46:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604310360; cv=none; d=google.com; s=arc-20160816; b=YXypxYCbRSh88EZrhYrhXSsACIG4ExnH7El9ERmj36+9RYuOmc3xoOJed5mvI+DPbB cnhhZxF+62iPEpAZ89a9N4cojteCIPFGJGz8ffvVm0vZwUFoj/kw2pcI2e8bBs3sWNZb mbVuZc5EyjdA5+ku4t7POOOsEJUF97fvUFznxXS7fRTsgOatvr5gdWn2CFgQlMLJg+RV pyREUt9lREqshcxqewsKA6GGPBF7O5axkn/z+d/xMvcLwmX9JSC2wMw4vIvv9V8OLuhQ 8UcPAxkGoDFJt2j2u+iqYSM1tR8RTwwDooqg1vUUX1Mc1w6lSmg1OA4iTdGH8qgN9Hdm HDXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=kn31uEVM3N2sjYmZw9PL6ElgXwL4Hs7/D2Hi6HLxB6k=; b=iv2phaIbcbytS0egaQ7C3m6CBxI4Y2LB5G7vJkp0SGO8lEyjYzrBk4eKeY2ip+yYQn U1Y8N3fsmJjO5xdCpwcIOCiZYNofpiw05qQQUfxsR/G89uULMDcTSl+PAC4x37toCBaH 8W+3HC0IXt6rS2Q/J5decvA45MiNJCmVkBFXqDJowxl+v+Av+gN9iJSwbQn9MBuuHUSH uhbhOBbUW2lxfdDS+LSQK9VDM37ILlfQ9BhRLKuQ9Ph2k42dESdzJdFTP9QgC1J430kk p+I5h1QVCSMnPELOIFV0Xz/lZKKit+fcOqNSMT/bL4DuK53slGruf/xKT307KdbKrwmC AtRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C0PH3gOV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si11270794edq.273.2020.11.02.01.45.37; Mon, 02 Nov 2020 01:46:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C0PH3gOV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728347AbgKBJoJ (ORCPT + 99 others); Mon, 2 Nov 2020 04:44:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28426 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728226AbgKBJoI (ORCPT ); Mon, 2 Nov 2020 04:44:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604310246; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kn31uEVM3N2sjYmZw9PL6ElgXwL4Hs7/D2Hi6HLxB6k=; b=C0PH3gOVCjqfkdPX3VF2y8Ln+/KZQ3MXAguVACtlKJ7gMoc+dDiB3tyR+7QPKFf96C39du vaX7f4nIoGAVqacTGqbL+CgHnafGYwPL8foGGgXt6jwSNWnL7tDHpWFbqevnYp6BCDd80B jQu9y19+nJHcd7m7BHqBkpci9Fr1w78= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-525-OFKv3v7rMuiwfziyc0lf8Q-1; Mon, 02 Nov 2020 04:44:01 -0500 X-MC-Unique: OFKv3v7rMuiwfziyc0lf8Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C345F809DC6; Mon, 2 Nov 2020 09:43:57 +0000 (UTC) Received: from [10.36.113.163] (ovpn-113-163.ams2.redhat.com [10.36.113.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CEA460CCC; Mon, 2 Nov 2020 09:43:51 +0000 (UTC) Subject: Re: [PATCH v2 08/13] arm: remove CONFIG_ARCH_HAS_HOLES_MEMORYMODEL To: Mike Rapoport , Andrew Morton Cc: Alexey Dobriyan , Catalin Marinas , Geert Uytterhoeven , Greg Ungerer , John Paul Adrian Glaubitz , Jonathan Corbet , Matt Turner , Meelis Roos , Michael Schmitz , Mike Rapoport , Russell King , Tony Luck , Vineet Gupta , Will Deacon , linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mm@kvack.org, linux-snps-arc@lists.infradead.org References: <20201101170454.9567-1-rppt@kernel.org> <20201101170454.9567-9-rppt@kernel.org> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <81410b81-b773-b4a2-5f03-e9f1a6a8e8e9@redhat.com> Date: Mon, 2 Nov 2020 10:43:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20201101170454.9567-9-rppt@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01.11.20 18:04, Mike Rapoport wrote: > From: Mike Rapoport > > 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. > > Signed-off-by: Mike Rapoport > --- > Documentation/vm/memory-model.rst | 3 +-- > arch/arm/Kconfig | 8 ++------ > arch/arm/mach-bcm/Kconfig | 1 - > arch/arm/mach-davinci/Kconfig | 1 - > arch/arm/mach-exynos/Kconfig | 1 - > arch/arm/mach-highbank/Kconfig | 1 - > arch/arm/mach-omap2/Kconfig | 1 - > arch/arm/mach-s5pv210/Kconfig | 1 - > arch/arm/mach-tango/Kconfig | 1 - > fs/proc/kcore.c | 2 -- > include/linux/mmzone.h | 31 ------------------------------- > mm/mmzone.c | 14 -------------- > mm/vmstat.c | 4 ---- > 13 files changed, 3 insertions(+), 66 deletions(-) > > diff --git a/Documentation/vm/memory-model.rst b/Documentation/vm/memory-model.rst > index 9daadf9faba1..ce398a7dc6cd 100644 > --- a/Documentation/vm/memory-model.rst > +++ b/Documentation/vm/memory-model.rst > @@ -51,8 +51,7 @@ call :c:func:`free_area_init` function. 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. > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > index fe2f17eb2b50..83adc46c1e67 100644 > --- a/arch/arm/Kconfig > +++ b/arch/arm/Kconfig > @@ -25,7 +25,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 > @@ -519,7 +519,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 > @@ -1479,9 +1478,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_SELECT_MEMORY_MODEL > bool > > @@ -1493,7 +1489,7 @@ config ARCH_SPARSEMEM_ENABLE > select SPARSEMEM_STATIC if SPARSEMEM > > config HAVE_ARCH_PFN_VALID > - def_bool ARCH_HAS_HOLES_MEMORYMODEL || !SPARSEMEM > + def_bool y > > config HIGHMEM > bool "High Memory Support" > diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig > index ae790908fc74..9b594ae98153 100644 > --- a/arch/arm/mach-bcm/Kconfig > +++ b/arch/arm/mach-bcm/Kconfig > @@ -211,7 +211,6 @@ config ARCH_BRCMSTB > select BCM7038_L1_IRQ > 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 > diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig > index f56ff8c24043..de11030748d0 100644 > --- a/arch/arm/mach-davinci/Kconfig > +++ b/arch/arm/mach-davinci/Kconfig > @@ -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 > diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig > index d2d249706ebb..56d272967fc0 100644 > --- a/arch/arm/mach-exynos/Kconfig > +++ b/arch/arm/mach-exynos/Kconfig > @@ -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 > diff --git a/arch/arm/mach-highbank/Kconfig b/arch/arm/mach-highbank/Kconfig > index 1bc68913d62c..9de38ce8124f 100644 > --- a/arch/arm/mach-highbank/Kconfig > +++ b/arch/arm/mach-highbank/Kconfig > @@ -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 > diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig > index 3ee7bdff86b2..89fe1572c142 100644 > --- a/arch/arm/mach-omap2/Kconfig > +++ b/arch/arm/mach-omap2/Kconfig > @@ -94,7 +94,6 @@ 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 > diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig > index 95d4e8284866..d644b45bc29d 100644 > --- a/arch/arm/mach-s5pv210/Kconfig > +++ b/arch/arm/mach-s5pv210/Kconfig > @@ -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 > diff --git a/arch/arm/mach-tango/Kconfig b/arch/arm/mach-tango/Kconfig > index 25b2fd434861..a9eeda36aeb1 100644 > --- a/arch/arm/mach-tango/Kconfig > +++ b/arch/arm/mach-tango/Kconfig > @@ -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 > diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c > index e502414b3556..4d2e64e9016c 100644 > --- a/fs/proc/kcore.c > +++ b/fs/proc/kcore.c > @@ -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) > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index 876600a6e891..7385871768d4 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -1440,37 +1440,6 @@ void sparse_init(void); > #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 */ > diff --git a/mm/mmzone.c b/mm/mmzone.c > index 4686fdc23bb9..f337831affc2 100644 > --- a/mm/mmzone.c > +++ b/mm/mmzone.c > @@ -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; > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 698bc0bc18d1..e292e63afebf 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -1503,10 +1503,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; > - Right, pfn_to_online_page() -> pfn_valid() / pfn_valid_within() should handle that. Acked-by: David Hildenbrand -- Thanks, David / dhildenb