[patch -mm] mm, vmacache: hash addresses based on pmd fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- 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@xxxxxxxxx>
Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx>
---
 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);




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux