aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kvm/mmu.c11
-rw-r--r--include/trace/events/kvm.h22
2 files changed, 30 insertions, 3 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index b8da6715d08b..739793240d1d 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -151,6 +151,9 @@ module_param(oos_shadow, bool, 0644);
151#define ACC_USER_MASK PT_USER_MASK 151#define ACC_USER_MASK PT_USER_MASK
152#define ACC_ALL (ACC_EXEC_MASK | ACC_WRITE_MASK | ACC_USER_MASK) 152#define ACC_ALL (ACC_EXEC_MASK | ACC_WRITE_MASK | ACC_USER_MASK)
153 153
154#include <trace/events/kvm.h>
155
156#undef TRACE_INCLUDE_FILE
154#define CREATE_TRACE_POINTS 157#define CREATE_TRACE_POINTS
155#include "mmutrace.h" 158#include "mmutrace.h"
156 159
@@ -792,6 +795,7 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
792 unsigned long data)) 795 unsigned long data))
793{ 796{
794 int i, j; 797 int i, j;
798 int ret;
795 int retval = 0; 799 int retval = 0;
796 struct kvm_memslots *slots; 800 struct kvm_memslots *slots;
797 801
@@ -806,16 +810,17 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
806 if (hva >= start && hva < end) { 810 if (hva >= start && hva < end) {
807 gfn_t gfn_offset = (hva - start) >> PAGE_SHIFT; 811 gfn_t gfn_offset = (hva - start) >> PAGE_SHIFT;
808 812
809 retval |= handler(kvm, &memslot->rmap[gfn_offset], 813 ret = handler(kvm, &memslot->rmap[gfn_offset], data);
810 data);
811 814
812 for (j = 0; j < KVM_NR_PAGE_SIZES - 1; ++j) { 815 for (j = 0; j < KVM_NR_PAGE_SIZES - 1; ++j) {
813 int idx = gfn_offset; 816 int idx = gfn_offset;
814 idx /= KVM_PAGES_PER_HPAGE(PT_DIRECTORY_LEVEL + j); 817 idx /= KVM_PAGES_PER_HPAGE(PT_DIRECTORY_LEVEL + j);
815 retval |= handler(kvm, 818 ret |= handler(kvm,
816 &memslot->lpage_info[j][idx].rmap_pde, 819 &memslot->lpage_info[j][idx].rmap_pde,
817 data); 820 data);
818 } 821 }
822 trace_kvm_age_page(hva, memslot, ret);
823 retval |= ret;
819 } 824 }
820 } 825 }
821 826
diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h
index 8abdc1230143..b17d49dfc3ef 100644
--- a/include/trace/events/kvm.h
+++ b/include/trace/events/kvm.h
@@ -164,6 +164,28 @@ TRACE_EVENT(kvm_fpu,
164 TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol)) 164 TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol))
165); 165);
166 166
167TRACE_EVENT(kvm_age_page,
168 TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref),
169 TP_ARGS(hva, slot, ref),
170
171 TP_STRUCT__entry(
172 __field( u64, hva )
173 __field( u64, gfn )
174 __field( u8, referenced )
175 ),
176
177 TP_fast_assign(
178 __entry->hva = hva;
179 __entry->gfn =
180 slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT);
181 __entry->referenced = ref;
182 ),
183
184 TP_printk("hva %llx gfn %llx %s",
185 __entry->hva, __entry->gfn,
186 __entry->referenced ? "YOUNG" : "OLD")
187);
188
167#endif /* _TRACE_KVM_MAIN_H */ 189#endif /* _TRACE_KVM_MAIN_H */
168 190
169/* This part must be outside protection */ 191/* This part must be outside protection */