From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/6] KVM: In kernel pit model Date: Wed, 05 Mar 2008 08:54:06 +0200 Message-ID: <47CE438E.2090408@qumranet.com> References: <200803041822.44757.sheng.yang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel@lists.sourceforge.net To: "Yang, Sheng" Return-path: In-Reply-To: <200803041822.44757.sheng.yang@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org Yang, Sheng wrote: > + > +static int pit_get_out(struct kvm *kvm, int channel) > +{ > + struct kvm_kpit_channel_state *c = > + &kvm->arch.vpit->pit_state.channels[channel]; > + s64 d, t; > + int out; > + > + 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); > NSECS_PER_SEC to avoid people jumping on you saying you can't use floating point in the kernel (yes, the compiler converts it at compile-time, but they'll still say it). -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ------------------------------------------------------------------------- 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/