All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, will.deacon@arm.com,
	catalin.marinas@arm.com, mgorman@techsingularity.net,
	james.morse@arm.com, mark.rutland@arm.com, robin.murphy@arm.com,
	cpandya@codeaurora.org, arunks@codeaurora.org,
	dan.j.williams@intel.com, osalvador@suse.de, logang@deltatee.com,
	pasha.tatashin@oracle.com, david@redhat.com, cai@lca.pw
Subject: Re: [PATCH 5/6] mm/memremap: Rename and consolidate SECTION_SIZE
Date: Wed, 3 Apr 2019 11:26:44 +0200	[thread overview]
Message-ID: <20190403092644.GH15605@dhcp22.suse.cz> (raw)
In-Reply-To: <1554265806-11501-6-git-send-email-anshuman.khandual@arm.com>

On Wed 03-04-19 10:00:05, Anshuman Khandual wrote:
> From: Robin Murphy <robin.murphy@arm.com>
> 
> Enabling ZONE_DEVICE (through ARCH_HAS_ZONE_DEVICE) for arm64 reveals that
> memremap's internal helpers for sparsemem sections conflict with arm64's
> definitions for hugepages which inherit the name of "sections" from earlier
> versions of the ARM architecture.
> 
> Disambiguate memremap by propagating sparsemem's PA_ prefix, to clarify
> that these values are in terms of addresses rather than PFNs (and
> because it's a heck of a lot easier than changing all the arch code).
> SECTION_MASK is unused, so it can just go. While here consolidate single
> instance of PA_SECTION_SIZE from mm/hmm.c as well.
> 
> [anshuman: Consolidated mm/hmm.c instance and updated the commit message]

Agreed. mremap shouldn't have redefined SECTION_SIZE in the first place.
This just adds a confusion.

> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  include/linux/mmzone.h |  1 +
>  kernel/memremap.c      | 10 ++++------
>  mm/hmm.c               |  2 --
>  3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index fba7741..ed7dd27 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -1081,6 +1081,7 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn)
>   * PFN_SECTION_SHIFT		pfn to/from section number
>   */
>  #define PA_SECTION_SHIFT	(SECTION_SIZE_BITS)
> +#define PA_SECTION_SIZE		(1UL << PA_SECTION_SHIFT)
>  #define PFN_SECTION_SHIFT	(SECTION_SIZE_BITS - PAGE_SHIFT)
>  
>  #define NR_MEM_SECTIONS		(1UL << SECTIONS_SHIFT)
> diff --git a/kernel/memremap.c b/kernel/memremap.c
> index a856cb5..dda1367 100644
> --- a/kernel/memremap.c
> +++ b/kernel/memremap.c
> @@ -14,8 +14,6 @@
>  #include <linux/hmm.h>
>  
>  static DEFINE_XARRAY(pgmap_array);
> -#define SECTION_MASK ~((1UL << PA_SECTION_SHIFT) - 1)
> -#define SECTION_SIZE (1UL << PA_SECTION_SHIFT)
>  
>  #if IS_ENABLED(CONFIG_DEVICE_PRIVATE)
>  vm_fault_t device_private_entry_fault(struct vm_area_struct *vma,
> @@ -98,8 +96,8 @@ static void devm_memremap_pages_release(void *data)
>  		put_page(pfn_to_page(pfn));
>  
>  	/* pages are dead and unused, undo the arch mapping */
> -	align_start = res->start & ~(SECTION_SIZE - 1);
> -	align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
> +	align_start = res->start & ~(PA_SECTION_SIZE - 1);
> +	align_size = ALIGN(res->start + resource_size(res), PA_SECTION_SIZE)
>  		- align_start;
>  
>  	nid = page_to_nid(pfn_to_page(align_start >> PAGE_SHIFT));
> @@ -154,8 +152,8 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)
>  	if (!pgmap->ref || !pgmap->kill)
>  		return ERR_PTR(-EINVAL);
>  
> -	align_start = res->start & ~(SECTION_SIZE - 1);
> -	align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
> +	align_start = res->start & ~(PA_SECTION_SIZE - 1);
> +	align_size = ALIGN(res->start + resource_size(res), PA_SECTION_SIZE)
>  		- align_start;
>  	align_end = align_start + align_size - 1;
>  
> diff --git a/mm/hmm.c b/mm/hmm.c
> index fe1cd87..ef9e4e6 100644
> --- a/mm/hmm.c
> +++ b/mm/hmm.c
> @@ -33,8 +33,6 @@
>  #include <linux/mmu_notifier.h>
>  #include <linux/memory_hotplug.h>
>  
> -#define PA_SECTION_SIZE (1UL << PA_SECTION_SHIFT)
> -
>  #if IS_ENABLED(CONFIG_HMM_MIRROR)
>  static const struct mmu_notifier_ops hmm_mmu_notifier_ops;
>  
> -- 
> 2.7.4
> 

