linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/2]riscv/mm: two modifications on hugepage
@ 2022-10-24  9:47 Tong Tiangen
  2022-10-24  9:47 ` [PATCH -next 1/2] riscv/mm: hugepage's PG_dcache_clean flag is only set in head page Tong Tiangen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tong Tiangen @ 2022-10-24  9:47 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou
  Cc: linux-riscv, linux-kernel, Tong Tiangen, wangkefeng.wang, Guohanjun

Tong Tiangen (2):
  riscv/mm: hugepage's PG_dcache_clean flag is only set in head page
  riscv/mm: add arch hook arch_clear_hugepage_flags

 arch/riscv/include/asm/cacheflush.h | 7 +++++++
 arch/riscv/include/asm/hugetlb.h    | 6 ++++++
 arch/riscv/mm/cacheflush.c          | 7 +++++++
 3 files changed, 20 insertions(+)

-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH -next 1/2] riscv/mm: hugepage's PG_dcache_clean flag is only set in head page
  2022-10-24  9:47 [PATCH -next 0/2]riscv/mm: two modifications on hugepage Tong Tiangen
@ 2022-10-24  9:47 ` Tong Tiangen
  2022-10-24  9:47 ` [PATCH -next 2/2] riscv/mm: add arch hook arch_clear_hugepage_flags Tong Tiangen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tong Tiangen @ 2022-10-24  9:47 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou
  Cc: linux-riscv, linux-kernel, Tong Tiangen, wangkefeng.wang, Guohanjun

HugeTLB pages are always fully mapped, so only setting head page's
PG_dcache_clean flag is enough.

This refers to the following link:
https://lore.kernel.org/lkml/20220331065640.5777-2-songmuchun@bytedance.com/

Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
---
 arch/riscv/include/asm/cacheflush.h | 7 +++++++
 arch/riscv/mm/cacheflush.c          | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/arch/riscv/include/asm/cacheflush.h b/arch/riscv/include/asm/cacheflush.h
index 8a5c246b0a21..c172d05de474 100644
--- a/arch/riscv/include/asm/cacheflush.h
+++ b/arch/riscv/include/asm/cacheflush.h
@@ -17,6 +17,13 @@ static inline void local_flush_icache_all(void)
 
 static inline void flush_dcache_page(struct page *page)
 {
+	/*
+	 * HugeTLB pages are always fully mapped and only head page will be
+	 * set PG_dcache_clean (see comments in flush_icache_pte()).
+	 */
+	if (PageHuge(page))
+		page = compound_head(page);
+
 	if (test_bit(PG_dcache_clean, &page->flags))
 		clear_bit(PG_dcache_clean, &page->flags);
 }
diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c
index 6cb7d96ad9c7..062559c04fc3 100644
--- a/arch/riscv/mm/cacheflush.c
+++ b/arch/riscv/mm/cacheflush.c
@@ -82,6 +82,13 @@ void flush_icache_pte(pte_t pte)
 {
 	struct page *page = pte_page(pte);
 
+	/*
+	 * HugeTLB pages are always fully mapped, so only setting head page's
+	 * PG_dcache_clean flag is enough.
+	 */
+	if (PageHuge(page))
+		page = compound_head(page);
+
 	if (!test_and_set_bit(PG_dcache_clean, &page->flags))
 		flush_icache_all();
 }
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH -next 2/2] riscv/mm: add arch hook arch_clear_hugepage_flags
  2022-10-24  9:47 [PATCH -next 0/2]riscv/mm: two modifications on hugepage Tong Tiangen
  2022-10-24  9:47 ` [PATCH -next 1/2] riscv/mm: hugepage's PG_dcache_clean flag is only set in head page Tong Tiangen
