From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751677AbcFIMsA (ORCPT ); Thu, 9 Jun 2016 08:48:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60895 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011AbcFIMr6 (ORCPT ); Thu, 9 Jun 2016 08:47:58 -0400 Subject: Re: [PATCH] pvclock: introduce seqcount-like API To: Roman Kagan , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, mnghuan@gmail.com, luto@kernel.org References: <1465471403-49372-1-git-send-email-pbonzini@redhat.com> <20160609124317.GC2570@rkaganb.sw.ru> From: Paolo Bonzini Message-ID: Date: Thu, 9 Jun 2016 14:47:54 +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: <20160609124317.GC2570@rkaganb.sw.ru> 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.32]); Thu, 09 Jun 2016 12:47:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/06/2016 14:43, Roman Kagan wrote: > On Thu, Jun 09, 2016 at 01:23:23PM +0200, Paolo Bonzini wrote: >> The version field in struct pvclock_vcpu_time_info basically implements >> a seqcount. Wrap it with the usual read_begin and read_retry functions, >> and use these APIs instead of peppering the code with smp_rmb()s. >> While at it, change it to the more pedantically correct virt_rmb(). >> >> With this change, __pvclock_read_cycles can be simplified noticeably. >> >> Signed-off-by: Paolo Bonzini >> --- >> arch/x86/entry/vdso/vclock_gettime.c | 25 +++++------------------ >> arch/x86/include/asm/pvclock.h | 39 +++++++++++++++++++++--------------- >> arch/x86/kernel/pvclock.c | 17 ++++++---------- >> 3 files changed, 34 insertions(+), 47 deletions(-) > [...] >> --- a/arch/x86/include/asm/pvclock.h >> +++ b/arch/x86/include/asm/pvclock.h > [...] >> @@ -69,23 +87,12 @@ static inline u64 pvclock_scale_delta(u64 delta, u32 mul_frac, int shift) >> } >> >> static __always_inline >> -unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src, >> - cycle_t *cycles, u8 *flags) >> +cycle_t __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src) >> { >> - unsigned version; >> - cycle_t offset; >> - u64 delta; >> - >> - version = src->version; >> - /* Make the latest version visible */ >> - smp_rmb(); > > This is on top of Minfei's patch, right? It isn't in Linus' tree yet so > I wonder if it makes sense to merge the two patches into one. > > Will you post it to stable, too? Not this one, because Minfei's patch is enough to fix the bug, but I do plan on including it in 4.7 to simplify the merging (kvm/next has already been branched off Linus's tree). Paolo > Anyway > > Reviewed-by: Roman Kagan > > Roman. >