mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ashish Mhetre <amhetre@nvidia.com>
To: <mark.rutland@arm.com>, <linux-arm-kernel@lists.infradead.org>,
	<linux-tegra@vger.kernel.org>, <avanbrunt@nvidia.com>
Cc: <linux-kernel@vger.kernel.org>, <vdumpa@nvidia.com>,
	Ashish Mhetre <amhetre@nvidia.com>
Subject: [PATCH V2] arm64: Don't flush tlb while clearing the accessed bit
Date: Mon, 29 Oct 2018 11:59:59 +0530	[thread overview]
Message-ID: <1540794599-30922-1-git-send-email-amhetre@nvidia.com> (raw)

From: Alex Van Brunt <avanbrunt@nvidia.com>

Accessed bit is used to age a page and in generic implementation there is
flush_tlb while clearing the accessed bit.
Flushing a TLB is overhead on ARM64 as access flag faults don't get
translation table entries cached into TLB's. Flushing TLB is not necessary
for this. Clearing the accessed bit without flushing TLB doesn't cause data
corruption on ARM64. [It may cause incorrect page aging but chances of that
should be relatively low.]
In our case with this patch, speed of reading from fast NVMe/SSD through
PCIe got improved by 10% ~ 15% and writing got improved by 20% ~ 40%.
So for performance optimisation don't flush TLB when clearing the accessed
bit on ARM64.
x86 made the same optimization even though their TLB invalidate is much
faster as it doesn't broadcast to other CPUs.

Signed-off-by: Alex Van Brunt <avanbrunt@nvidia.com>
Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
v2: Added comments about why flushing is not needed while clearing accessed bit

 arch/arm64/include/asm/pgtable.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 2ab2031..33e1940 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -652,6 +652,22 @@ static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
 	return __ptep_test_and_clear_young(ptep);
 }
 
+#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
+static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
+					 unsigned long address, pte_t *ptep)
+{
+	/*
+	 * Flushing a TLB is overhead on ARM64 as access flag faults don't get
+	 * translation table entries cached into TLB's. Flushing TLB is not
+	 * necessary for this. Clearing the accessed bit without flushing TLB
+	 * doesn't cause data corruption on ARM64.[ It may cause imcorrect page
+	 * aging but chances of this should be comparatively low. ]
+	 * So as a performance optimization don't flush the TLB when clearing
+	 * the accessed bit.
+	 */
+	return ptep_test_and_clear_young(vma, address, ptep);
+}
+
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
 static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
-- 
2.7.4


             reply	other threads:[~2018-10-29  6:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29  6:29 Ashish Mhetre [this message]
2018-10-29  8:57 ` Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1540794599-30922-1-git-send-email-amhetre@nvidia.com \
    --to=amhetre@nvidia.com \
    --cc=avanbrunt@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=vdumpa@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®