aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWanpeng Li <wanpeng.li@hotmail.com>2015-09-03 10:07:39 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2015-09-06 10:33:14 -0400
commit2cbd78244fb26a06f2b8fb006b32f133451df413 (patch)
tree1fac5e7a0438045dc3036fe27ab9f177628823cb
parentaca6ff29c4063a8d467cdee241e6b3bf7dc4a171 (diff)
KVM: trace kvm_halt_poll_ns grow/shrink
Tracepoint for dynamic halt_pool_ns, fired on every potential change. Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--include/trace/events/kvm.h30
-rw-r--r--virt/kvm/kvm_main.c8
2 files changed, 36 insertions, 2 deletions
diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h
index a44062da684b..0d1bc478833b 100644
--- a/include/trace/events/kvm.h
+++ b/include/trace/events/kvm.h
@@ -356,6 +356,36 @@ TRACE_EVENT(
356 __entry->address) 356 __entry->address)
357); 357);
358 358
359TRACE_EVENT(kvm_halt_poll_ns,
360 TP_PROTO(bool grow, unsigned int vcpu_id, int new, int old),
361 TP_ARGS(grow, vcpu_id, new, old),
362
363 TP_STRUCT__entry(
364 __field(bool, grow)
365 __field(unsigned int, vcpu_id)
366 __field(int, new)
367 __field(int, old)
368 ),
369
370 TP_fast_assign(
371 __entry->grow = grow;
372 __entry->vcpu_id = vcpu_id;
373 __entry->new = new;
374 __entry->old = old;
375 ),
376
377 TP_printk("vcpu %u: halt_poll_ns %d (%s %d)",
378 __entry->vcpu_id,
379 __entry->new,
380 __entry->grow ? "grow" : "shrink",
381 __entry->old)
382);
383
384#define trace_kvm_halt_poll_ns_grow(vcpu_id, new, old) \
385 trace_kvm_halt_poll_ns(true, vcpu_id, new, old)
386#define trace_kvm_halt_poll_ns_shrink(vcpu_id, new, old) \
387 trace_kvm_halt_poll_ns(false, vcpu_id, new, old)
388
359#endif 389#endif
360 390
361#endif /* _TRACE_KVM_MAIN_H */ 391#endif /* _TRACE_KVM_MAIN_H */
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 8ab49cfc024e..4662a8877f6c 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1918,8 +1918,9 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_mark_page_dirty);
1918 1918
1919static void grow_halt_poll_ns(struct kvm_vcpu *vcpu) 1919static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
1920{ 1920{
1921 int val = vcpu->halt_poll_ns; 1921 int old, val;
1922 1922
1923 old = val = vcpu->halt_poll_ns;
1923 /* 10us base */ 1924 /* 10us base */
1924 if (val == 0 && halt_poll_ns_grow) 1925 if (val == 0 && halt_poll_ns_grow)
1925 val = 10000; 1926 val = 10000;
@@ -1927,18 +1928,21 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
1927 val *= halt_poll_ns_grow; 1928 val *= halt_poll_ns_grow;
1928 1929
1929 vcpu->halt_poll_ns = val; 1930 vcpu->halt_poll_ns = val;
1931 trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, val, old);
1930} 1932}
1931 1933
1932static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu) 1934static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu)
1933{ 1935{
1934 int val = vcpu->halt_poll_ns; 1936 int old, val;
1935 1937
1938 old = val = vcpu->halt_poll_ns;
1936 if (halt_poll_ns_shrink == 0) 1939 if (halt_poll_ns_shrink == 0)
1937 val = 0; 1940 val = 0;
1938 else 1941 else
1939 val /= halt_poll_ns_shrink; 1942 val /= halt_poll_ns_shrink;
1940 1943
1941 vcpu->halt_poll_ns = val; 1944 vcpu->halt_poll_ns = val;
1945 trace_kvm_halt_poll_ns_shrink(vcpu->vcpu_id, val, old);
1942} 1946}
1943 1947
1944static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu) 1948static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu)