vmacache.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef __LINUX_VMACACHE_H
  2. #define __LINUX_VMACACHE_H
  3. #include <linux/sched.h>
  4. #include <linux/mm.h>
  5. /*
  6. * Hash based on the page number. Provides a good hit rate for
  7. * workloads with good locality and those with random accesses as well.
  8. */
  9. #define VMACACHE_HASH(addr) ((addr >> PAGE_SHIFT) & VMACACHE_MASK)
  10. static inline void vmacache_flush(struct task_struct *tsk)
  11. {
  12. memset(tsk->vmacache, 0, sizeof(tsk->vmacache));
  13. }
  14. extern void vmacache_flush_all(struct mm_struct *mm);
  15. extern void vmacache_update(unsigned long addr, struct vm_area_struct *newvma);
  16. extern struct vm_area_struct *vmacache_find(struct mm_struct *mm,
  17. unsigned long addr);
  18. #ifndef CONFIG_MMU
  19. extern struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm,
  20. unsigned long start,
  21. unsigned long end);
  22. #endif
  23. static inline void vmacache_invalidate(struct mm_struct *mm)
  24. {
  25. mm->vmacache_seqnum++;
  26. /* deal with overflows */
  27. if (unlikely(mm->vmacache_seqnum == 0))
  28. vmacache_flush_all(mm);
  29. }
  30. #endif /* __LINUX_VMACACHE_H */