linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6] mm/pgmap: Use correct alignment when looking at first pfn from a region
@ 2019-09-17 15:31 Aneesh Kumar K.V
  2019-09-17 21:57 ` Ralph Campbell
  2019-09-19 19:25 ` Andrew Morton
  0 siblings, 2 replies; 8+ messages in thread
From: Aneesh Kumar K.V @ 2019-09-17 15:31 UTC (permalink / raw)
  To: dan.j.williams, akpm; +Cc: linux-nvdimm, linux-mm, Aneesh Kumar K.V

vmem_altmap_offset() adjust the section aligned base_pfn offset.
So we need to make sure we account for the same when computing base_pfn.

ie, for altmap_valid case, our pfn_first should be:

pfn_first = altmap->base_pfn + vmem_altmap_offset(altmap);

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
* changes from v5
* update commit subject and use linux-mm for merge

 mm/memremap.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/mm/memremap.c b/mm/memremap.c
index ed70c4e8e52a..233908d7df75 100644
--- a/mm/memremap.c
+++ b/mm/memremap.c
@@ -54,8 +54,16 @@ static void pgmap_array_delete(struct resource *res)
 
 static unsigned long pfn_first(struct dev_pagemap *pgmap)
 {
-	return PHYS_PFN(pgmap->res.start) +
-		vmem_altmap_offset(pgmap_altmap(pgmap));
+	const struct resource *res = &pgmap->res;
+	struct vmem_altmap *altmap = pgmap_altmap(pgmap);
+	unsigned long pfn;
+
+	if (altmap) {
+		pfn = altmap->base_pfn + vmem_altmap_offset(altmap);
+	} else
+		pfn = PHYS_PFN(res->start);
+
+	return pfn;
 }
 
 static unsigned long pfn_end(struct dev_pagemap *pgmap)
-- 
2.21.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-01-31  4:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-17 15:31 [PATCH v6] mm/pgmap: Use correct alignment when looking at first pfn from a region Aneesh Kumar K.V
2019-09-17 21:57 ` Ralph Campbell
2019-09-19 19:25 ` Andrew Morton
2019-09-25  3:51   ` Aneesh Kumar K.V
2019-11-30 23:13     ` Andrew Morton
2019-12-03  0:50       ` Dan Williams
2019-12-03 10:12         ` Aneesh Kumar K.V
2020-01-31  4:26           ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).