linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: akpm@linux-foundation.org
Cc: Michal Hocko <mhocko@suse.com>,
	linux-nvdimm@lists.01.org, Logan Gunthorpe <logang@deltatee.com>,
	linux-kernel@vger.kernel.org,
	Stephen Bates <stephen.bates@microsemi.com>,
	linux-mm@kvack.org, Johannes Weiner <hannes@cmpxchg.org>,
	Mel Gorman <mgorman@techsingularity.net>,
	Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH v4 04/13] mm: introduce common definitions for the size and mask of a section
Date: Wed, 15 Mar 2017 23:07:09 -0700	[thread overview]
Message-ID: <148964442915.19438.13692551999756522608.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <148964440651.19438.2288075389153762985.stgit@dwillia2-desk3.amr.corp.intel.com>

Up-level the local section size and mask from kernel/memremap.c to
global definitions.  These will be used by the new sub-section hotplug
support.

Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Logan Gunthorpe <logang@deltatee.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Stephen Bates <stephen.bates@microsemi.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 include/linux/mmzone.h |    2 ++
 kernel/memremap.c      |   10 ++++------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 82a1af3afa04..a95b83ee65ec 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1050,6 +1050,8 @@ 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 PA_SECTION_MASK		(~(PA_SECTION_SIZE-1))
 #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 72e93754c0f4..c4f63346ff52 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -172,8 +172,6 @@ EXPORT_SYMBOL(devm_memunmap);
 #ifdef CONFIG_ZONE_DEVICE
 static DEFINE_MUTEX(pgmap_lock);
 static RADIX_TREE(pgmap_radix, GFP_KERNEL);
-#define SECTION_MASK ~((1UL << PA_SECTION_SHIFT) - 1)
-#define SECTION_SIZE (1UL << PA_SECTION_SHIFT)
 
 struct page_map {
 	struct resource res;
@@ -267,8 +265,8 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
 	}
 
 	/* pages are dead and unused, undo the arch mapping */
-	align_start = res->start & ~(SECTION_SIZE - 1);
-	align_size = ALIGN(resource_size(res), SECTION_SIZE);
+	align_start = res->start & PA_SECTION_MASK;
+	align_size = ALIGN(resource_size(res), PA_SECTION_SIZE);
 
 	mem_hotplug_begin();
 	arch_remove_memory(align_start, align_size);
@@ -316,8 +314,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
 	struct page_map *page_map;
 	int error, nid, is_ram;
 
-	align_start = res->start & ~(SECTION_SIZE - 1);
-	align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
+	align_start = res->start & PA_SECTION_MASK;
+	align_size = ALIGN(res->start + resource_size(res), PA_SECTION_SIZE)
 		- align_start;
 	is_ram = region_intersects(align_start, align_size,
 		IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2017-03-16  6:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16  6:06 [PATCH v4 00/13] mm: sub-section memory hotplug support Dan Williams
2017-03-16  6:06 ` [PATCH v4 01/13] mm: fix type width of section to/from pfn conversion macros Dan Williams
2017-03-16  6:06 ` [PATCH v4 02/13] mm, devm_memremap_pages: use multi-order radix for ZONE_DEVICE lookups Dan Williams
2017-03-16  6:07 ` [PATCH v4 03/13] mm: introduce struct mem_section_usage to track partial population of a section Dan Williams
2017-03-16  6:07 ` Dan Williams [this message]
2017-03-16  6:07 ` [PATCH v4 05/13] mm: cleanup sparse_init_one_section() return value Dan Williams
2017-03-16  6:07 ` [PATCH v4 06/13] mm: track active portions of a section at boot Dan Williams
2017-03-16  6:07 ` [PATCH v4 07/13] mm: fix register_new_memory() zone type detection Dan Williams
2017-03-16  6:07 ` [PATCH v4 08/13] x86, kasan: clarify kasan's dependency on vmemmap_populate_hugepages() Dan Williams
2017-03-20 15:43   ` Andrey Ryabinin
2017-03-16  6:07 ` [PATCH v4 09/13] mm: convert kmalloc_section_memmap() to populate_section_memmap() Dan Williams
2017-03-16  6:07 ` [PATCH v4 10/13] mm: prepare for hot-{add, remove} of sub-section ranges Dan Williams
2017-03-16  6:07 ` [PATCH v4 11/13] mm: support section-unaligned ZONE_DEVICE memory ranges Dan Williams
2017-03-16  6:07 ` [PATCH v4 12/13] mm: enable section-unaligned devm_memremap_pages() Dan Williams
2017-03-16  6:07 ` [PATCH v4 13/13] libnvdimm, pfn, dax: stop padding pmem namespaces to section alignment Dan Williams
2017-03-16 17:48 ` [PATCH v4 00/13] mm: sub-section memory hotplug support Michal Hocko
2017-03-16 19:04   ` Dan Williams
2017-03-19 16:35     ` Michal Hocko

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=148964442915.19438.13692551999756522608.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=logang@deltatee.com \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=stephen.bates@microsemi.com \
    --cc=vbabka@suse.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox