From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752668AbcFLKZT (ORCPT ); Sun, 12 Jun 2016 06:25:19 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:36038 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751117AbcFLKZQ (ORCPT ); Sun, 12 Jun 2016 06:25:16 -0400 Date: Sun, 12 Jun 2016 18:25:12 +0800 From: Minfei Huang To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, luto@kernel.org, rkagan@virtuozzo.com Subject: Re: [PATCH] pvclock: introduce seqcount-like API Message-ID: <20160612102446.GB22854@localhost> References: <1465471403-49372-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1465471403-49372-1-git-send-email-pbonzini@redhat.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/09/16 at 01:23P, 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. Hi, Paolo. Thanks for accepting my patches in your repo. > > 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(-) > > diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h > index 7c1c89598688..0ee92db1e9f3 100644 > --- a/arch/x86/include/asm/pvclock.h > +++ b/arch/x86/include/asm/pvclock.h > @@ -25,6 +25,24 @@ void pvclock_resume(void); > > void pvclock_touch_watchdogs(void); > > +static __always_inline > +unsigned pvclock_read_begin(const struct pvclock_vcpu_time_info *src) It's better to use type unsigned int, instead of unsigned which is complained by script checkpatch. Thanks Minfei > +{ > + unsigned version = src->version & ~1; Ditto. > + /* Make sure that the version is read before the data. */ > + virt_rmb(); > + return version; > +} > + > +static __always_inline > +bool pvclock_read_retry(const struct pvclock_vcpu_time_info *src, > + unsigned version) Ditto. Thanks Minfei