All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yang, Sheng" <sheng.yang@intel.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: kvm-devel@lists.sourceforge.net, Avi Kivity <avi@qumranet.com>
Subject: Re: [PATCH 1/6] KVM: In kernel pit model
Date: Wed, 5 Mar 2008 19:35:40 +0800	[thread overview]
Message-ID: <200803051935.40229.sheng.yang@intel.com> (raw)
In-Reply-To: <20080305091529.GA25357@elte.hu>

Thanks for comments!

On Wednesday 05 March 2008 17:15:29 Ingo Molnar wrote:
> * Yang, Sheng <sheng.yang@intel.com> wrote:
> > +#if 1
> > +#define pit_debug(fmt, arg...) printk(KERN_WARNING fmt, ##arg)
> > +#else
> > +#define pit_debug(fmt, arg...)
> > +#endif
>
> this should use pr_debug() instead i guess.

Um... I followed example on ./virt/kvm/ioapic.c here. Though I think it's good 
to substitute all self defined debug printk with pr_debug, why KVM have 
little pr_xxx(the only ones are in x86.c)? Maybe for KVM is acting more like 
a separate driver, and using printk is easier for separate debug? I really 
don't know...

> > +#ifndef CONFIG_X86_64
> > +#define mod_64(x, y) ((x) - (y) * div64_64(x, y))
> > +#else
> > +#define mod_64(x, y) ((x) % (y))
> > +#endif
> >
> > +/* Compute with 96 bit intermediate result: (a*b)/c */
> > +static u64 muldiv64(u64 a, u32 b, u32 c)
> > +{
> > +	union {
> > +		u64 ll;
> > +		struct {
> > +			u32 low, high;
> > +		} l;
> > +	} u, res;
> > +	u64 rl, rh;
> > +
> > +	u.ll = a;
> > +	rl = (u64)u.l.low * (u64)b;
> > +	rh = (u64)u.l.high * (u64)b;
> > +	rh += (rl >> 32);
> > +	res.l.high = div64_64(rh, c);
> > +	res.l.low = div64_64(((mod_64(rh, c) << 32) + (rl & 0xffffffff)), c);
> > +	return res.ll;
> > +}
>
> eventually these should move into a generic file, for example
> lib/div64.c.

That's my hope (of course with big endian support). But is there any user 
outside KVM? I think it may not easy to get into the generic part. 

> > +	ASSERT(mutex_is_locked(&kvm->arch.vpit->pit_state.lock));
>
> could we please standardize on WARN_ON(!(x)) instead?

Sure. :)

> > +static enum hrtimer_restart pit_timer_fn(struct hrtimer *data)
> > +{
> > +	struct kvm_kpit_state *ps;
> > +	int restart_timer = 0;
> > +
> > +	ps = container_of(data, struct kvm_kpit_state, pit_timer.timer);
> > +
> > +	restart_timer = __pit_timer_fn(ps);
> > +
> > +	if (restart_timer)
> > +		return HRTIMER_RESTART;
> > +	else
> > +		return HRTIMER_NORESTART;
> > +}
>
> elegant use of hrtimers! :-)
>
> > +	if (val == 0)
> > +		val = 0x10000;
>
> magic constant.
>
> > +	val  &= 0xff;
> > +	addr &= 3;
>
> magic constants.

I will update these constants. :) In fact, I have thought of these before, but 
not insist... 

Thanks!

Yang, Sheng
>
> 	Ingo

-------------------------------------------------------------------------
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/

  reply	other threads:[~2008-03-05 11:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-04 10:22 [PATCH 1/6] KVM: In kernel pit model Yang, Sheng
2008-03-05  6:54 ` Avi Kivity
2008-03-05  7:04   ` Yang, Sheng
2008-03-05  9:15     ` Ingo Molnar
2008-03-05 11:35       ` Yang, Sheng [this message]
2008-03-05 11:43         ` Avi Kivity
2008-03-05 12:24         ` Ingo Molnar
2008-03-06  7:56         ` Yang, Sheng
2008-03-06  8:06           ` Avi Kivity
2008-03-06  8:43             ` Yang, Sheng
2008-03-06  9:41               ` Yang, Sheng
2008-03-07  8:12                 ` Yang, Sheng
2008-03-07  8:53                   ` Avi Kivity
2008-03-07  9:14                     ` Yang, Sheng
2008-03-07  9:57                       ` Avi Kivity
2008-03-06  9:14           ` Ingo Molnar
2008-03-06  9:25             ` Yang, Sheng
2008-03-06 12:33               ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2008-03-07 12:52 [PATCH 1/6] KVM: In kernel PIT model Yang, Sheng

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=200803051935.40229.sheng.yang@intel.com \
    --to=sheng.yang@intel.com \
    --cc=avi@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=mingo@elte.hu \
    /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.