-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv: Introduce huge page support for 32/64bit kernel
This patch implements both 4MB huge page support for 32bit kernel and 2MB/1GB huge pages support for 64bit kernel. Signed-off-by: Alexandre Ghiti <alex@ghiti.fr> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
- Loading branch information
Alexandre Ghiti
authored and
Paul Walmsley
committed
Jul 3, 2019
1 parent
3876d4a
commit 9e953cd
Showing
6 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _ASM_RISCV_HUGETLB_H | ||
#define _ASM_RISCV_HUGETLB_H | ||
|
||
#include <asm-generic/hugetlb.h> | ||
#include <asm/page.h> | ||
|
||
static inline int is_hugepage_only_range(struct mm_struct *mm, | ||
unsigned long addr, | ||
unsigned long len) { | ||
return 0; | ||
} | ||
|
||
static inline void arch_clear_hugepage_flags(struct page *page) | ||
{ | ||
} | ||
|
||
#endif /* _ASM_RISCV_HUGETLB_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
#include <linux/hugetlb.h> | ||
#include <linux/err.h> | ||
|
||
int pud_huge(pud_t pud) | ||
{ | ||
return pud_present(pud) && | ||
(pud_val(pud) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)); | ||
} | ||
|
||
int pmd_huge(pmd_t pmd) | ||
{ | ||
return pmd_present(pmd) && | ||
(pmd_val(pmd) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)); | ||
} | ||
|
||
static __init int setup_hugepagesz(char *opt) | ||
{ | ||
unsigned long ps = memparse(opt, &opt); | ||
|
||
if (ps == HPAGE_SIZE) { | ||
hugetlb_add_hstate(HPAGE_SHIFT - PAGE_SHIFT); | ||
} else if (IS_ENABLED(CONFIG_64BIT) && ps == PUD_SIZE) { | ||
hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); | ||
} else { | ||
hugetlb_bad_size(); | ||
pr_err("hugepagesz: Unsupported page size %lu M\n", ps >> 20); | ||
return 0; | ||
} | ||
|
||
return 1; | ||
} | ||
__setup("hugepagesz=", setup_hugepagesz); | ||
|
||
#ifdef CONFIG_CONTIG_ALLOC | ||
static __init int gigantic_pages_init(void) | ||
{ | ||
/* With CONTIG_ALLOC, we can allocate gigantic pages at runtime */ | ||
if (IS_ENABLED(CONFIG_64BIT) && !size_to_hstate(1UL << PUD_SHIFT)) | ||
hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); | ||
return 0; | ||
} | ||
arch_initcall(gigantic_pages_init); | ||
#endif |