All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: "Yang, Sheng" <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH 1/2] KVM: In-kernel PIT model
Date: Mon, 28 Jan 2008 13:59:18 +0200	[thread overview]
Message-ID: <479DC396.3030202@qumranet.com> (raw)
In-Reply-To: <200801281444.34693.sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

Yang, Sheng wrote:
> From af5d9ee2a189c2f0998c5c46d1fcd25c5cb72f8c Mon Sep 17 00:00:00 2001
> From: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Mon, 28 Jan 2008 05:10:22 +0800
> Subject: [PATCH] KVM: In-kernel PIT model
>
> The patch moved PIT from userspace to kernel, and increase the timer accuracy 
> greatly.
>   

> diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
> new file mode 100644
> index 0000000..73b8240
> --- /dev/null
> +++ b/arch/x86/kvm/i8254.c
> +/* Compute with 96 bit intermediate result: (a*b)/c */
> +static u64 muldiv64(u64 a, u32 b, u32 c)
> +{
> +	union {
> +		u64 ll;
> +		struct {
> +#ifdef WORDS_BIGENDIAN
> +			u32 high, low;
> +#else
> +			u32 low, high;
> +#endif
>   

Since this is in arch/x86, we're implicitly little endian, so you can 
remove the ifdef.

> +
> +static int pit_get_count(struct kvm *kvm, int channel)
> +{
> +	struct pit_channel_state *c =
> +		&kvm->arch.vpit->pit_state.channels[channel];
> +	s64 d, t;
> +	int counter;
> +
> +	ASSERT(mutex_is_locked(&kvm->arch.vpit->pit_state.lock));
> +
> +	t = ktime_to_ns(ktime_sub(ktime_get(), c->count_load_time));
> +	d = muldiv64(t, PIT_FREQ, 1e9);
>   

1e9 is a float, which is frowned upon in the kernel.  While it is 
converted in compile time, it is better to use an int (like NSEC_PER_SEC).

> diff --git a/arch/x86/kvm/i8254.h b/arch/x86/kvm/i8254.h
> new file mode 100644
> index 0000000..fcff9fb
> --- /dev/null
> +++ b/arch/x86/kvm/i8254.h
> @@ -0,0 +1,62 @@
> +
> +extern unsigned int cpu_khz;
>   

unused, please drop.

> +
> +struct pit_timer {
> +
> +struct pit_channel_state {
> +
> +struct pit_state {
>   

These names are too generic, please prefix with kvm_ so nobody confuses 
them with host hardware.

> +
> +struct kvm_pit {
> +	unsigned long base_addresss;
> +	struct kvm_io_device dev;
> +	struct kvm_io_device speaker_dev;
> +	struct kvm *kvm;
> +	struct pit_state pit_state;
> +	atomic_t inject_pending; /* if inject pending interrupts */
>   

inject_pending is only used with atomic_set() and atomic_read(); a 
simple bool is atomic for simple read/write ops.

Need save/restore support.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

      parent reply	other threads:[~2008-01-28 11:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-28  6:44 [PATCH 1/2] KVM: In-kernel PIT model Yang, Sheng
     [not found] ` <200801281444.34693.sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-01-28 11:59   ` Avi Kivity [this message]

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=479DC396.3030202@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.