All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at
@ 2017-04-04 14:04 Aneesh Kumar K.V
  2017-04-04 14:04 ` [RFC PATCH 2/7] mm/follow_page_mask: Split follow_page_mask to smaller functions Aneesh Kumar K.V
                   ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-04 14:04 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

The right interface to use to set a hugetlb pte entry is set_huge_pte_at. Use
that instead of set_pte_at.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 mm/migrate.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 9a0897a14d37..4c272ac6fe53 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -224,25 +224,26 @@ static int remove_migration_pte(struct page *page, struct vm_area_struct *vma,
 		if (is_write_migration_entry(entry))
 			pte = maybe_mkwrite(pte, vma);
 
+		flush_dcache_page(new);
 #ifdef CONFIG_HUGETLB_PAGE
 		if (PageHuge(new)) {
 			pte = pte_mkhuge(pte);
 			pte = arch_make_huge_pte(pte, vma, new, 0);
-		}
-#endif
-		flush_dcache_page(new);
-		set_pte_at(vma->vm_mm, pvmw.address, pvmw.pte, pte);
-
-		if (PageHuge(new)) {
+			set_huge_pte_at(vma->vm_mm, pvmw.address, pvmw.pte, pte);
 			if (PageAnon(new))
 				hugepage_add_anon_rmap(new, vma, pvmw.address);
 			else
 				page_dup_rmap(new, true);
-		} else if (PageAnon(new))
-			page_add_anon_rmap(new, vma, pvmw.address, false);
-		else
-			page_add_file_rmap(new, false);
+		} else
+#endif
+		{
+			set_pte_at(vma->vm_mm, pvmw.address, pvmw.pte, pte);
 
+			if (PageAnon(new))
+				page_add_anon_rmap(new, vma, pvmw.address, false);
+			else
+				page_add_file_rmap(new, false);
+		}
 		if (vma->vm_flags & VM_LOCKED && !PageTransCompound(new))
 			mlock_vma_page(new);
 
-- 
2.7.4

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

* [RFC PATCH 2/7] mm/follow_page_mask: Split follow_page_mask to smaller functions.
  2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
@ 2017-04-04 14:04 ` Aneesh Kumar K.V
  2017-04-07 11:04   ` Anshuman Khandual
  2017-04-04 14:04 ` [RFC PATCH 3/7] mm/hugetlb: export hugetlb_entry_migration helper Aneesh Kumar K.V
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-04 14:04 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

Makes code reading easy. No functional changes in this patch.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 mm/gup.c | 148 +++++++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 91 insertions(+), 57 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 04aa405350dc..73d46f9f7b81 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -208,68 +208,16 @@ static struct page *follow_page_pte(struct vm_area_struct *vma,
 	return no_page_table(vma, flags);
 }
 
