linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch -mm] mm, vmacache: hash addresses based on pmd fix
@ 2018-07-23 22:34 David Rientjes
  0 siblings, 0 replies; only message in thread
From: David Rientjes @ 2018-07-23 22:34 UTC (permalink / raw)
  To: Andrew Morton; +Cc: kbuild-all, lkp, Johannes Weiner, linux-mm

- use PMD_SHIFT only if CONFIG_MMU is used, otherwise there is only pgdir, 
per kbuild test robot

- fix vmacache_find_exact() for correct formal name, per me

- only check vma->vm_mm == mm for CONFIG_DEBUG_VM_VMACACHE, per akpm

Tested for {allnoconfig, defconfig} on alpha, arc, arm, arm64, c6x, h8300, 
i386, ia64, m68k, microblaze, mips, mips, nds32, nios2, parisc, powerpc, 
riscv, s390, sh, sparc, um, and xtensa.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/vmacache.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/mm/vmacache.c b/mm/vmacache.c
--- a/mm/vmacache.c
+++ b/mm/vmacache.c
@@ -6,12 +6,18 @@
 #include <linux/sched/task.h>
 #include <linux/mm.h>
 #include <linux/vmacache.h>
+#include <asm/pgtable.h>
 
 /*
- * Hash based on the pmd of addr.  Provides a good hit rate for workloads with
- * spatial locality.
+ * Hash based on the pmd of addr if configured with MMU, which provides a good
+ * hit rate for workloads with spatial locality.  Otherwise, use pages.
  */
-#define VMACACHE_HASH(addr) ((addr >> PMD_SHIFT) & VMACACHE_MASK)
+#ifdef CONFIG_MMU
+#define VMACACHE_SHIFT	PMD_SHIFT
+#else
+#define VMACACHE_SHIFT	PAGE_SHIFT
+#endif
+#define VMACACHE_HASH(addr) ((addr >> VMACACHE_SHIFT) & VMACACHE_MASK)
 
 /*
  * Flush vma caches for threads that share a given mm.
@@ -105,8 +111,10 @@ struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr)
 		struct vm_area_struct *vma = current->vmacache.vmas[idx];
 
 		if (vma) {
+#ifdef CONFIG_DEBUG_VM_VMACACHE
 			if (WARN_ON_ONCE(vma->vm_mm != mm))
 				break;
+#endif
 			if (vma->vm_start <= addr && vma->vm_end > addr) {
 				count_vm_vmacache_event(VMACACHE_FIND_HITS);
 				return vma;
@@ -124,7 +132,7 @@ struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm,
 					   unsigned long start,
 					   unsigned long end)
 {
-	int idx = VMACACHE_HASH(addr);
+	int idx = VMACACHE_HASH(start);
 	int i;
 
 	count_vm_vmacache_event(VMACACHE_FIND_CALLS);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-07-23 22:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-23 22:34 [patch -mm] mm, vmacache: hash addresses based on pmd fix David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox