From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750917AbcFIM1G (ORCPT ); Thu, 9 Jun 2016 08:27:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35796 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750947AbcFIM1E (ORCPT ); Thu, 9 Jun 2016 08:27:04 -0400 Subject: Re: [PATCH 3/3 V2] pvclock: Get rid of __pvclock_read_cycles in function pvclock_read_flags To: Peter Zijlstra , Minfei Huang References: <1464329832-4638-3-git-send-email-mnghuan@gmail.com> <1464438463-8485-1-git-send-email-mnghuan@gmail.com> <20160609121603.GB30935@twins.programming.kicks-ass.net> Cc: bp@suse.de, luto@kernel.org, hpa@zytor.com, mingo@redhat.com, tglx@linutronix.de, x86@kernel.org, linux-kernel@vger.kernel.org From: Paolo Bonzini Message-ID: <685113ad-c337-8207-89f6-1a0b475c44fb@redhat.com> Date: Thu, 9 Jun 2016 14:26:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <20160609121603.GB30935@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 09 Jun 2016 12:27:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/06/2016 14:16, Peter Zijlstra wrote: > On Sat, May 28, 2016 at 08:27:43PM +0800, Minfei Huang wrote: >> +++ b/arch/x86/kernel/pvclock.c >> @@ -61,11 +61,14 @@ void pvclock_resume(void) >> u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src) >> { >> unsigned version; >> - cycle_t ret; >> u8 flags; >> >> do { >> - version = __pvclock_read_cycles(src, &ret, &flags); >> + version = src->version; >> + /* Make the latest version visible */ >> + smp_rmb(); >> + >> + flags = src->flags; > > Using a seqcount to load a single byte is insane ;-) Only if you know that the writer will not write that byte twice within a critical section... Which I guess we do know in this case because the write side is just a memcpy, but it's still a bit safer when it's not specified by the pvclock API. It's not a fast path anyway, it runs literally twice at startup. Paolo