-/**
- * follow_page_mask - look up a page descriptor from a user-virtual address
- * @vma: vm_area_struct mapping @address
- * @address: virtual address to look up
- * @flags: flags modifying lookup behaviour
- * @page_mask: on output, *page_mask is set according to the size of the page
- *
- * @flags can have FOLL_ flags set, defined in <linux/mm.h>
- *
- * Returns the mapped (struct page *), %NULL if no mapping exists, or
- * an error pointer if there is a mapping to something not represented
- * by a page descriptor (see also vm_normal_page()).
- */
-struct page *follow_page_mask(struct vm_area_struct *vma,
-			      unsigned long address, unsigned int flags,
-			      unsigned int *page_mask)
+static struct page *follow_pmd_mask(struct vm_area_struct *vma,
+				    unsigned long address, pud_t *pudp,
+				    unsigned int flags, unsigned int *page_mask)
 {
-	pgd_t *pgd;
-	p4d_t *p4d;
-	pud_t *pud;
 	pmd_t *pmd;
 	spinlock_t *ptl;
 	struct page *page;
 	struct mm_struct *mm = vma->vm_mm;
 
-	*page_mask = 0;
-
-	page = follow_huge_addr(mm, address, flags & FOLL_WRITE);
-	if (!IS_ERR(page)) {
-		BUG_ON(flags & FOLL_GET);
-		return page;
-	}
-
-	pgd = pgd_offset(mm, address);
-	if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
-		return no_page_table(vma, flags);
-	p4d = p4d_offset(pgd, address);
-	if (p4d_none(*p4d))
-		return no_page_table(vma, flags);
-	BUILD_BUG_ON(p4d_huge(*p4d));
-	if (unlikely(p4d_bad(*p4d)))
-		return no_page_table(vma, flags);
-	pud = pud_offset(p4d, address);
-	if (pud_none(*pud))
-		return no_page_table(vma, flags);
-	if (pud_huge(*pud) && vma->vm_flags & VM_HUGETLB) {
-		page = follow_huge_pud(mm, address, pud, flags);
-		if (page)
-			return page;
-		return no_page_table(vma, flags);
-	}
-	if (pud_devmap(*pud)) {
-		ptl = pud_lock(mm, pud);
-		page = follow_devmap_pud(vma, address, pud, flags);
-		spin_unlock(ptl);
-		if (page)
-			return page;
-	}
-	if (unlikely(pud_bad(*pud)))
-		return no_page_table(vma, flags);
-
-	pmd = pmd_offset(pud, address);
+	pmd = pmd_offset(pudp, address);
 	if (pmd_none(*pmd))
 		return no_page_table(vma, flags);
 	if (pmd_huge(*pmd) && vma->vm_flags & VM_HUGETLB) {
@@ -319,13 +267,99 @@ struct page *follow_page_mask(struct vm_area_struct *vma,
 		return ret ? ERR_PTR(ret) :
 			follow_page_pte(vma, address, pmd, flags);
 	}
-
 	page = follow_trans_huge_pmd(vma, address, pmd, flags);
 	spin_unlock(ptl);
 	*page_mask = HPAGE_PMD_NR - 1;
 	return page;
 }
 
+
+static struct page *follow_pud_mask(struct vm_area_struct *vma,
+				    unsigned long address, p4d_t *p4dp,
+				    unsigned int flags, unsigned int *page_mask)
+{
+	pud_t *pud;
+	spinlock_t *ptl;
+	struct page *page;
+	struct mm_struct *mm = vma->vm_mm;
+
+	pud = pud_offset(p4dp, address);
+	if (pud_none(*pud))
+		return no_page_table(vma, flags);
+	if (pud_huge(*pud) && vma->vm_flags & VM_HUGETLB) {
+		page = follow_huge_pud(mm, address, pud, flags);
+		if (page)
+			return page;
+		return no_page_table(vma, flags);
+	}
+	if (pud_devmap(*pud)) {
+		ptl = pud_lock(mm, pud);
+		page = follow_devmap_pud(vma, address, pud, flags);
+		spin_unlock(ptl);
+		if (page)
+			return page;
+	}
+	if (unlikely(pud_bad(*pud)))
+		return no_page_table(vma, flags);
+
+	return follow_pmd_mask(vma, address, pud, flags, page_mask);
+}
+
+
+static struct page *follow_p4d_mask(struct vm_area_struct *vma,
+				    unsigned long address, pgd_t *pgdp,
+				    unsigned int flags, unsigned int *page_mask)
+{
+	p4d_t *p4d;
+
+	p4d = p4d_offset(pgdp, address);
+	if (p4d_none(*p4d))
+		return no_page_table(vma, flags);
+	BUILD_BUG_ON(p4d_huge(*p4d));
+	if (unlikely(p4d_bad(*p4d)))
+		return no_page_table(vma, flags);
+
+	return follow_pud_mask(vma, address, p4d, flags, page_mask);
+}
+
+/**
+ * follow_page_mask - look up a page descriptor from a user-virtual address
+ * @vma: vm_area_struct mapping @address
+ * @address: virtual address to look up
+ * @flags: flags modifying lookup behaviour
+ * @page_mask: on output, *page_mask is set according to the size of the page
+ *
+ * @flags can have FOLL_ flags set, defined in <linux/mm.h>
+ *
+ * Returns the mapped (struct page *), %NULL if no mapping exists, or
+ * an error pointer if there is a mapping to something not represented
+ * by a page descriptor (see also vm_normal_page()).
+ */
+struct page *follow_page_mask(struct vm_area_struct *vma,
+			      unsigned long address, unsigned int flags,
+			      unsigned int *page_mask)
+{
+	pgd_t *pgd;
+	struct page *page;
+	struct mm_struct *mm = vma->vm_mm;
+
+	*page_mask = 0;
+
+	/* make this handle hugepd */
+	page = follow_huge_addr(mm, address, flags & FOLL_WRITE);
+	if (!IS_ERR(page)) {
+		BUG_ON(flags & FOLL_GET);
+		return page;
+	}
+
+	pgd = pgd_offset(mm, address);
+
+	if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
+		return no_page_table(vma, flags);
+
+	return follow_p4d_mask(vma, address, pgd, flags, page_mask);
+}
+
 static int get_gate_page(struct mm_struct *mm, unsigned long address,
 		unsigned int gup_flags, struct vm_area_struct **vma,
 		struct page **page)
-- 
2.7.4

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

* [RFC PATCH 3/7] mm/hugetlb: export hugetlb_entry_migration helper
  2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
  2017-04-04 14:04 ` [RFC PATCH 2/7] mm/follow_page_mask: Split follow_page_mask to smaller functions Aneesh Kumar K.V
@ 2017-04-04 14:04 ` Aneesh Kumar K.V
  2017-04-07 11:07   ` Anshuman Khandual
  2017-04-04 14:04 ` [RFC PATCH 4/7] mm/follow_page_mask: Add support for hugepage directory entry Aneesh Kumar K.V
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-04 14:04 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

We will be using this later from the ppc64 code. Change the return type to bool.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 include/linux/hugetlb.h | 1 +
 mm/hugetlb.c            | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index b857fc8cc2ec..fddf6cf403d5 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -126,6 +126,7 @@ int pud_huge(pud_t pud);
 unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
 		unsigned long address, unsigned long end, pgprot_t newprot);
 
