From: "Glauber Costa" Subject: Re: [PATCH 4/4] kvm/guest: fix paravirt clocksource to be compartible with xen. Date: Thu, 24 Apr 2008 10:16:40 -0300 Message-ID: <5d6222a80804240616x7344ac49t71f36fa45902b18c@mail.gmail.com> References: <1209026228-9113-1-git-send-email-kraxel@redhat.com> <1209026228-9113-2-git-send-email-kraxel@redhat.com> <1209026228-9113-3-git-send-email-kraxel@redhat.com> <1209026228-9113-4-git-send-email-kraxel@redhat.com> <1209026228-9113-5-git-send-email-kraxel@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel@lists.sourceforge.net To: "Gerd Hoffmann" Return-path: In-Reply-To: <1209026228-9113-5-git-send-email-kraxel@redhat.com> Content-Disposition: inline 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 > - > - delta = kvm_clock_read(); > - > native_write_msr(MSR_KVM_WALL_CLOCK, low, high); > - do { > - version = wall_clock.wc_version; > - rmb(); > - wc_sec = wall_clock.wc_sec; > - wc_nsec = wall_clock.wc_nsec; > - rmb(); > - } while ((wall_clock.wc_version != version) || (version & 1)); > - > - delta = kvm_clock_read() - delta; > - delta += wc_nsec; > - nsec = do_div(delta, NSEC_PER_SEC); > - set_normalized_timespec(&ts, wc_sec + delta, nsec); > - /* > - * Of all mechanisms of time adjustment I've tested, this one > - * was the champion! > - */ > - return ts.tv_sec + 1; > + > + vcpu_time = &get_cpu_var(hv_clock); > + pvclock_read_wallclock(&wall_clock, vcpu_time, &ts); > + put_cpu_var(hv_clock); > + > + return ts.tv_sec; > } Here it is. Despite some needed cleanups, patches look beautiful to me. -- Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act." ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone