linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 1/1] arm64: mm: remove unnecessary multiple tlb flush of contiguous hugetlb
@ 2023-02-07 11:09 Kaihao Bai
  2023-02-07 18:21 ` Catalin Marinas
  0 siblings, 1 reply; 3+ messages in thread
From: Kaihao Bai @ 2023-02-07 11:09 UTC (permalink / raw)
  To: catalin.marinas, will, linux-arm-kernel, linux-kernel
  Cc: anshuman.khandual, baolin.wang, carlo.bai

In arm64, contiguous flag refers to the same TLB entry that shared by a
contiguous address range. If flush one entry of the address range, it
would cover the whole contiguous address range. Thus there's no need to
flush all contiguous range that CONT_PMD/PTE points to.

Signed-off-by: Kaihao Bai <carlo.bai@linux.alibaba.com>
---
 arch/arm64/mm/hugetlbpage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 95364e8bdc19..9213072ce9c7 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -213,7 +213,7 @@ static pte_t get_clear_contig_flush(struct mm_struct *mm,
 	pte_t orig_pte = get_clear_contig(mm, addr, ptep, pgsize, ncontig);
 	struct vm_area_struct vma = TLB_FLUSH_VMA(mm, 0);
 
-	flush_tlb_range(&vma, addr, addr + (pgsize * ncontig));
+	flush_tlb_page(&vma, addr);
 	return orig_pte;
 }
 
@@ -238,7 +238,7 @@ static void clear_flush(struct mm_struct *mm,
 	for (i = 0; i < ncontig; i++, addr += pgsize, ptep++)
 		pte_clear(mm, addr, ptep);
 
-	flush_tlb_range(&vma, saddr, addr);
+	flush_tlb_page(&vma, saddr);
 }
 
 static inline struct folio *hugetlb_swap_entry_to_folio(swp_entry_t entry)
-- 
2.27.0


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

* Re: [RFC PATCH 1/1] arm64: mm: remove unnecessary multiple tlb flush of contiguous hugetlb
  2023-02-07 11:09 [RFC PATCH 1/1] arm64: mm: remove unnecessary multiple tlb flush of contiguous hugetlb Kaihao Bai
@ 2023-02-07 18:21 ` Catalin Marinas
  2023-02-08  3:43   ` Carlo Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Catalin Marinas @ 2023-02-07 18:21 UTC (permalink / raw)
  To: Kaihao Bai
  Cc: will, linux-arm-kernel, linux-kernel, anshuman.khandual, baolin.wang

On Tue, Feb 07, 2023 at 07:09:41PM +0800, Kaihao Bai wrote:
> In arm64, contiguous flag refers to the same TLB entry that shared by a
> contiguous address range. If flush one entry of the address range, it
> would cover the whole contiguous address range. Thus there's no need to
> flush all contiguous range that CONT_PMD/PTE points to.

This doesn't work. The contiguous bit is a hint, so the CPU may not
coalesce multiple PTEs into a single TLB entry.

-- 
Catalin

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

* Re: [RFC PATCH 1/1] arm64: mm: remove unnecessary multiple tlb flush of contiguous hugetlb
  2023-02-07 18:21 ` Catalin Marinas
@ 2023-02-08  3:43   ` Carlo Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Carlo Bai @ 2023-02-08  3:43 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: will, linux-arm-kernel, linux-kernel, anshuman.khandual, baolin.wang

On 2023/2/8 2:21, Catalin Marinas wrote:
> On Tue, Feb 07, 2023 at 07:09:41PM +0800, Kaihao Bai wrote:
>> In arm64, contiguous flag refers to the same TLB entry that shared by a
>> contiguous address range. If flush one entry of the address range, it
>> would cover the whole contiguous address range. Thus there's no need to
>> flush all contiguous range that CONT_PMD/PTE points to.
> 
> This doesn't work. The contiguous bit is a hint, so the CPU may not
> coalesce multiple PTEs into a single TLB entry.
>Sorry I misunderstood the underlying approach of contiguous bit. I 
re-check and find that "TLB maintenance must be performed based on the 
size of the underlying translation table entries, to avoid TLB
coherency issues.". Thanks for your clarification!

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

end of thread, other threads:[~2023-02-08  3:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 11:09 [RFC PATCH 1/1] arm64: mm: remove unnecessary multiple tlb flush of contiguous hugetlb Kaihao Bai
2023-02-07 18:21 ` Catalin Marinas
2023-02-08  3:43   ` Carlo Bai

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).