From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161005AbcFOMRQ (ORCPT ); Wed, 15 Jun 2016 08:17:16 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34220 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753107AbcFOMRO (ORCPT ); Wed, 15 Jun 2016 08:17:14 -0400 Subject: Re: [PATCH] pvclock: introduce seqcount-like API To: Andy Lutomirski References: <1465471403-49372-1-git-send-email-pbonzini@redhat.com> <20160609124317.GC2570@rkaganb.sw.ru> <20160609133529.GA5400@rkaganb.sw.ru> <8c422861-ab1e-ccdc-70e4-8517416e93f4@redhat.com> <3bfffd0d-bb91-d9e3-b67b-a82be9cb82d7@redhat.com> Cc: Roman Kagan , "linux-kernel@vger.kernel.org" , kvm list , Minfei Huang , Andrew Lutomirski From: Paolo Bonzini Message-ID: Date: Wed, 15 Jun 2016 14:17:09 +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: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/06/2016 20:08, Andy Lutomirski wrote: > > __pvclock_read_cycles is pretty much the same as the code that is being > > inlined. Thus the only change is that __pvclock_read_cycles is called > > inside the loop rather than outside, but the loop really is expected to > > never roll so why make a copy in the first place? > > I feel like I had a reason, but I don't remember what it was. I cannot see any substantial difference in the generated code with this patch. On the other hand, if I add this: diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h index 0ee92db1e9f3..d019f0cc80ec 100644 --- a/arch/x86/include/asm/pvclock.h +++ b/arch/x86/include/asm/pvclock.h @@ -40,7 +40,7 @@ bool pvclock_read_retry(const struct pvclock_vcpu_time_info *src, { /* Make sure that the version is re-read after the data. */ virt_rmb(); - return version != src->version; + return unlikely(version != src->version); } /* then vread_pvclock is inlined everywhere, which bloats the code somewhat (+80 code bytes). Do you want me to mark vread_pvclock as noinline too? Paolo