Enable ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP & fixup race condition on PG_dcache_clean
Subsystems (3)
cover Enable ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP & fixup race condition on PG_dcache_clean
From: Guo Ren <[email protected]>
The first patch fixup race condition on PG_dcache_clean which found in arm64. Then enable ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP and tested with simple hugetlbfs test case.
# cat /proc/sys/vm/hugetlb_optimize_vmemmap 1 # echo 8 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages # mount -t hugetlbfs none test/ -o pagesize=2048k # ./myhugemap_test # umount test/ # echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
No problem found.
Guo Ren (2):
riscv: Fixup race condition on PG_dcache_clean in flush_icache_pte
riscv: Enable ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
arch/riscv/Kconfig | 1 + arch/riscv/include/asm/cacheflush.h | 3 +++ arch/riscv/mm/cacheflush.c | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
2.36.1
PATCH 1/2 riscv: Fixup race condition on PG_dcache_clean in flush_icache_pte
From: Guo Ren <[email protected]>
RISC-V follows the arm64 flush_icache_pte mechanism and also includes its bug. The patch ensures that instructions are observable in a new mapping. For more details, see 588a513d3425 ("arm64: Fix race condition on PG_dcache_clean in __sync_icache_dcache()").
--- arch/riscv/mm/cacheflush.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/mm/cacheflush.c +3 -1
@@ -82,7 +82,9 @@ void flush_icache_pte(pte_t pte) {struct page *page =pte_page (pte); -if (!test_and_set_bit (PG_dcache_clean, &page->flags)) +if (!test_bit (PG_dcache_clean, &page->flags)) {flush_icache_all (); +set_bit (PG_dcache_clean, &page->flags); + } }#endif /* CONFIG_MMU */
Signature · 1 line
2.36.1
PATCH 2/2 riscv: Enable ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
In reply to [email protected]From: Guo Ren <[email protected]>
This patch enable the feature of "free some vmemmap pages of HugeTLB page" [1]. To make it work correct, we also need fixup PG_dcache_clean setting for huge page [2].
[1] https://lore.kernel.org/linux-doc/[email protected]/
[2] https://lore.kernel.org/linux-mm/[email protected]/
--- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/cacheflush.h | 3 +++ arch/riscv/mm/cacheflush.c | 3 +++ 3 files changed, 7 insertions(+)
arch/riscv/Kconfig +1 -0
@@ -45,6 +45,7 @@ config RISCV select ARCH_WANT_FRAME_POINTERS select ARCH_WANT_GENERAL_HUGETLB select ARCH_WANT_HUGE_PMD_SHARE if 64BIT + select ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU select BUILDTIME_TABLE_SORT if MMU
arch/riscv/include/asm/cacheflush.h +3 -0
@@ -17,6 +17,9 @@ static inline void local_flush_icache_all(void)static inline void flush_dcache_page (struct page *page) { +if (PageHuge (page)) + page =compound_head (page); +if (test_bit (PG_dcache_clean, &page->flags))clear_bit (PG_dcache_clean, &page->flags); }
arch/riscv/mm/cacheflush.c +3 -0
@@ -82,6 +82,9 @@ void flush_icache_pte(pte_t pte) {struct page *page =pte_page (pte); +if (PageHuge (page)) + page =compound_head (page); +if (!test_bit (PG_dcache_clean, &page->flags)) {flush_icache_all ();set_bit (PG_dcache_clean, &page->flags);
Signature · 1 line
2.36.1
Re: [PATCH 2/2] riscv: Enable ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
Quoted 7 lines · On Oct 23, 2022, at 21:32, [email protected] wrote:
From: Guo Ren <[email protected]>
This patch enable the feature of "free some vmemmap pages of HugeTLB
We have a new name “HVO" to refer to this feature. So I’d like to rewrite The changelog to something like “Enable HVO [1] for RISCV”.
Quoted 11 lines
page" [1]. To make it work correct, we also need fixup
PG_dcache_cleansetting for huge page [2].[1] https://lore.kernel.org/linux-doc/[email protected]/
[2] https://lore.kernel.org/linux-mm/[email protected]/Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>Cc Muchun Song <[email protected]>Cc Huacai Chen <[email protected]>Cc Arnd Bergmann <[email protected]>
I’am really glad to see more and more arches for support HVO.
Thanks.
Re: [PATCH 2/2] riscv: Enable ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
Quoted 11 lines · Muchun Song
Quoted 8 lines · On Oct 23, 2022, at 21:32, [email protected] wrote:
From: Guo Ren <[email protected]>
This patch enable the feature of "free some vmemmap pages of HugeTLB
We have a new name “HVO" to refer to this feature. So I’d like to rewrite The changelog to something like “Enable HVO [1] for RISCV”.
Okay.
Quoted 13 lines
Quoted 4 lines
page" [1]. To make it work correct, we also need fixup
PG_dcache_cleansetting for huge page [2].Quoted 8 lines
[1] https://lore.kernel.org/linux-doc/[email protected]/
[2] https://lore.kernel.org/linux-mm/[email protected]/Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>Cc Muchun Song <[email protected]>Cc Huacai Chen <[email protected]>Cc Arnd Bergmann <[email protected]>
Quoted 3 lines
I’am really glad to see more and more arches for support HVO.
Acked-by Muchun Song <[email protected]>
Thx
Quoted 3 lines
Thanks.
Signature · 2 lines
Best Regards Guo Ren