-- 
Michal Hocko
SUSE Labs

WARNING: multiple messages have this Message-ID (diff)
From: Michal Hocko <mhocko@kernel.org>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: mark.rutland@arm.com, david@redhat.com, catalin.marinas@arm.com,
	cai@lca.pw, will.deacon@arm.com, linux-kernel@vger.kernel.org,
	pasha.tatashin@oracle.com, linux-mm@kvack.org,
	logang@deltatee.com, james.morse@arm.com, cpandya@codeaurora.org,
	arunks@codeaurora.org, akpm@linux-foundation.org,
	osalvador@suse.de, mgorman@techsingularity.net,
	dan.j.williams@intel.com, linux-arm-kernel@lists.infradead.org,
	robin.murphy@arm.com
Subject: Re: [PATCH 5/6] mm/memremap: Rename and consolidate SECTION_SIZE
Date: Wed, 3 Apr 2019 11:26:44 +0200	[thread overview]
Message-ID: <20190403092644.GH15605@dhcp22.suse.cz> (raw)
In-Reply-To: <1554265806-11501-6-git-send-email-anshuman.khandual@arm.com>

On Wed 03-04-19 10:00:05, Anshuman Khandual wrote:
> From: Robin Murphy <robin.murphy@arm.com>
> 
> Enabling ZONE_DEVICE (through ARCH_HAS_ZONE_DEVICE) for arm64 reveals that
> memremap's internal helpers for sparsemem sections conflict with arm64's
> definitions for hugepages which inherit the name of "sections" from earlier
> versions of the ARM architecture.
> 
> Disambiguate memremap by propagating sparsemem's PA_ prefix, to clarify
> that these values are in terms of addresses rather than PFNs (and
> because it's a heck of a lot easier than changing all the arch code).
> SECTION_MASK is unused, so it can just go. While here consolidate single
> instance of PA_SECTION_SIZE from mm/hmm.c as well.
> 
> [anshuman: Consolidated mm/hmm.c instance and updated the commit message]

Agreed. mremap shouldn't have redefined SECTION_SIZE in the first place.
This just adds a confusion.

> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  include/linux/mmzone.h |  1 +
>  kernel/memremap.c      | 10 ++++------
>  mm/hmm.c               |  2 --
>  3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index fba7741..ed7dd27 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -1081,6 +1081,7 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn)
>   * PFN_SECTION_SHIFT		pfn to/from section number
>   */
>  #define PA_SECTION_SHIFT	(SECTION_SIZE_BITS)
> +#define PA_SECTION_SIZE		(1UL << PA_SECTION_SHIFT)
>  #define PFN_SECTION_SHIFT	(SECTION_SIZE_BITS - PAGE_SHIFT)
>  
>  #define NR_MEM_SECTIONS		(1UL << SECTIONS_SHIFT)
> diff --git a/kernel/memremap.c b/kernel/memremap.c
> index a856cb5..dda1367 100644
> --- a/kernel/memremap.c
> +++ b/kernel/memremap.c
> @@ -14,8 +14,6 @@
>  #include <linux/hmm.h>
>  
>  static DEFINE_XARRAY(pgmap_array);
> -#define SECTION_MASK ~((1UL << PA_SECTION_SHIFT) - 1)
> -#define SECTION_SIZE (1UL << PA_SECTION_SHIFT)
>  
>  #if IS_ENABLED(CONFIG_DEVICE_PRIVATE)
>  vm_fault_t device_private_entry_fault(struct vm_area_struct *vma,
> @@ -98,8 +96,8 @@ static void devm_memremap_pages_release(void *data)
>  		put_page(pfn_to_page(pfn));
>  
>  	/* pages are dead and unused, undo the arch mapping */
> -	align_start = res->start & ~(SECTION_SIZE - 1);
> -	align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
> +	align_start = res->start & ~(PA_SECTION_SIZE - 1);
> +	align_size = ALIGN(res->start + resource_size(res), PA_SECTION_SIZE)
>  		- align_start;
>  
>  	nid = page_to_nid(pfn_to_page(align_start >> PAGE_SHIFT));
> @@ -154,8 +152,8 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)
>  	if (!pgmap->ref || !pgmap->kill)
>  		return ERR_PTR(-EINVAL);
>  
> -	align_start = res->start & ~(SECTION_SIZE - 1);
> -	align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
> +	align_start = res->start & ~(PA_SECTION_SIZE - 1);
> +	align_size = ALIGN(res->start + resource_size(res), PA_SECTION_SIZE)
>  		- align_start;
>  	align_end = align_start + align_size - 1;
>  
> diff --git a/mm/hmm.c b/mm/hmm.c
> index fe1cd87..ef9e4e6 100644
> --- a/mm/hmm.c
> +++ b/mm/hmm.c
> @@ -33,8 +33,6 @@
>  #include <linux/mmu_notifier.h>
>  #include <linux/memory_hotplug.h>
>  
> -#define PA_SECTION_SIZE (1UL << PA_SECTION_SHIFT)
> -
>  #if IS_ENABLED(CONFIG_HMM_MIRROR)
>  static const struct mmu_notifier_ops hmm_mmu_notifier_ops;
>  
> -- 
> 2.7.4
> 

