* Re: [PATCH v2 RESEND 1/2] arm64: avoid flushing icache multiple times on contiguous HugeTLB
@ 2022-03-03 11:20 Muchun Song
0 siblings, 0 replies; 4+ messages in thread
From: Muchun Song @ 2022-03-03 11:20 UTC (permalink / raw)
To: Catalin Marinas
Cc: Will Deacon, Andrew Morton, David Hildenbrand, Bodeddula,
Balasubramaniam, Oscar Salvador, Mike Kravetz, David Rientjes,
Mark Rutland, james.morse, Song Bao Hua (Barry Song),
linux-arm-kernel, LKML, Linux Memory Management List,
Xiongchun duan, Fam Zheng, Muchun Song
On Wed, Mar 2, 2022 at 8:32 PM Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> On Wed, Mar 02, 2022 at 04:46:23PM +0800, Muchun Song wrote:
> > When a contiguous HugeTLB page is mapped, set_pte_at() will be called
> > CONT_PTES/CONT_PMDS times. Therefore, __sync_icache_dcache() will
> > flush cache multiple times if the page is executable (to ensure
> > the I-D cache coherency). However, the first flushing cache already
> > covers subsequent cache flush operations. So only flusing cache
> > for the head page if it is a HugeTLB page to avoid redundant cache
> > flushing. In the next patch, it is also depends on this change
> > since the tail vmemmap pages of HugeTLB is mapped with read-only
> > meanning only head page struct can be modified.
> >
> > Signed-off-by: Muchun Song <songmuchun@bytedance.com>
>
> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Thanks for your review.
>
> (for this patch only, I have yet to figure out whether Anshuman's and
> Mark's comments have been addressed in patch 2)
>
Their comments are memory hotplug related, actually, those issues
are not real issues as I explained in patch 2. And If you have any
questions, feel free to ask, maybe I can help.
Thanks Catalin.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 RESEND 1/2] arm64: avoid flushing icache multiple times on contiguous HugeTLB
2022-03-02 8:46 Muchun Song
2022-03-02 12:31 ` Catalin Marinas
@ 2022-03-07 22:03 ` Will Deacon
1 sibling, 0 replies; 4+ messages in thread
From: Will Deacon @ 2022-03-07 22:03 UTC (permalink / raw)
To: mike.kravetz, osalvador, rientjes, mark.rutland, Muchun Song,
akpm, james.morse, bodeddub, david, catalin.marinas,
song.bao.hua
Cc: kernel-team, Will Deacon, smuchun, linux-kernel, duanxiongchun,
linux-mm, linux-arm-kernel, fam.zheng
On Wed, 2 Mar 2022 16:46:23 +0800, Muchun Song wrote:
> When a contiguous HugeTLB page is mapped, set_pte_at() will be called
> CONT_PTES/CONT_PMDS times. Therefore, __sync_icache_dcache() will
> flush cache multiple times if the page is executable (to ensure
> the I-D cache coherency). However, the first flushing cache already
> covers subsequent cache flush operations. So only flusing cache
> for the head page if it is a HugeTLB page to avoid redundant cache
> flushing. In the next patch, it is also depends on this change
> since the tail vmemmap pages of HugeTLB is mapped with read-only
> meanning only head page struct can be modified.
>
> [...]
Applied first patch only to arm64 (for-next/mm), thanks!
[1/2] arm64: avoid flushing icache multiple times on contiguous HugeTLB
https://git.kernel.org/arm64/c/cf5a501d985b
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 RESEND 1/2] arm64: avoid flushing icache multiple times on contiguous HugeTLB
2022-03-02 8:46 Muchun Song
@ 2022-03-02 12:31 ` Catalin Marinas
2022-03-07 22:03 ` Will Deacon
1 sibling, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2022-03-02 12:31 UTC (permalink / raw)
To: Muchun Song
Cc: will, akpm, david, bodeddub, osalvador, mike.kravetz, rientjes,
mark.rutland, james.morse, song.bao.hua, linux-arm-kernel,
linux-kernel, linux-mm, duanxiongchun, fam.zheng, smuchun
On Wed, Mar 02, 2022 at 04:46:23PM +0800, Muchun Song wrote:
> When a contiguous HugeTLB page is mapped, set_pte_at() will be called
> CONT_PTES/CONT_PMDS times. Therefore, __sync_icache_dcache() will
> flush cache multiple times if the page is executable (to ensure
> the I-D cache coherency). However, the first flushing cache already
> covers subsequent cache flush operations. So only flusing cache
> for the head page if it is a HugeTLB page to avoid redundant cache
> flushing. In the next patch, it is also depends on this change
> since the tail vmemmap pages of HugeTLB is mapped with read-only
> meanning only head page struct can be modified.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
(for this patch only, I have yet to figure out whether Anshuman's and
Mark's comments have been addressed in patch 2)
--
Catalin
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 RESEND 1/2] arm64: avoid flushing icache multiple times on contiguous HugeTLB
@ 2022-03-02 8:46 Muchun Song
2022-03-02 12:31 ` Catalin Marinas
2022-03-07 22:03 ` Will Deacon
0 siblings, 2 replies; 4+ messages in thread
From: Muchun Song @ 2022-03-02 8:46 UTC (permalink / raw)
To: will, akpm, david, bodeddub, osalvador, mike.kravetz, rientjes,
mark.rutland, catalin.marinas, james.morse, song.bao.hua
Cc: linux-arm-kernel, linux-kernel, linux-mm, duanxiongchun,
fam.zheng, smuchun, Muchun Song
When a contiguous HugeTLB page is mapped, set_pte_at() will be called
CONT_PTES/CONT_PMDS times. Therefore, __sync_icache_dcache() will
flush cache multiple times if the page is executable (to ensure
the I-D cache coherency). However, the first flushing cache already
covers subsequent cache flush operations. So only flusing cache
for the head page if it is a HugeTLB page to avoid redundant cache
flushing. In the next patch, it is also depends on this change
since the tail vmemmap pages of HugeTLB is mapped with read-only
meanning only head page struct can be modified.
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
arch/arm64/mm/flush.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c
index 2aaf950b906c..a06c6ac770d4 100644
--- a/arch/arm64/mm/flush.c
+++ b/arch/arm64/mm/flush.c
@@ -52,6 +52,13 @@ void __sync_icache_dcache(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_bit(PG_dcache_clean, &page->flags)) {
sync_icache_aliases((unsigned long)page_address(page),
(unsigned long)page_address(page) +
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-07 22:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03 11:20 [PATCH v2 RESEND 1/2] arm64: avoid flushing icache multiple times on contiguous HugeTLB Muchun Song
-- strict thread matches above, loose matches on Subject: below --
2022-03-02 8:46 Muchun Song
2022-03-02 12:31 ` Catalin Marinas
2022-03-07 22:03 ` Will Deacon
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).