qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Bligh <alex@alex.org.uk>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Alex Bligh <alex@alex.org.uk>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	liu ping fan <qemulist@gmail.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>,
	rth@twiddle.net
Subject: [Qemu-devel] [PATCHv1 3/4] Timers: Instrument timer_mod
Date: Fri, 25 Oct 2013 23:30:33 +0100	[thread overview]
Message-ID: <1382740234-21345-4-git-send-email-alex@alex.org.uk> (raw)
In-Reply-To: <1382740234-21345-1-git-send-email-alex@alex.org.uk>

Add instrumentation for timer_mod to allow measurement of the
average time delta to expiry plus the number of short delta
periods. This is only run when logging to a file because
getting the clock value may add appreciable expense.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
---
 qemu-timer.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/qemu-timer.c b/qemu-timer.c
index 84a8932..16eaa1f 100644
--- a/qemu-timer.c
+++ b/qemu-timer.c
@@ -376,6 +376,23 @@ static bool timer_mod_ns_locked(QEMUTimerList *timer_list,
     ts->next = *pt;
     *pt = ts;
 
+    if (timer_debug_log) {
+        int64_t delta;
+
+        delta = ts->expire_time -
+            qemu_clock_get_ns(ts->timer_list->clock->type);
+        if (delta <= 0) {
+            delta = 0;
+        }
+
+        ts->tot_deltas += delta;
+        ts->num_deltas++;
+
+        if (delta < SCALE_US) {
+            ts->num_short++;
+        }
+    }
+
     return pt == &timer_list->active_timers;
 }
 
-- 
1.7.9.5

  parent reply	other threads:[~2013-10-25 22:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-25 22:30 [Qemu-devel] [PATCHv1 0/4] Timers: add timer debugging through -timer-debug-log Alex Bligh
2013-10-25 22:30 ` [Qemu-devel] [PATCHv1 1/4] Timers: add debugging macros wrapping timer functions and debug structures Alex Bligh
2013-10-25 22:30 ` [Qemu-devel] [PATCHv1 2/4] Timers: add command line option -timer-debug-log Alex Bligh
2013-10-25 22:30 ` Alex Bligh [this message]
2013-10-25 22:30 ` [Qemu-devel] [PATCHv1 4/4] Timers: produce timer-debug-log file Alex Bligh
2013-10-25 23:00 ` [Qemu-devel] [PATCHv1 0/4] Timers: add timer debugging through -timer-debug-log Paolo Bonzini
2013-10-26  5:52   ` Alex Bligh
2013-10-26  7:18     ` Paolo Bonzini
2013-10-26  8:24       ` Alex Bligh
2013-10-26 17:11         ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1382740234-21345-4-git-send-email-alex@alex.org.uk \
    --to=alex@alex.org.uk \
    --cc=aliguori@us.ibm.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kwolf@redhat.com \
    --cc=morita.kazutaka@lab.ntt.co.jp \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemulist@gmail.com \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).