Skip to content

Commit ce68c03

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Fix arch_hugetlb_migration_supported() for NAPOT
arch_hugetlb_migration_supported() must be reimplemented to add support for NAPOT hugepages, which is done here. Fixes: 82a1a1f ("riscv: mm: support Svnapot in hugetlb page") Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/r/20240130120114.106003-1-alexghiti@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 97cf301 commit ce68c03

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

arch/riscv/include/asm/hugetlb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ static inline void arch_clear_hugepage_flags(struct page *page)
1111
}
1212
#define arch_clear_hugepage_flags arch_clear_hugepage_flags
1313

14+
bool arch_hugetlb_migration_supported(struct hstate *h);
15+
#define arch_hugetlb_migration_supported arch_hugetlb_migration_supported
16+
1417
#ifdef CONFIG_RISCV_ISA_SVNAPOT
1518
#define __HAVE_ARCH_HUGE_PTE_CLEAR
1619
void huge_pte_clear(struct mm_struct *mm, unsigned long addr,

arch/riscv/mm/hugetlbpage.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ void huge_pte_clear(struct mm_struct *mm,
364364
pte_clear(mm, addr, ptep);
365365
}
366366

367-
static __init bool is_napot_size(unsigned long size)
367+
static bool is_napot_size(unsigned long size)
368368
{
369369
unsigned long order;
370370

@@ -392,7 +392,7 @@ arch_initcall(napot_hugetlbpages_init);
392392

393393
#else
394394

395-
static __init bool is_napot_size(unsigned long size)
395+
static bool is_napot_size(unsigned long size)
396396
{
397397
return false;
398398
}
@@ -409,7 +409,7 @@ int pmd_huge(pmd_t pmd)
409409
return pmd_leaf(pmd);
410410
}
411411

412-
bool __init arch_hugetlb_valid_size(unsigned long size)
412+
static bool __hugetlb_valid_size(unsigned long size)
413413
{
414414
if (size == HPAGE_SIZE)
415415
return true;
@@ -421,6 +421,16 @@ bool __init arch_hugetlb_valid_size(unsigned long size)
421421
return false;
422422
}
423423

424+
bool __init arch_hugetlb_valid_size(unsigned long size)
425+
{
426+
return __hugetlb_valid_size(size);
427+
}
428+
429+
bool arch_hugetlb_migration_supported(struct hstate *h)
430+
{
431+
return __hugetlb_valid_size(huge_page_size(h));
432+
}
433+
424434
#ifdef CONFIG_CONTIG_ALLOC
425435
static __init int gigantic_pages_init(void)
426436
{

0 commit comments

Comments
 (0)