@ 2022-10-24  9:47 ` Tong Tiangen
  2022-12-02 21:03 ` [PATCH -next 0/2]riscv/mm: two modifications on hugepage Palmer Dabbelt
  2022-12-02 21:25 ` patchwork-bot+linux-riscv
  3 siblings, 0 replies; 5+ messages in thread
From: Tong Tiangen @ 2022-10-24  9:47 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou
  Cc: linux-riscv, linux-kernel, Tong Tiangen, wangkefeng.wang, Guohanjun

With the PG_arch_1 we keep track if the page's data cache is clean,
architecture rely on this property to treat new pages as dirty with
respect to the data cache and perform the flushing before mapping the pages
into userspace.

This patch adds a new architecture hook, arch_clear_hugepage_flags,so that
architectures which rely on the page flags being in a particular state for
fresh allocations can adjust the flags accordingly when a page is freed
into the pool.

Fixes: 9e953cda5cdf ("riscv: Introduce huge page support for 32/64bit kernel")
Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
---
 arch/riscv/include/asm/hugetlb.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/riscv/include/asm/hugetlb.h b/arch/riscv/include/asm/hugetlb.h
index a5c2ca1d1cd8..ec19d6afc896 100644
--- a/arch/riscv/include/asm/hugetlb.h
+++ b/arch/riscv/include/asm/hugetlb.h
@@ -5,4 +5,10 @@
 #include <asm-generic/hugetlb.h>
 #include <asm/page.h>
 
+static inline void arch_clear_hugepage_flags(struct page *page)
+{
+	clear_bit(PG_dcache_clean, &page->flags);
+}
+#define arch_clear_hugepage_flags arch_clear_hugepage_flags
+
 #endif /* _ASM_RISCV_HUGETLB_H */
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next 0/2]riscv/mm: two modifications on hugepage
  2022-10-24  9:47 [PATCH -next 0/2]riscv/mm: two modifications on hugepage Tong Tiangen
  2022-10-24  9:47 ` [PATCH -next 1/2] riscv/mm: hugepage's PG_dcache_clean flag is only set in head page Tong Tiangen
  2022-10-24  9:47 ` [PATCH -next 2/2] riscv/mm: add arch hook arch_clear_hugepage_flags Tong Tiangen
@ 2022-12-02 21:03 ` Palmer Dabbelt
  2022-12-02 21:25 ` patchwork-bot+linux-riscv
  3 siblings, 0 replies; 5+ messages in thread
From: Palmer Dabbelt @ 2022-12-02 21:03 UTC (permalink / raw)
  To: Paul Walmsley, Tong Tiangen, Palmer Dabbelt, Albert Ou
  Cc: linux-kernel, linux-riscv, wangkefeng.wang, Guohanjun

On Mon, 24 Oct 2022 09:47:23 +0000, Tong Tiangen wrote:
> Tong Tiangen (2):
>   riscv/mm: hugepage's PG_dcache_clean flag is only set in head page
>   riscv/mm: add arch hook arch_clear_hugepage_flags
> 
> arch/riscv/include/asm/cacheflush.h | 7 +++++++
>  arch/riscv/include/asm/hugetlb.h    | 6 ++++++
>  arch/riscv/mm/cacheflush.c          | 7 +++++++
>  3 files changed, 20 insertions(+)
> 
> [...]

Applied, thanks!

[1/2] riscv/mm: hugepage's PG_dcache_clean flag is only set in head page
      https://git.kernel.org/palmer/c/d33deda095d3
[2/2] riscv/mm: add arch hook arch_clear_hugepage_flags
      https://git.kernel.org/palmer/c/d8bf77a1dc30

Best regards,
-- 
Palmer Dabbelt <palmer@rivosinc.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next 0/2]riscv/mm: two modifications on hugepage
  2022-10-24  9:47 [PATCH -next 0/2]riscv/mm: two modifications on hugepage Tong Tiangen
                   ` (2 preceding siblings ...)
  2022-12-02 21:03 ` [PATCH -next 0/2]riscv/mm: two modifications on hugepage Palmer Dabbelt
@ 2022-12-02 21:25 ` patchwork-bot+linux-riscv
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-riscv @ 2022-12-02 21:25 UTC (permalink / raw)
  To: Tong Tiangen
  Cc: linux-riscv, paul.walmsley, palmer, aou, linux-kernel,
	wangkefeng.wang, guohanjun

Hello:

This series was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Mon, 24 Oct 2022 09:47:23 +0000 you wrote:
> Tong Tiangen (2):
>   riscv/mm: hugepage's PG_dcache_clean flag is only set in head page
>   riscv/mm: add arch hook arch_clear_hugepage_flags
> 
>  arch/riscv/include/asm/cacheflush.h | 7 +++++++
>  arch/riscv/include/asm/hugetlb.h    | 6 ++++++
>  arch/riscv/mm/cacheflush.c          | 7 +++++++
>  3 files changed, 20 insertions(+)

Here is the summary with links:
  - [-next,1/2] riscv/mm: hugepage's PG_dcache_clean flag is only set in head page
    https://git.kernel.org/riscv/c/d33deda095d3
  - [-next,2/2] riscv/mm: add arch hook arch_clear_hugepage_flags
    https://git.kernel.org/riscv/c/d8bf77a1dc30

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-02 21:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24  9:47 [PATCH -next 0/2]riscv/mm: two modifications on hugepage Tong Tiangen
2022-10-24  9:47 ` [PATCH -next 1/2] riscv/mm: hugepage's PG_dcache_clean flag is only set in head page Tong Tiangen
2022-10-24  9:47 ` [PATCH -next 2/2] riscv/mm: add arch hook arch_clear_hugepage_flags Tong Tiangen
2022-12-02 21:03 ` [PATCH -next 0/2]riscv/mm: two modifications on hugepage Palmer Dabbelt
2022-12-02 21:25 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).