From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753083AbdEFQ3N (ORCPT ); Sat, 6 May 2017 12:29:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44606 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752000AbdEFQ3F (ORCPT ); Sat, 6 May 2017 12:29:05 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B17C83DFCD Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=jonmasters.org Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=jcm@jonmasters.org DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B17C83DFCD Subject: Re: [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday. To: Andrew Pinski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <1492991221-5156-1-git-send-email-apinski@cavium.com> <1492991221-5156-2-git-send-email-apinski@cavium.com> From: Jon Masters Organization: World Organi{s,z}ation of Broken Dreams Message-ID: <7ac07a75-ec3b-d05e-061c-5efab751ae2b@jonmasters.org> Date: Sat, 6 May 2017 12:29:03 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <1492991221-5156-2-git-send-email-apinski@cavium.com> 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]); Sat, 06 May 2017 16:29:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/23/2017 07:47 PM, Andrew Pinski wrote: > ISB is normally required before mrs CNTVCT if we want the > mrs to completed after the loads. In this case it is not. > As we are taking the difference and if that difference > was going to be negative, we just use the last counter value > instead. > > Signed-off-by: Andrew Pinski Humor me. Walk me through this? > --- > arch/arm64/kernel/vdso/gettimeofday.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/vdso/gettimeofday.c b/arch/arm64/kernel/vdso/gettimeofday.c > index a0ab8b1..cf3235a 100644 > --- a/arch/arm64/kernel/vdso/gettimeofday.c > +++ b/arch/arm64/kernel/vdso/gettimeofday.c > @@ -117,10 +117,20 @@ static notrace u64 get_clock_shifted_nsec(u64 cycle_last, u64 mult) > u64 res; > > /* Read the virtual counter. */ > - isb(); > + /* > + * This normally requires an ISB but since we know the > + * read of the last cycle will always be after the > + * read of the values are valid word. > + */ > asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory"); > > - res = res - cycle_last; > + /* > + * If the current cycle is greater than the last, > + * then get the difference. > + */ > + if (res > cycle_last) > + res = res - cycle_last; > + > /* We can only guarantee 56 bits of precision. */ > res &= ~(0xff00ul<<48); > return res * mult; > -- Computer Architect