Commit e0b728b1 authored by David Matlack's avatar David Matlack Committed by Paolo Bonzini

KVM: x86/mmu: Add tracepoint for splitting huge pages

Add a tracepoint that records whenever KVM eagerly splits a huge page
and the error status of the split to indicate if it succeeded or failed
and why.
Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
Signed-off-by: default avatarDavid Matlack <dmatlack@google.com>
Message-Id: <20220119230739.2234394-18-dmatlack@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent cb00a70b
...@@ -416,6 +416,29 @@ TRACE_EVENT( ...@@ -416,6 +416,29 @@ TRACE_EVENT(
) )
); );
TRACE_EVENT(
kvm_mmu_split_huge_page,
TP_PROTO(u64 gfn, u64 spte, int level, int errno),
TP_ARGS(gfn, spte, level, errno),
TP_STRUCT__entry(
__field(u64, gfn)
__field(u64, spte)
__field(int, level)
__field(int, errno)
),
TP_fast_assign(
__entry->gfn = gfn;
__entry->spte = spte;
__entry->level = level;
__entry->errno = errno;
),
TP_printk("gfn %llx spte %llx level %d errno %d",
__entry->gfn, __entry->spte, __entry->level, __entry->errno)
);
#endif /* _TRACE_KVMMMU_H */ #endif /* _TRACE_KVMMMU_H */
#undef TRACE_INCLUDE_PATH #undef TRACE_INCLUDE_PATH
......
...@@ -1347,7 +1347,7 @@ static int tdp_mmu_split_huge_page(struct kvm *kvm, struct tdp_iter *iter, ...@@ -1347,7 +1347,7 @@ static int tdp_mmu_split_huge_page(struct kvm *kvm, struct tdp_iter *iter,
*/ */
ret = tdp_mmu_link_sp(kvm, iter, sp, false, shared); ret = tdp_mmu_link_sp(kvm, iter, sp, false, shared);
if (ret) if (ret)
return ret; goto out;
/* /*
* tdp_mmu_link_sp_atomic() will handle subtracting the huge page we * tdp_mmu_link_sp_atomic() will handle subtracting the huge page we
...@@ -1356,7 +1356,9 @@ static int tdp_mmu_split_huge_page(struct kvm *kvm, struct tdp_iter *iter, ...@@ -1356,7 +1356,9 @@ static int tdp_mmu_split_huge_page(struct kvm *kvm, struct tdp_iter *iter,
*/ */
kvm_update_page_stats(kvm, level - 1, PT64_ENT_PER_PAGE); kvm_update_page_stats(kvm, level - 1, PT64_ENT_PER_PAGE);
return 0; out:
trace_kvm_mmu_split_huge_page(iter->gfn, huge_spte, level, ret);
return ret;
} }
static int tdp_mmu_split_huge_pages_root(struct kvm *kvm, static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
...@@ -1393,6 +1395,9 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm, ...@@ -1393,6 +1395,9 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
sp = tdp_mmu_alloc_sp_for_split(kvm, &iter, shared); sp = tdp_mmu_alloc_sp_for_split(kvm, &iter, shared);
if (!sp) { if (!sp) {
ret = -ENOMEM; ret = -ENOMEM;
trace_kvm_mmu_split_huge_page(iter.gfn,
iter.old_spte,
iter.level, ret);
break; break;
} }
...@@ -1416,7 +1421,6 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm, ...@@ -1416,7 +1421,6 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
if (sp) if (sp)
tdp_mmu_free_sp(sp); tdp_mmu_free_sp(sp);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment