aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPunit Agrawal <punit.agrawal@arm.com>2017-08-22 06:42:46 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2017-08-22 12:47:10 -0400
commitc3e4ed5c3d5d79af940eb24c810dddcec6d2b536 (patch)
tree7fe96053cdf9e6bc952930b6162f413e9bba7cfa
parent30f3ac00ad2f822937839c95cbb22ce483190c4c (diff)
arm64: hugetlb: Override huge_pte_clear() to support contiguous hugepages
The default huge_pte_clear() implementation does not clear contiguous page table entries when it encounters contiguous hugepages that are supported on arm64. Fix this by overriding the default implementation to clear all the entries associated with contiguous hugepages. Signed-off-by: Punit Agrawal <punit.agrawal@arm.com> Cc: David Woods <dwoods@mellanox.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--arch/arm64/include/asm/hugetlb.h6
-rw-r--r--arch/arm64/mm/hugetlbpage.c38
2 files changed, 43 insertions, 1 deletions
diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h
index 793bd73b0d07..df8c0aea0917 100644
--- a/arch/arm64/include/asm/hugetlb.h
+++ b/arch/arm64/include/asm/hugetlb.h
@@ -18,7 +18,6 @@
18#ifndef __ASM_HUGETLB_H 18#ifndef __ASM_HUGETLB_H
19#define __ASM_HUGETLB_H 19#define __ASM_HUGETLB_H
20 20
21#include <asm-generic/hugetlb.h>
22#include <asm/page.h> 21#include <asm/page.h>
23 22
24static inline pte_t huge_ptep_get(pte_t *ptep) 23static inline pte_t huge_ptep_get(pte_t *ptep)
@@ -82,6 +81,11 @@ extern void huge_ptep_set_wrprotect(struct mm_struct *mm,
82 unsigned long addr, pte_t *ptep); 81 unsigned long addr, pte_t *ptep);
83extern void huge_ptep_clear_flush(struct vm_area_struct *vma, 82extern void huge_ptep_clear_flush(struct vm_area_struct *vma,
84 unsigned long addr, pte_t *ptep); 83 unsigned long addr, pte_t *ptep);
84extern void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
85 pte_t *ptep, unsigned long sz);
86#define huge_pte_clear huge_pte_clear
87
88#include <asm-generic/hugetlb.h>
85 89
86#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE 90#ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE
87static inline bool gigantic_page_supported(void) { return true; } 91static inline bool gigantic_page_supported(void) { return true; }
diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index b91ec151e62c..035c121c675b 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -68,6 +68,32 @@ static int find_num_contig(struct mm_struct *mm, unsigned long addr,
68 return CONT_PTES; 68 return CONT_PTES;
69} 69}
70 70
71static inline int num_contig_ptes(unsigned long size, size_t *pgsize)
72{
73 int contig_ptes = 0;
74
75 *pgsize = size;
76
77 switch (size) {
78#ifdef CONFIG_ARM64_4K_PAGES
79 case PUD_SIZE:
80#endif
81 case PMD_SIZE:
82 contig_ptes = 1;
83 break;
84 case CONT_PMD_SIZE:
85 *pgsize = PMD_SIZE;
86 contig_ptes = CONT_PMDS;
87 break;
88 case CONT_PTE_SIZE:
89 *pgsize = PAGE_SIZE;
90 contig_ptes = CONT_PTES;
91 break;
92 }
93
94 return contig_ptes;
95}
96
71/* 97/*
72 * Changing some bits of contiguous entries requires us to follow a 98 * Changing some bits of contiguous entries requires us to follow a
73 * Break-Before-Make approach, breaking the whole contiguous set 99 * Break-Before-Make approach, breaking the whole contiguous set
@@ -262,6 +288,18 @@ pte_t arch_make_huge_pte(pte_t entry, struct vm_area_struct *vma,
262 return entry; 288 return entry;
263} 289}
264 290
291void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
292 pte_t *ptep, unsigned long sz)
293{
294 int i, ncontig;
295 size_t pgsize;
296
297 ncontig = num_contig_ptes(sz, &pgsize);
298
299 for (i = 0; i < ncontig; i++, addr += pgsize, ptep++)
300 pte_clear(mm, addr, ptep);
301}
302
265pte_t huge_ptep_get_and_clear(struct mm_struct *mm, 303pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
266 unsigned long addr, pte_t *ptep) 304 unsigned long addr, pte_t *ptep)
267{ 305{