+bool is_hugetlb_entry_migration(pte_t pte);
 #else /* !CONFIG_HUGETLB_PAGE */
 
 static inline void reset_vma_resv_huge_pages(struct vm_area_struct *vma)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 2c090189f314..34ec2ab62215 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3189,7 +3189,7 @@ static void set_huge_ptep_writable(struct vm_area_struct *vma,
 		update_mmu_cache(vma, address, ptep);
 }
 
-static int is_hugetlb_entry_migration(pte_t pte)
+bool is_hugetlb_entry_migration(pte_t pte)
 {
 	swp_entry_t swp;
 
-- 
2.7.4

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

* [RFC PATCH 4/7] mm/follow_page_mask: Add support for hugepage directory entry
  2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
  2017-04-04 14:04 ` [RFC PATCH 2/7] mm/follow_page_mask: Split follow_page_mask to smaller functions Aneesh Kumar K.V
  2017-04-04 14:04 ` [RFC PATCH 3/7] mm/hugetlb: export hugetlb_entry_migration helper Aneesh Kumar K.V
@ 2017-04-04 14:04 ` Aneesh Kumar K.V
  2017-04-07 11:37   ` Anshuman Khandual
  2017-04-04 14:04 ` [RFC PATCH 5/7] mm/follow_page_mask: Add support for hugetlb pgd entries Aneesh Kumar K.V
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-04 14:04 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

The defaul implementation prints warning and returns NULL. We will add ppc64
support in later patches

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 include/linux/hugetlb.h |  3 +++
 mm/gup.c                | 33 +++++++++++++++++++++++++++++++++
 mm/hugetlb.c            |  8 ++++++++
 3 files changed, 44 insertions(+)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index fddf6cf403d5..d3a4be0022d8 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -117,6 +117,9 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr);
 int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep);
 struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
 			      int write);
+struct page *follow_huge_pd(struct vm_area_struct *vma,
+			    unsigned long address, hugepd_t hpd,
+			    int flags, int pdshift);
 struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
 				pmd_t *pmd, int flags);
 struct page *follow_huge_pud(struct mm_struct *mm, unsigned long address,
diff --git a/mm/gup.c b/mm/gup.c
index 73d46f9f7b81..0e18fd5f65b4 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -226,6 +226,14 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma,
 			return page;
 		return no_page_table(vma, flags);
 	}
+	if (is_hugepd(__hugepd(pmd_val(*pmd)))) {
+		page = follow_huge_pd(vma, address,
+				      __hugepd(pmd_val(*pmd)), flags,
+				      PMD_SHIFT);
+		if (page)
+			return page;
+		return no_page_table(vma, flags);
+	}
 	if (pmd_devmap(*pmd)) {
 		ptl = pmd_lock(mm, pmd);
 		page = follow_devmap_pmd(vma, address, pmd, flags);
@@ -292,6 +300,14 @@ static struct page *follow_pud_mask(struct vm_area_struct *vma,
 			return page;
 		return no_page_table(vma, flags);
 	}
+	if (is_hugepd(__hugepd(pud_val(*pud)))) {
+		page = follow_huge_pd(vma, address,
+				      __hugepd(pud_val(*pud)), flags,
+				      PUD_SHIFT);
+		if (page)
+			return page;
+		return no_page_table(vma, flags);
+	}
 	if (pud_devmap(*pud)) {
 		ptl = pud_lock(mm, pud);
 		page = follow_devmap_pud(vma, address, pud, flags);
@@ -311,6 +327,7 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma,
 				    unsigned int flags, unsigned int *page_mask)
 {
 	p4d_t *p4d;
+	struct page *page;
 
 	p4d = p4d_offset(pgdp, address);
 	if (p4d_none(*p4d))
@@ -319,6 +336,14 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma,
 	if (unlikely(p4d_bad(*p4d)))
 		return no_page_table(vma, flags);
 
+	if (is_hugepd(__hugepd(p4d_val(*p4d)))) {
+		page = follow_huge_pd(vma, address,
+				      __hugepd(p4d_val(*p4d)), flags,
+				      P4D_SHIFT);
+		if (page)
+			return page;
+		return no_page_table(vma, flags);
+	}
 	return follow_pud_mask(vma, address, p4d, flags, page_mask);
 }
 
@@ -357,6 +382,14 @@ struct page *follow_page_mask(struct vm_area_struct *vma,
 	if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
 		return no_page_table(vma, flags);
 
+	if (is_hugepd(__hugepd(pgd_val(*pgd)))) {
+		page = follow_huge_pd(vma, address,
+				      __hugepd(pgd_val(*pgd)), flags,
+				      PGDIR_SHIFT);
+		if (page)
+			return page;
+		return no_page_table(vma, flags);
+	}
 	return follow_p4d_mask(vma, address, pgd, flags, page_mask);
 }
 
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 34ec2ab62215..b02faa1079bd 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4650,6 +4650,14 @@ follow_huge_addr(struct mm_struct *mm, unsigned long address,
 }
 
 struct page * __weak
+follow_huge_pd(struct vm_area_struct *vma,
+	       unsigned long address, hugepd_t hpd, int flags, int pdshift)
+{
+	WARN(1, "hugepd follow called with no support for hugepage directory format\n");
+	return NULL;
+}
+
+struct page * __weak
 follow_huge_pmd(struct mm_struct *mm, unsigned long address,
 		pmd_t *pmd, int flags)
 {
-- 
2.7.4

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

* [RFC PATCH 5/7] mm/follow_page_mask: Add support for hugetlb pgd entries.
  2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
                   ` (2 preceding siblings ...)
  2017-04-04 14:04 ` [RFC PATCH 4/7] mm/follow_page_mask: Add support for hugepage directory entry Aneesh Kumar K.V
@ 2017-04-04 14:04 ` Aneesh Kumar K.V
  2017-04-07 11:56   ` Anshuman Khandual
  2017-04-04 14:04 ` [RFC PATCH 6/7] powerpc/hugetlb: Add code to support to follow huge page directory entries Aneesh Kumar K.V
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-04 14:04 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

ppc64 supports pgd hugetlb entries. Add code to handle hugetlb pgd entries to
follow_page_mask so that ppc64 can switch to it to handle hugetlbe entries.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 include/linux/hugetlb.h | 3 +++
 mm/gup.c                | 7 +++++++
 mm/hugetlb.c            | 9 +++++++++
 3 files changed, 19 insertions(+)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index d3a4be0022d8..04b73a9c8b4b 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -124,6 +124,9 @@ struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
 				pmd_t *pmd, int flags);
 struct page *follow_huge_pud(struct mm_struct *mm, unsigned long address,
 				pud_t *pud, int flags);
