From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/3] kvmclock - the host part. Date: Tue, 13 Nov 2007 18:12:51 +0200 Message-ID: <4739CD03.90406@qumranet.com> References: <11945615632624-git-send-email-gcosta@redhat.com><11945615703593-git-send-email-gcosta@redhat.com> <11945615751747-git-send-email-gcosta@redhat.com> <10EA09EFD8728347A513008B6B0DA77A025DF8A2@pdsmsx411.ccr.corp.intel.com> <4739906B.2080103@redhat.com> <4739B916.4000405@qumranet.com> <10EA09EFD8728347A513008B6B0DA77A025DFB75@pdsmsx411.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, jeremy-TSDbQ3PG+2Y@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org, Glauber de Oliveira Costa To: "Dong, Eddie" Return-path: In-Reply-To: <10EA09EFD8728347A513008B6B0DA77A025DFB75-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org Dong, Eddie wrote: >>> >>> After thinking for a little while, you are theoretically right. >>> In the current state, we could even be preempted between all >>> operations ;-) Maybe after avi's suggestion of moving the call to it >>> it will end up in a preempt safe region, but anyway, it's safer to >>> add the preempt markers here. I'll put it in next version, thanks >>> >>> >>> >> Well, you can't kvm_write_guest() with preemption enabled. >> >> preempt notifiers to the rescue! We have a callout during preemption, >> so you can just zero out a flag there, and when we're scheduled again >> retry the whole thing. >> >> > > The preemption issue is within following code which need to be done in a > short enough period. > > + kvm_get_msr(vcpu, MSR_IA32_TIME_STAMP_COUNTER, > + &vcpu->hv_clock.last_tsc); > + > + ktime_get_ts(&ts); > + vcpu->hv_clock.now_ns = ts.tv_nsec + (NSEC_PER_SEC * > (u64)ts.tv_sec); > + vcpu->hv_clock.wc_sec = get_seconds(); > > I am even thinking we have to disable interrupt between these lines, > otherwise > guest wall clock may see backward time source when calculating the > delta TSC since last vcpu->hv_clock.now_ns update. > That's true. While we do need to handle vcpu migration and descheduling, the code sequence you note needs to be as atomic as possible. -- error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/