Return-Path: Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:27990 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751265AbbHBPuF (ORCPT ); Sun, 2 Aug 2015 11:50:05 -0400 Date: Sun, 2 Aug 2015 08:49:49 -0700 From: Shaohua Li To: Thomas Gleixner CC: , , , Suresh Siddha , "H. Peter Anvin" , Ingo Molnar , Subject: Re: [PATCH] x86: serialize LVTT and TSC_DEADLINE write Message-ID: <20150802154948.GA1432307@devbig257.prn2.facebook.com> References: <75ed9226b028a31e37861fbba51cdffbcfe04eda.1438300532.git.shli@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: On Sat, Aug 01, 2015 at 12:10:41PM +0200, Thomas Gleixner wrote: > On Fri, 31 Jul 2015, Shaohua Li wrote: > > @@ -336,6 +336,22 @@ static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen) > > apic_write(APIC_LVTT, lvtt_value); > > > > if (lvtt_value & APIC_LVT_TIMER_TSCDEADLINE) { > > + u64 msr; > > + > > + /* > > + * See Intel SDM: TSC-Deadline Mode chapter. In xAPIC mode, > > + * writing APIC LVTT and TSC_DEADLINE MSR isn't serialized. > > + * This uses the algorithm described in Intel SDM to serialize > > + * the two writes > > + * */ > > + while (1) { > > + wrmsrl(MSR_IA32_TSC_DEADLINE, -1L); > > + rdmsrl(MSR_IA32_TSC_DEADLINE, msr); > > + if (msr) > > + break; > > + } > > + wrmsrl(MSR_IA32_TSC_DEADLINE, 0); > > > I think this is exceptionally silly. A proper fence after the > apic_write() should have the same effect. Not sure what happens in the hardware, I could have a try of fence, but I'd prefer using the algorithm Intel described. This is not a fast path, the loop will exit immediately regardless the issue occurs anyway. Thanks, Shaohua