Skip to content

Commit 67d59bd

Browse files
Baolin Wangakpm00
authored andcommitted
arm64: mm: factor out the address and ptep alignment into a new helper
Factor out the contpte block's address and ptep alignment into a new helper, and will be reused in the following patch. No functional changes. Link: https://lkml.kernel.org/r/8076d12cb244b2d9e91119b44dc6d5e4ad9c00af.1770645603.git.baolin.wang@linux.alibaba.com Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> Reviewed-by: David Hildenbrand (Arm) <david@kernel.org> Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> Cc: Barry Song <baohua@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Harry Yoo <harry.yoo@oracle.com> Cc: Jann Horn <jannh@google.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Rik van Riel <riel@surriel.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 52e054f commit 67d59bd

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

arch/arm64/mm/contpte.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,26 @@ static inline pte_t *contpte_align_down(pte_t *ptep)
2626
return PTR_ALIGN_DOWN(ptep, sizeof(*ptep) * CONT_PTES);
2727
}
2828

29+
static inline pte_t *contpte_align_addr_ptep(unsigned long *start,
30+
unsigned long *end, pte_t *ptep,
31+
unsigned int nr)
32+
{
33+
/*
34+
* Note: caller must ensure these nr PTEs are consecutive (present)
35+
* PTEs that map consecutive pages of the same large folio within a
36+
* single VMA and a single page table.
37+
*/
38+
if (pte_cont(__ptep_get(ptep + nr - 1)))
39+
*end = ALIGN(*end, CONT_PTE_SIZE);
40+
41+
if (pte_cont(__ptep_get(ptep))) {
42+
*start = ALIGN_DOWN(*start, CONT_PTE_SIZE);
43+
ptep = contpte_align_down(ptep);
44+
}
45+
46+
return ptep;
47+
}
48+
2949
static void contpte_try_unfold_partial(struct mm_struct *mm, unsigned long addr,
3050
pte_t *ptep, unsigned int nr)
3151
{
@@ -569,14 +589,7 @@ void contpte_clear_young_dirty_ptes(struct vm_area_struct *vma,
569589
unsigned long start = addr;
570590
unsigned long end = start + nr * PAGE_SIZE;
571591

572-
if (pte_cont(__ptep_get(ptep + nr - 1)))
573-
end = ALIGN(end, CONT_PTE_SIZE);
574-
575-
if (pte_cont(__ptep_get(ptep))) {
576-
start = ALIGN_DOWN(start, CONT_PTE_SIZE);
577-
ptep = contpte_align_down(ptep);
578-
}
579-
592+
ptep = contpte_align_addr_ptep(&start, &end, ptep, nr);
580593
__clear_young_dirty_ptes(vma, start, ptep, (end - start) / PAGE_SIZE, flags);
581594
}
582595
EXPORT_SYMBOL_GPL(contpte_clear_young_dirty_ptes);

0 commit comments

Comments
 (0)