Skip to content

Commit

Permalink
mm: unrig VMA cache hit ratio
Browse files Browse the repository at this point in the history
Current code doesn't count first FIND operation after VMA cache flush
(which happen surprisingly often) artificially increasing cache hit ratio.

On my regular setup the difference is:

		Before				After
	==========================================================

	* boot, login into KDE

	vmacache_find_calls 446216	vmacache_find_calls 492741
	vmacache_find_hits 277596	vmacache_find_hits 276096

		~62.2%				~56.0%

	* rebuild kernel (no changes to code, usual config)

	vmacache_find_calls 1943007	vmacache_find_calls 2083718
	vmacache_find_hits 1246123	vmacache_find_hits 1244146

		~64.1%				~59.7%

	* rebuild kernel (full rebuild, usual config)

	vmacache_find_calls 32163155	vmacache_find_calls 33677183
	vmacache_find_hits 27889956	vmacache_find_hits 27877591

		~88.2%				~84.3%

Total: ~4% cache hit ratio.

If someone is counting _relative_ cache _miss_ ratio, misreporting is much
higher.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Alexey Dobriyan <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and sfrothwell committed Sep 29, 2016
1 parent 52bd295 commit c9430e3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mm/vmacache.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr)
{
int i;

count_vm_vmacache_event(VMACACHE_FIND_CALLS);

if (!vmacache_valid(mm))
return NULL;

count_vm_vmacache_event(VMACACHE_FIND_CALLS);

for (i = 0; i < VMACACHE_SIZE; i++) {
struct vm_area_struct *vma = current->vmacache[i];

Expand All @@ -115,11 +115,11 @@ struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm,
{
int i;

count_vm_vmacache_event(VMACACHE_FIND_CALLS);

if (!vmacache_valid(mm))
return NULL;

count_vm_vmacache_event(VMACACHE_FIND_CALLS);

for (i = 0; i < VMACACHE_SIZE; i++) {
struct vm_area_struct *vma = current->vmacache[i];

Expand Down

0 comments on commit c9430e3

Please sign in to comment.