path: root/mm/mmu_notifier.c
diff options
authorVladimir Davydov <>2015-09-09 15:35:41 -0700
committerLinus Torvalds <>2015-09-10 13:29:01 -0700
commit1d7715c676a1566c2e4c3e77d16b1f9bb4909025 (patch)
tree81d2fb1c256280de7faa19dc2e269b6c8c4bcfc8 /mm/mmu_notifier.c
parent80ae2fdceba8313b0433f899bdd9c6c463291a17 (diff)
mmu-notifier: add clear_young callback
In the scope of the idle memory tracking feature, which is introduced by the following patch, we need to clear the referenced/accessed bit not only in primary, but also in secondary ptes. The latter is required in order to estimate wss of KVM VMs. At the same time we want to avoid flushing tlb, because it is quite expensive and it won't really affect the final result. Currently, there is no function for clearing pte young bit that would meet our requirements, so this patch introduces one. To achieve that we have to add a new mmu-notifier callback, clear_young, since there is no method for testing-and-clearing a secondary pte w/o flushing tlb. The new method is not mandatory and currently only implemented by KVM. Signed-off-by: Vladimir Davydov <> Reviewed-by: Andres Lagar-Cavilla <> Acked-by: Paolo Bonzini <> Cc: Minchan Kim <> Cc: Raghavendra K T <> Cc: Johannes Weiner <> Cc: Michal Hocko <> Cc: Greg Thelen <> Cc: Michel Lespinasse <> Cc: David Rientjes <> Cc: Pavel Emelyanov <> Cc: Cyrill Gorcunov <> Cc: Jonathan Corbet <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm/mmu_notifier.c')
1 files changed, 17 insertions, 0 deletions
diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
index 3b9b3d0741b2..5fbdd367bbed 100644
--- a/mm/mmu_notifier.c
+++ b/mm/mmu_notifier.c
@@ -123,6 +123,23 @@ int __mmu_notifier_clear_flush_young(struct mm_struct *mm,
return young;
+int __mmu_notifier_clear_young(struct mm_struct *mm,
+ unsigned long start,
+ unsigned long end)
+ struct mmu_notifier *mn;
+ int young = 0, id;
+ id = srcu_read_lock(&srcu);
+ hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist) {
+ if (mn->ops->clear_young)
+ young |= mn->ops->clear_young(mn, mm, start, end);
+ }
+ srcu_read_unlock(&srcu, id);
+ return young;
int __mmu_notifier_test_young(struct mm_struct *mm,
unsigned long address)