qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 03/12] qemu-timer: more clock functions
Date: Fri, 30 Sep 2011 13:03:58 +0200	[thread overview]
Message-ID: <4E85A21E.7010408@redhat.com> (raw)
In-Reply-To: <87ipoa5mkt.fsf@ginnungagap.bsc.es>

On 09/30/2011 12:52 PM, Lluís Vilanova wrote:
> Paolo Bonzini writes:
>
>> These will be used when moving icount accounting to cpus.c.
>
> I have something related to this kind of refactoring. While trying to understand
> all the timing facilities in QEMU, I wrote some (unfinished) patches that try to
> disentangle much of the code in qemu-timer into two new files:
>
> - qemu-htime: Provides routines related to time in the host.
> - qemu-vtime: Provides routines related to time in the guest.
>
> These patches also try to sanitize some routine names by making their domain and
> units explicit (e.g., get_clock becomes qemu_htime_nsec and cpu_get_ticks
> becomes qemu_vtime_tsc).

That's almost unnecessary, get_clock should be just 
qemu_get_clock_ns(host_clock) or something like that.  The problem is 
that the clock names are impossible to remember. :)

However, making it clear from the name whether get_clock refers to the 
host_clock or rt_clock can be a useful cleanup.

> The patches also make the frequency explicit (adds
> qemu_htime_freq and qemu_vtime_freq).

The frequency of the clocks is now always explicit in the function names 
(using _ns or _ms).

> The routines in qemu-timer should be already moved into the corresponding
> qemu-*time files (I no longer remember on which state I left it), but the
> routine name sanitizing is not finished, mostly because I still had to clear out
> some details about how the current deadline calculation works.

I think after my series there is already a similar split, with 
qemu-timer.c doing everything except the guest clock, and cpus.c taking 
care of the guest clock.

I have a few more cleanups pending in this area, but I'll submit them 
probably after 1.0 since I have enough stuff on my plate already.

> Does this kind of refactoring sound interesting?

Renaming the host_clock and rt_clock to something more easily remembered 
is trivial, but still useful.

It is also useful to make a dummy vmclock (with primitives like "get", 
"set", "advance to the next deadline") available outside qemu proper for 
use in unit tests.  I'm not sure how close we are to unit testing of 
device models, but anything that makes us closer is worthwhile.

Paolo

  reply	other threads:[~2011-09-30 11:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 16:31 [Qemu-devel] [PATCH 00/12] allow tools to use the QEMU main loop Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 01/12] qemu-timer: remove active_timers array Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 02/12] qemu-timer: move common code to qemu_rearm_alarm_timer Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 03/12] qemu-timer: more clock functions Paolo Bonzini
2011-09-30 10:52   ` Lluís Vilanova
2011-09-30 11:03     ` Paolo Bonzini [this message]
2011-09-30 12:15       ` Lluís Vilanova
2011-09-27 16:31 ` [Qemu-devel] [PATCH 04/12] qemu-timer: move icount to cpus.c Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 05/12] qemu-timer: do not refer to runstate_is_running() Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 06/12] qemu-timer: use atexit for quit_timers Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 07/12] qemu-timer: move more stuff out of qemu-timer.c Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 08/12] qemu-timer: do not use RunState change handlers Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 09/12] create main-loop.h Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 10/12] create main-loop.c Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 11/12] Revert to a hand-made select loop Paolo Bonzini
2011-09-27 16:31 ` [Qemu-devel] [PATCH 12/12] simplify main loop functions 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=4E85A21E.7010408@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).