-- 
Michal Hocko
SUSE Labs

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-04-03  9:26 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03  4:30 [PATCH 0/6] arm64/mm: Enable memory hot remove and ZONE_DEVICE Anshuman Khandual
2019-04-03  4:30 ` Anshuman Khandual
2019-04-03  4:30 ` [PATCH 1/6] arm64/mm: Enable sysfs based memory hot add interface Anshuman Khandual
2019-04-03  4:30   ` Anshuman Khandual
2019-04-03  8:20   ` David Hildenbrand
2019-04-03  8:20     ` David Hildenbrand
2019-04-03 13:12     ` Robin Murphy
2019-04-03 13:12       ` Robin Murphy
2019-04-04  5:21       ` Anshuman Khandual
2019-04-04  5:21         ` Anshuman Khandual
2019-04-04  5:25     ` Anshuman Khandual
2019-04-04  5:25       ` Anshuman Khandual
2019-04-04  8:49       ` David Hildenbrand
2019-04-04  8:49         ` David Hildenbrand
2019-04-03  4:30 ` [PATCH 2/6] arm64/mm: Enable memory hot remove Anshuman Khandual
2019-04-03  4:30   ` Anshuman Khandual
2019-04-03 12:37   ` Robin Murphy
2019-04-03 12:37     ` Robin Murphy
2019-04-03 13:15     ` Steven Price
2019-04-03 13:15       ` Steven Price
2019-04-04  6:51       ` Anshuman Khandual
2019-04-04  6:51         ` Anshuman Khandual
2019-04-04  5:39     ` Anshuman Khandual
2019-04-04  5:39       ` Anshuman Khandual
2019-04-04 11:58       ` Oscar Salvador
2019-04-04 11:58         ` Oscar Salvador
2019-04-04 13:03         ` Anshuman Khandual
2019-04-04 13:03           ` Anshuman Khandual
2019-04-04 15:19           ` Oscar Salvador
2019-04-04 15:19             ` Oscar Salvador
2019-04-03 17:32   ` Logan Gunthorpe
2019-04-03 17:32     ` Logan Gunthorpe
2019-04-03 17:57     ` Robin Murphy
2019-04-03 17:57       ` Robin Murphy
2019-04-04  8:23       ` Anshuman Khandual
2019-04-04  8:23         ` Anshuman Khandual
2019-04-04  7:07     ` Anshuman Khandual
2019-04-04  7:07       ` Anshuman Khandual
2019-04-04  9:16       ` Steven Price
2019-04-04  9:16         ` Steven Price
2019-04-03  4:30 ` [PATCH 3/6] arm64/mm: Enable struct page allocation from device memory Anshuman Khandual
2019-04-03  4:30   ` Anshuman Khandual
2019-04-03  4:30 ` [PATCH 4/6] mm/hotplug: Reorder arch_remove_memory() call in __remove_memory() Anshuman Khandual
2019-04-03  4:30   ` Anshuman Khandual
2019-04-03  8:45   ` Oscar Salvador
2019-04-03  8:45     ` Oscar Salvador
2019-04-03  9:17   ` Michal Hocko
2019-04-03  9:17     ` Michal Hocko
2019-04-04  8:32     ` Anshuman Khandual
2019-04-04  8:32       ` Anshuman Khandual
2019-04-03  9:30   ` David Hildenbrand
2019-04-03  9:30     ` David Hildenbrand
2019-04-03  4:30 ` [PATCH 5/6] mm/memremap: Rename and consolidate SECTION_SIZE Anshuman Khandual
2019-04-03  4:30   ` Anshuman Khandual
2019-04-03  9:26   ` Michal Hocko [this message]
2019-04-03  9:26     ` Michal Hocko
2019-04-03  9:30   ` David Hildenbrand
2019-04-03  9:30     ` David Hildenbrand
2019-04-03  4:30 ` [PATCH 6/6] arm64/mm: Enable ZONE_DEVICE Anshuman Khandual
2019-04-03  4:30   ` Anshuman Khandual
2019-04-03 13:58   ` Robin Murphy
2019-04-03 13:58     ` Robin Murphy
2019-04-03 16:07     ` Jerome Glisse
2019-04-03 16:07       ` Jerome Glisse
2019-04-04  5:03       ` Anshuman Khandual
2019-04-04  5:03         ` Anshuman Khandual
2019-04-04  4:42     ` Anshuman Khandual
2019-04-04  4:42       ` Anshuman Khandual
2019-04-04  5:04       ` Dan Williams
2019-04-04  5:04         ` Dan Williams
2019-04-04  9:46         ` Robin Murphy
2019-04-04  9:46           ` Robin Murphy
2019-04-07 22:11           ` Dan Williams
2019-04-07 22:11             ` Dan Williams
2019-04-08  4:03             ` Ira Weiny
2019-04-08  4:03               ` Ira Weiny
2019-04-08  6:03               ` Anshuman Khandual
2019-04-08  6:03                 ` Anshuman Khandual
2019-04-03 18:08 ` [PATCH 0/6] arm64/mm: Enable memory hot remove and ZONE_DEVICE Dan Williams
2019-04-03 18:08   ` Dan Williams
2019-04-03 18:08   ` Dan Williams
2019-04-04 13:11   ` Anshuman Khandual
2019-04-04 13:11     ` Anshuman Khandual
2019-04-04  9:46 ` [RFC 1/2] mm/vmemmap: Enable vmem_altmap based base page mapping for vmemmap Anshuman Khandual
2019-04-04  9:46   ` Anshuman Khandual
2019-04-04  9:46   ` [RFC 2/2] arm64/mm: Enable ZONE_DEVICE for all page configs Anshuman Khandual
2019-04-04  9:46     ` Anshuman Khandual

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190403092644.GH15605@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=arunks@codeaurora.org \
    --cc=cai@lca.pw \
    --cc=catalin.marinas@arm.com \
    --cc=cpandya@codeaurora.org \
    --cc=dan.j.williams@intel.com \
    --cc=david@redhat.com \
    --cc=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=logang@deltatee.com \
    --cc=mark.rutland@arm.com \
    --cc=mgorman@techsingularity.net \
    --cc=osalvador@suse.de \
    --cc=pasha.tatashin@oracle.com \
    --cc=robin.murphy@arm.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.