From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752818AbbFMJCS (ORCPT ); Sat, 13 Jun 2015 05:02:18 -0400 Received: from cantor2.suse.de ([195.135.220.15]:46782 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751406AbbFMJCO (ORCPT ); Sat, 13 Jun 2015 05:02:14 -0400 Date: Sat, 13 Jun 2015 11:02:11 +0200 From: Borislav Petkov To: Andy Lutomirski Cc: x86@kernel.org, Peter Zijlstra , John Stultz , linux-kernel@vger.kernel.org, Len Brown , Huang Rui , Denys Vlasenko Subject: Re: [PATCH v2 15/17] x86: Add rdtsc_ordered() and use it in trivial call sites Message-ID: <20150613090211.GC3796@pd.tnic> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 12, 2015 at 04:44:55PM -0700, Andy Lutomirski wrote: > barrier_before_rdtsc(); rdtsc_unordered() is an unnecessary mouthful and > requires more thought than should be necessary. Add an rdtsc_ordered() > helper and replace the trivial call sites with it. > > This should not change generated code. > > Signed-off-by: Andy Lutomirski > --- ... > diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h > index a47fb11af5f5..22d69d2d1f0d 100644 > --- a/arch/x86/include/asm/msr.h > +++ b/arch/x86/include/asm/msr.h > @@ -148,6 +148,20 @@ static __always_inline void barrier_before_rdtsc(void) > "lfence", X86_FEATURE_LFENCE_RDTSC); > } > > +/** > + * rdtsc_ordered() - read the current TSC in program order > + * > + * rdtsc_ordered() returns the result of RDTSC as a 64-bit integer. > + * It is ordered like a load to a global in-memory counter. It should > + * be impossible to observe non-monotonic rdtsc_unordered() behavior > + * across multiple CPUs as long as the TSC is synced. > + */ > +static __always_inline unsigned long long rdtsc_ordered(void) > +{ > + barrier_before_rdtsc(); > + return rdtsc_unordered(); > +} > + I don't see the final tree state with all those applied (too lazy to apply them) but why not simply kill barrier_before_rdtsc() and inline the alternative into rdtsc_ordered()? I mean, I don't see usage for it somewhere else... -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --