From: "Jan Beulich" Subject: Re: [PATCH v2 3/3] x86/viridian: Add partition time reference counter MSR support Date: Mon, 04 Aug 2014 15:01:12 +0100 Message-ID: <53DFAE4802000078000290F1@mail.emea.novell.com> References: <1407157961-7239-1-git-send-email-paul.durrant@citrix.com> <1407157961-7239-4-git-send-email-paul.durrant@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1407157961-7239-4-git-send-email-paul.durrant@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Paul Durrant Cc: Keir Fraser , xen-devel@lists.xen.org, IanJackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org >>> On 04.08.14 at 15:12, wrote: > +static s_time_t get_time_ref_count(struct domain *d) > +{ > + s_time_t now = get_s_time() / 100; > + struct viridian_time_ref_count *trc; > + > + trc = &d->arch.hvm_domain.viridian.time_ref_count; > + > + spin_lock(&trc->lock); How well do you think this will scale, taking into consideration our recent observations with certain Windows versions having all its CPUs race for time stamps over apparently extended periods of time? It would seem to me that a cmpxchg() based approach might be preferable here. > + > + if ( trc->last == 0 ) > + gdprintk(XENLOG_G_INFO, "TIME_REFERENCE_COUNTER accessed\n"); As per the comments on patch 2, this needs to be either printk() or the _G_ in the middle converted to just _. > + > + if ( (now - trc->last) > 0 ) > + trc->last = now; > + else > + now = ++trc->last; And how well is that going to work (and match Windows' expectations) when the migration destination host's NOW() is significantly smaller than the source host's? > @@ -344,6 +383,14 @@ int rdmsr_viridian_regs(uint32_t idx, uint64_t *val) > *val = v->arch.hvm_vcpu.viridian.apic_assist.raw; > break; > > + case VIRIDIAN_MSR_TIME_REF_COUNT: > + if ( !(viridian_feature_mask(d) & HVMPV_time_ref_count) ) > + return 0; > + > + perfc_incr(mshv_rdmsr_time_ref_count); > + *val = (uint64_t)get_time_ref_count(d); Pointless cast. Jan