+struct page *follow_huge_pgd(struct mm_struct *mm, unsigned long address,
+			     pgd_t *pgd, int flags);
+
 int pmd_huge(pmd_t pmd);
 int pud_huge(pud_t pud);
 unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
diff --git a/mm/gup.c b/mm/gup.c
index 0e18fd5f65b4..74a25e33dddb 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -382,6 +382,13 @@ struct page *follow_page_mask(struct vm_area_struct *vma,
 	if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
 		return no_page_table(vma, flags);
 
+	if (pgd_huge(*pgd)) {
+		page = follow_huge_pgd(mm, address, pgd, flags);
+		if (page)
+			return page;
+		return no_page_table(vma, flags);
+	}
+
 	if (is_hugepd(__hugepd(pgd_val(*pgd)))) {
 		page = follow_huge_pd(vma, address,
 				      __hugepd(pgd_val(*pgd)), flags,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b02faa1079bd..eb39a7496de7 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4702,6 +4702,15 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
 	return pte_page(*(pte_t *)pud) + ((address & ~PUD_MASK) >> PAGE_SHIFT);
 }
 
+struct page * __weak
+follow_huge_pgd(struct mm_struct *mm, unsigned long address, pgd_t *pgd, int flags)
+{
+	if (flags & FOLL_GET)
+		return NULL;
+
+	return pte_page(*(pte_t *)pgd) + ((address & ~PGDIR_MASK) >> PAGE_SHIFT);
+}
+
 #ifdef CONFIG_MEMORY_FAILURE
 
 /*
-- 
2.7.4

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

* [RFC PATCH 6/7] powerpc/hugetlb: Add code to support to follow huge page directory entries
  2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
                   ` (3 preceding siblings ...)
  2017-04-04 14:04 ` [RFC PATCH 5/7] mm/follow_page_mask: Add support for hugetlb pgd entries Aneesh Kumar K.V
@ 2017-04-04 14:04 ` Aneesh Kumar K.V
  2017-04-11 10:25   ` Michael Ellerman
  2017-04-04 14:04 ` [RFC PATCH 7/7] powerpc/hugetlb: Enable hugetlb migration for ppc64 Aneesh Kumar K.V
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-04 14:04 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

Add follow_huge_pd implementation for ppc64.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/mm/hugetlbpage.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 80f6d2ed551a..9d66d4f810aa 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -17,6 +17,8 @@
 #include <linux/memblock.h>
 #include <linux/bootmem.h>
 #include <linux/moduleparam.h>
+#include <linux/swap.h>
+#include <linux/swapops.h>
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/tlb.h>
@@ -618,6 +620,10 @@ void hugetlb_free_pgd_range(struct mmu_gather *tlb,
 }
 
 /*
+ * 64 bit book3s use generic follow_page_mask
+ */
+#ifndef CONFIG_PPC_BOOK3S_64
+/*
  * We are holding mmap_sem, so a parallel huge page collapse cannot run.
  * To prevent hugepage split, disable irq.
  */
@@ -673,6 +679,42 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
 	return NULL;
 }
 
+#else /* !CONFIG_PPC_BOOK3S_64 */
+
+struct page *follow_huge_pd(struct vm_area_struct *vma,
+			    unsigned long address, hugepd_t hpd,
+			    int flags, int pdshift)
+{
+	pte_t *ptep;
+	spinlock_t *ptl;
+	struct page *page = NULL;
+	unsigned long mask;
+	int shift = hugepd_shift(hpd);
+	struct mm_struct *mm = vma->vm_mm;
+
+retry:
+	ptl = &mm->page_table_lock;
+	spin_lock(ptl);
+
+	ptep = hugepte_offset(hpd, address, pdshift);
+	if (pte_present(*ptep)) {
+		mask = (1UL << shift) - 1;
+		page = pte_page(*ptep);
+		page += ((address & mask) >> PAGE_SHIFT);
+		if (flags & FOLL_GET)
+			get_page(page);
+	} else {
+		if (is_hugetlb_entry_migration(*ptep)) {
+			spin_unlock(ptl);
+			__migration_entry_wait(mm, ptep, ptl);
+			goto retry;
+		}
+	}
+	spin_unlock(ptl);
+	return page;
+}
+#endif
+
 static unsigned long hugepte_addr_end(unsigned long addr, unsigned long end,
 				      unsigned long sz)
 {
-- 
2.7.4

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

* [RFC PATCH 7/7] powerpc/hugetlb: Enable hugetlb migration for ppc64
  2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
                   ` (4 preceding siblings ...)
  2017-04-04 14:04 ` [RFC PATCH 6/7] powerpc/hugetlb: Add code to support to follow huge page directory entries Aneesh Kumar K.V
@ 2017-04-04 14:04 ` Aneesh Kumar K.V
  2017-04-07 12:26   ` Anshuman Khandual
  2017-04-04 14:07 ` [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-04 14:04 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/Kconfig.cputype | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 382c3dd86d6d..c0ca27521679 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -350,6 +350,11 @@ config PPC_RADIX_MMU
 	  is only implemented by IBM Power9 CPUs, if you don't have one of them
 	  you can probably disable this.
 
+config ARCH_ENABLE_HUGEPAGE_MIGRATION
+	def_bool y
+	depends on PPC_BOOK3S_64 && HUGETLB_PAGE && MIGRATION
+
+
 config PPC_MMU_NOHASH
 	def_bool y
 	depends on !PPC_STD_MMU
-- 
2.7.4

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

* Re: [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at
  2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
                   ` (5 preceding siblings ...)
  2017-04-04 14:04 ` [RFC PATCH 7/7] powerpc/hugetlb: Enable hugetlb migration for ppc64 Aneesh Kumar K.V
@ 2017-04-04 14:07 ` Aneesh Kumar K.V
  2017-04-05 11:51 ` Anshuman Khandual
  2017-04-07 10:59 ` Anshuman Khandual
  8 siblings, 0 replies; 18+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-04 14:07 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev


The patch series is not yet send to linux-mm. Once I get feedback on the 
approach used, I will resend this to linux-mm.

Also if there is sufficient interest we could also get nohash hugetlb 
migration to work. But I avoided doing that in this series, because of 
my inability to test the changes.

-aneesh

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

* Re: [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at
  2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
                   ` (6 preceding siblings ...)
  2017-04-04 14:07 ` [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
@ 2017-04-05 11:51 ` Anshuman Khandual
  2017-04-05 15:23   ` Aneesh Kumar K.V
  2017-04-07 10:59 ` Anshuman Khandual
  8 siblings, 1 reply; 18+ messages in thread
From: Anshuman Khandual @ 2017-04-05 11:51 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, mpe; +Cc: linuxppc-dev

On 04/04/2017 07:34 PM, Aneesh Kumar K.V wrote:
> The right interface to use to set a hugetlb pte entry is set_huge_pte_at. Use
> that instead of set_pte_at.

This is a generic change, should not mm list be added for this patch.

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

* Re: [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at
  2017-04-05 11:51 ` Anshuman Khandual
@ 2017-04-05 15:23   ` Aneesh Kumar K.V
  0 siblings, 0 replies; 18+ messages in thread
From: Aneesh Kumar K.V @ 2017-04-05 15:23 UTC (permalink / raw)
  To: Anshuman Khandual, benh, paulus, mpe; +Cc: linuxppc-dev



On Wednesday 05 April 2017 05:21 PM, Anshuman Khandual wrote:
> On 04/04/2017 07:34 PM, Aneesh Kumar K.V wrote:
>> The right interface to use to set a hugetlb pte entry is set_huge_pte_at. Use
>> that instead of set_pte_at.
>
> This is a generic change, should not mm list be added for this patch.
>


yes to all the patches. Look for my reply to patch 1 where I mentioned 
the plan for linux-mm


https://lists.ozlabs.org/pipermail/linuxppc-dev/2017-April/156225.html

-aneesh

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

* Re: [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at
  2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
                   ` (7 preceding siblings ...)
  2017-04-05 11:51 ` Anshuman Khandual
@ 2017-04-07 10:59 ` Anshuman Khandual
  8 siblings, 0 replies; 18+ messages in thread
From: Anshuman Khandual @ 2017-04-07 10:59 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, mpe; +Cc: linuxppc-dev

On 04/04/2017 07:34 PM, Aneesh Kumar K.V wrote:
> The right interface to use to set a hugetlb pte entry is set_huge_pte_at. Use
> that instead of set_pte_at.
>

Though set_huge_pte_at() calls set_pte_at() on powerpc,
changing this in the generic code makes sense.

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

* Re: [RFC PATCH 2/7] mm/follow_page_mask: Split follow_page_mask to smaller functions.
  2017-04-04 14:04 ` [RFC PATCH 2/7] mm/follow_page_mask: Split follow_page_mask to smaller functions Aneesh Kumar K.V
@ 2017-04-07 11:04   ` Anshuman Khandual
  0 siblings, 0 replies; 18+ messages in thread
From: Anshuman Khandual @ 2017-04-07 11:04 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, mpe; +Cc: linuxppc-dev

On 04/04/2017 07:34 PM, Aneesh Kumar K.V wrote:
> Makes code reading easy. No functional changes in this patch.

The description should mention how the follow function is
broken down to PGD follow, PUD follow and PMD follow on
4 level page table system. Needs to be bit verbose.

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

* Re: [RFC PATCH 3/7] mm/hugetlb: export hugetlb_entry_migration helper
  2017-04-04 14:04 ` [RFC PATCH 3/7] mm/hugetlb: export hugetlb_entry_migration helper Aneesh Kumar K.V
@ 2017-04-07 11:07   ` Anshuman Khandual
  0 siblings, 0 replies; 18+ messages in thread
From: Anshuman Khandual @ 2017-04-07 11:07 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, mpe; +Cc: linuxppc-dev

On 04/04/2017 07:34 PM, Aneesh Kumar K.V wrote:
> We will be using this later from the ppc64 code. Change the return type to bool.

How all other arch were able to detect the hugetlb migration
entries without using this helper function before ?

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

* Re: [RFC PATCH 4/7] mm/follow_page_mask: Add support for hugepage directory entry
  2017-04-04 14:04 ` [RFC PATCH 4/7] mm/follow_page_mask: Add support for hugepage directory entry Aneesh Kumar K.V
@ 2017-04-07 11:37   ` Anshuman Khandual
  0 siblings, 0 replies; 18+ messages in thread
From: Anshuman Khandual @ 2017-04-07 11:37 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, mpe; +Cc: linuxppc-dev

On 04/04/2017 07:34 PM, Aneesh Kumar K.V wrote:
> The defaul implementation prints warning and returns NULL. We will add ppc64
> support in later patches.

The description is not sufficient. The patch makes the entire follow
page mask function aware of hugepd based implementation at PGD, PUD
and PMD level. It also provides default follow_huge_pd() function
which in absence of architecture support prints warning and returns
NULL. The commit description should contain all these details. 

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

* Re: [RFC PATCH 5/7] mm/follow_page_mask: Add support for hugetlb pgd entries.
  2017-04-04 14:04 ` [RFC PATCH 5/7] mm/follow_page_mask: Add support for hugetlb pgd entries Aneesh Kumar K.V
@ 2017-04-07 11:56   ` Anshuman Khandual
  0 siblings, 0 replies; 18+ messages in thread
From: Anshuman Khandual @ 2017-04-07 11:56 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, mpe; +Cc: linuxppc-dev

On 04/04/2017 07:34 PM, Aneesh Kumar K.V wrote:
> ppc64 supports pgd hugetlb entries. Add code to handle hugetlb pgd entries to
> follow_page_mask so that ppc64 can switch to it to handle hugetlbe entries.
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

This was exactly proposed by two of the patches I had posted
last year with bit more descriptive commit message. Making
follow page mask function aware of PGD based HugeTLB can be
sent separately to core MM. I will send it out to mm list soon
for fresh consideration which will make the series one patch
less.

https://patchwork.ozlabs.org/patch/595033/
https://patchwork.ozlabs.org/patch/595037/

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

* Re: [RFC PATCH 7/7] powerpc/hugetlb: Enable hugetlb migration for ppc64
  2017-04-04 14:04 ` [RFC PATCH 7/7] powerpc/hugetlb: Enable hugetlb migration for ppc64 Aneesh Kumar K.V
@ 2017-04-07 12:26   ` Anshuman Khandual
  0 siblings, 0 replies; 18+ messages in thread
From: Anshuman Khandual @ 2017-04-07 12:26 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus, mpe; +Cc: linuxppc-dev

On 04/04/2017 07:34 PM, Aneesh Kumar K.V wrote:
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
>  arch/powerpc/platforms/Kconfig.cputype | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
> index 382c3dd86d6d..c0ca27521679 100644
> --- a/arch/powerpc/platforms/Kconfig.cputype
> +++ b/arch/powerpc/platforms/Kconfig.cputype
> @@ -350,6 +350,11 @@ config PPC_RADIX_MMU
>  	  is only implemented by IBM Power9 CPUs, if you don't have one of them
>  	  you can probably disable this.
> 
> +config ARCH_ENABLE_HUGEPAGE_MIGRATION
> +	def_bool y
> +	depends on PPC_BOOK3S_64 && HUGETLB_PAGE && MIGRATION
> +

I have tested this patch series both for anon and file mapping
on a POWER8 box with 16MB pages. Will try to test it for 16GB
pages on a PVM system.

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

* Re: [RFC PATCH 6/7] powerpc/hugetlb: Add code to support to follow huge page directory entries
  2017-04-04 14:04 ` [RFC PATCH 6/7] powerpc/hugetlb: Add code to support to follow huge page directory entries Aneesh Kumar K.V
@ 2017-04-11 10:25   ` Michael Ellerman
  2017-04-12  4:48     ` Anshuman Khandual
  0 siblings, 1 reply; 18+ messages in thread
From: Michael Ellerman @ 2017-04-11 10:25 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus; +Cc: linuxppc-dev, Aneesh Kumar K.V

"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:

> Add follow_huge_pd implementation for ppc64.
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
>  arch/powerpc/mm/hugetlbpage.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
>
> diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
> index 80f6d2ed551a..9d66d4f810aa 100644
> --- a/arch/powerpc/mm/hugetlbpage.c
> +++ b/arch/powerpc/mm/hugetlbpage.c
> @@ -17,6 +17,8 @@
>  #include <linux/memblock.h>
>  #include <linux/bootmem.h>
>  #include <linux/moduleparam.h>
> +#include <linux/swap.h>
> +#include <linux/swapops.h>
>  #include <asm/pgtable.h>
>  #include <asm/pgalloc.h>
>  #include <asm/tlb.h>
> @@ -618,6 +620,10 @@ void hugetlb_free_pgd_range(struct mmu_gather *tlb,
>  }
>  
>  /*
> + * 64 bit book3s use generic follow_page_mask
> + */
> +#ifndef CONFIG_PPC_BOOK3S_64

I think it's always easier to follow if you use:

  #ifdef x
  ...
  #else /* !x */
  ...
  #endif

ie. in this case put the Book3S 64 case first and the existing code in the
#else.

cheers

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

* Re: [RFC PATCH 6/7] powerpc/hugetlb: Add code to support to follow huge page directory entries
  2017-04-11 10:25   ` Michael Ellerman
@ 2017-04-12  4:48     ` Anshuman Khandual
  0 siblings, 0 replies; 18+ messages in thread
From: Anshuman Khandual @ 2017-04-12  4:48 UTC (permalink / raw)
  To: Michael Ellerman, Aneesh Kumar K.V, benh, paulus; +Cc: linuxppc-dev

On 04/11/2017 03:55 PM, Michael Ellerman wrote:
> "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:
> 
>> Add follow_huge_pd implementation for ppc64.
>>
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>> ---
>>  arch/powerpc/mm/hugetlbpage.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 42 insertions(+)
>>
>> diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
>> index 80f6d2ed551a..9d66d4f810aa 100644
>> --- a/arch/powerpc/mm/hugetlbpage.c
>> +++ b/arch/powerpc/mm/hugetlbpage.c
>> @@ -17,6 +17,8 @@
>>  #include <linux/memblock.h>
>>  #include <linux/bootmem.h>
>>  #include <linux/moduleparam.h>
>> +#include <linux/swap.h>
>> +#include <linux/swapops.h>
>>  #include <asm/pgtable.h>
>>  #include <asm/pgalloc.h>
>>  #include <asm/tlb.h>
>> @@ -618,6 +620,10 @@ void hugetlb_free_pgd_range(struct mmu_gather *tlb,
>>  }
>>  
>>  /*
>> + * 64 bit book3s use generic follow_page_mask
>> + */
>> +#ifndef CONFIG_PPC_BOOK3S_64
> I think it's always easier to follow if you use:
> 
>   #ifdef x
>   ...
>   #else /* !x */
>   ...
>   #endif
> 
> ie. in this case put the Book3S 64 case first and the existing code in the
> #else.

Yeah, it was difficult to read in the first glance.

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

end of thread, other threads:[~2017-04-12  4:48 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04 14:04 [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
2017-04-04 14:04 ` [RFC PATCH 2/7] mm/follow_page_mask: Split follow_page_mask to smaller functions Aneesh Kumar K.V
2017-04-07 11:04   ` Anshuman Khandual
2017-04-04 14:04 ` [RFC PATCH 3/7] mm/hugetlb: export hugetlb_entry_migration helper Aneesh Kumar K.V
2017-04-07 11:07   ` Anshuman Khandual
2017-04-04 14:04 ` [RFC PATCH 4/7] mm/follow_page_mask: Add support for hugepage directory entry Aneesh Kumar K.V
2017-04-07 11:37   ` Anshuman Khandual
2017-04-04 14:04 ` [RFC PATCH 5/7] mm/follow_page_mask: Add support for hugetlb pgd entries Aneesh Kumar K.V
2017-04-07 11:56   ` Anshuman Khandual
2017-04-04 14:04 ` [RFC PATCH 6/7] powerpc/hugetlb: Add code to support to follow huge page directory entries Aneesh Kumar K.V
2017-04-11 10:25   ` Michael Ellerman
2017-04-12  4:48     ` Anshuman Khandual
2017-04-04 14:04 ` [RFC PATCH 7/7] powerpc/hugetlb: Enable hugetlb migration for ppc64 Aneesh Kumar K.V
2017-04-07 12:26   ` Anshuman Khandual
2017-04-04 14:07 ` [RFC PATCH 1/7] mm/hugetlb/migration: Use set_huge_pte_at instead of set_pte_at Aneesh Kumar K.V
2017-04-05 11:51 ` Anshuman Khandual
2017-04-05 15:23   ` Aneesh Kumar K.V
2017-04-07 10:59 ` Anshuman Khandual

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.