From: Anthony Liguori <anthony@codemonkey.ws>
To: malc <av1474@comtv.ru>
Cc: qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] Re: [PATCH 05/26] Unexport ticks_per_sec variable. Create get_ticks_per_sec() function
Date: Fri, 11 Sep 2009 10:34:40 -0500 [thread overview]
Message-ID: <4AAA6E10.6080308@codemonkey.ws> (raw)
In-Reply-To: <Pine.LNX.4.64.0909110308350.2097@linmac.oyster.ru>
[-- Attachment #1: Type: text/plain, Size: 547 bytes --]
malc wrote:
> And generalizations are always true. Anyhow, i'm explicitly against the
> patch, so first obtain the express acknowledgment from the leaders,
> otherwise i'll revert it should it go in.
>
I'm adding the following patch to Juan's series. The result is that
get_ticks_per_sec() should be optimized to a literal value. The result
being that uses of it are faster than they were before (not it should
matter).
I think the result of this patch is that the refactoring is an
undeniable improvement.
Regards,
Anthony Liguori
[-- Attachment #2: get-ticks-per-sec.patch --]
[-- Type: text/x-patch, Size: 3203 bytes --]
commit 1c7aff17af0ca9e1803b952ce455f096c5da8847
Author: Anthony Liguori <aliguori@us.ibm.com>
Date: Fri Sep 11 10:28:26 2009 -0500
Make get_ticks_per_sec() a static inline
ticks_per_sec is a constant. There's no need to store it as a variable as it
never changes since our time is based on units.
Convert get_ticks_per_sec() to a static inline and move the constant into
qemu-timer.h. Remove all references to QEMU_TIMER_BASE so that we consistently
use this interface.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/qemu-timer.h b/qemu-timer.h
index 00b166d..e44c334 100644
--- a/qemu-timer.h
+++ b/qemu-timer.h
@@ -26,7 +26,10 @@ void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
int qemu_timer_pending(QEMUTimer *ts);
int qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time);
-int64_t get_ticks_per_sec(void);
+static inline int64_t get_ticks_per_sec(void)
+{
+ return 1000000000LL;
+}
void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
diff --git a/vl.c b/vl.c
index 6052b1c..c3c874d 100644
--- a/vl.c
+++ b/vl.c
@@ -528,8 +528,6 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
/***********************************************************/
/* real time host monotonic timer */
-#define QEMU_TIMER_BASE 1000000000LL
-
#ifdef WIN32
static int64_t clock_freq;
@@ -550,7 +548,7 @@ static int64_t get_clock(void)
{
LARGE_INTEGER ti;
QueryPerformanceCounter(&ti);
- return muldiv64(ti.QuadPart, QEMU_TIMER_BASE, clock_freq);
+ return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq);
}
#else
@@ -758,7 +756,7 @@ static void rtc_stop_timer(struct qemu_alarm_timer *t);
fairly approximate, so ignore small variation.
When the guest is idle real and virtual time will be aligned in
the IO wait loop. */
-#define ICOUNT_WOBBLE (QEMU_TIMER_BASE / 10)
+#define ICOUNT_WOBBLE (get_ticks_per_sec() / 10)
static void icount_adjust(void)
{
@@ -800,7 +798,7 @@ static void icount_adjust_rt(void * opaque)
static void icount_adjust_vm(void * opaque)
{
qemu_mod_timer(icount_vm_timer,
- qemu_get_clock(vm_clock) + QEMU_TIMER_BASE / 10);
+ qemu_get_clock(vm_clock) + get_ticks_per_sec() / 10);
icount_adjust();
}
@@ -816,7 +814,7 @@ static void init_icount_adjust(void)
qemu_get_clock(rt_clock) + 1000);
icount_vm_timer = qemu_new_timer(vm_clock, icount_adjust_vm, NULL);
qemu_mod_timer(icount_vm_timer,
- qemu_get_clock(vm_clock) + QEMU_TIMER_BASE / 10);
+ qemu_get_clock(vm_clock) + get_ticks_per_sec() / 10);
}
static struct qemu_alarm_timer alarm_timers[] = {
@@ -1036,15 +1034,10 @@ int64_t qemu_get_clock(QEMUClock *clock)
}
}
-int64_t get_ticks_per_sec(void)
-{
- return timers_state.ticks_per_sec;
-}
-
static void init_timers(void)
{
init_get_clock();
- timers_state.ticks_per_sec = QEMU_TIMER_BASE;
+ timers_state.ticks_per_sec = get_ticks_per_sec();
rt_clock = qemu_new_clock(QEMU_TIMER_REALTIME);
vm_clock = qemu_new_clock(QEMU_TIMER_VIRTUAL);
}
next prev parent reply other threads:[~2009-09-11 15:34 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-10 1:04 [Qemu-devel] [PATCH 00/26] VMState: port several pc devices to vmstate Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 01/26] ram: remove support for loading v1 Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 02/26] ram: Remove SaveVM Version 2 support Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 03/26] Remove SaveVM v2 support Juan Quintela
2009-09-10 17:41 ` Stefano Stabellini
2009-09-10 17:43 ` [Qemu-devel] " Juan Quintela
2009-09-10 18:15 ` Stefano Stabellini
2009-09-10 18:22 ` Anthony Liguori
2009-09-11 14:05 ` Stefano Stabellini
2009-09-11 14:28 ` Juan Quintela
2009-09-11 15:32 ` Stefano Stabellini
2009-09-11 15:37 ` Anthony Liguori
2009-09-11 15:48 ` Juan Quintela
2009-09-11 17:59 ` Stefano Stabellini
2009-09-17 11:40 ` Stefano Stabellini
2009-09-10 1:04 ` [Qemu-devel] [PATCH 04/26] timers: remove useless check Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 05/26] Unexport ticks_per_sec variable. Create get_ticks_per_sec() function Juan Quintela
2009-09-10 1:20 ` malc
2009-09-10 1:57 ` [Qemu-devel] " Juan Quintela
2009-09-10 2:21 ` malc
2009-09-10 16:44 ` Juan Quintela
2009-09-10 17:02 ` malc
2009-09-10 17:38 ` Anthony Liguori
2009-09-10 21:31 ` malc
2009-09-10 22:08 ` Anthony Liguori
2009-09-10 23:10 ` malc
2009-09-10 23:33 ` Juan Quintela
2009-09-11 5:49 ` Amit Shah
2009-09-11 13:00 ` Markus Armbruster
2009-09-11 15:34 ` Anthony Liguori [this message]
2009-09-11 15:55 ` Juan Quintela
2009-09-11 15:58 ` Jan Kiszka
2009-11-09 16:29 ` Paul Brook
2009-09-10 17:39 ` Juan Quintela
2009-09-10 22:16 ` Paolo Bonzini
2009-09-10 23:11 ` malc
2009-09-11 9:04 ` Jan Kiszka
2009-09-11 9:31 ` Juan Quintela
2009-09-11 9:37 ` Jan Kiszka
2009-09-11 10:15 ` Juan Quintela
2009-09-11 10:26 ` Jan Kiszka
2009-09-10 1:04 ` [Qemu-devel] [PATCH 06/26] timers: Createt TimersState and put all timers state there Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 07/26] timers: move them to VMState Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 08/26] vmstate: add sensible arguments to vmstate_unregister() Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 09/26] vmstate: rename run_after_load() -> post_load() Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 10/26] vmstate: Add pre_load() hook Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 11/26] vmstate: Add pre/post_save() hooks Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 12/26] vmstate: port cpu_comon Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 13/26] vmstate: port fw_cfg device Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 14/26] vmstate: port i8259 device Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 15/26] vmstate: add support for uint8_t equal Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 16/26] vmstate: port fdc device Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 17/26] vmstate: add support for arrays of uint16_t Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 18/26] vmstate: port dma device Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 19/26] vmstate: port vmmouse device Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 20/26] vmstate: port pckbd device Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 21/26] vmstate: add uint64 array support Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 22/26] vmstate: port ioapic device Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 23/26] hpet: it is imposible that qemu_timer field is NULL at this point Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 24/26] vmstate: port hpet device Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 25/26] vmstate: port serial device Juan Quintela
2009-09-10 1:04 ` [Qemu-devel] [PATCH 26/26] vmstate: port cirrus_vga device Juan Quintela
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=4AAA6E10.6080308@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=av1474@comtv.ru \
--cc=qemu-devel@nongnu.org \
--cc=quintela@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).