Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4179274ybl; Mon, 13 Jan 2020 09:10:20 -0800 (PST) X-Google-Smtp-Source: APXvYqxsoA892pLbOtR6k2+beZWnWlvEPJt/Sjh42Ei/wRcTCWio6xgBC3rykdKfmI/MtXFaeOO/ X-Received: by 2002:aca:f2c5:: with SMTP id q188mr13781738oih.113.1578935420761; Mon, 13 Jan 2020 09:10:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578935420; cv=none; d=google.com; s=arc-20160816; b=WS+YaJT+l1c+My6UFx5DPw2GpPHkHrlF+gP1VMlc73tI5OTmV7AWGLws/UtMisDNVy gs9pOnL9nLHTsVHx7SXLVjf3+p5TMpgqmv37PFAOWmiUffqud9fNSc3NqPR9cQsflZeN 63Y2RycdwnIiamGOGcVxrOQSlXqs3HZwt9Go093Y49uSW7IPFd11LWhqKxJifY5KY+gP 2oVAkzTXyn5gDiUeXcrV1mZ34EQ5/fRup8UjqrrT+ny4+sS1+vEh7fdTWPezXWSRwmhk DI+0bcihJe3Fl5NKXjDKQ397JcOtxsDwmFBwWPO6dP1zXeAjpVNFYA6Tr6DEGn2WjWkg oU6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=9JszdThPZcrKbLGagNxNFoOFX49AMCE1MJAxuQq15/c=; b=AlmzhRPX/Uwlfz0qXYeetBsHRGrCrfHmupF7UsdZgSBbaIkRMaaTlcytsSDAJXZoG5 Ey4foHEiJgFiVZE1GhJ4bIoDfkVH0NC/QZxC26pyMmvOpiXJyT7q4whbvOnzye9Z8bfM LhT6CQj2sZL3EJLGjz10BfF3bR51pna8t2wZYTmwu+K6LDRgMNUQI5Aogs1lTTaJhpeu bopeJ9i5YCafSjWFnKJRZOpK+DDa433nOOA63Bk+mj7xCDvxTJmnO6hlMgdxiZuLzvw+ OWGHk7azP6sThdNFQEl07XbTSmR+hS8QX1BkWaOSi0pWsmQMAlv3vhDoOuuk0iHrX21U Pdyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=smBvGj76; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m18si7000760otq.72.2020.01.13.09.10.07; Mon, 13 Jan 2020 09:10:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=smBvGj76; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728897AbgAMRI6 (ORCPT + 99 others); Mon, 13 Jan 2020 12:08:58 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:1604 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728863AbgAMRIx (ORCPT ); Mon, 13 Jan 2020 12:08:53 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 47xKmt35Q3z9v0Y1; Mon, 13 Jan 2020 18:08:46 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=smBvGj76; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id yShFRHkN_wHb; Mon, 13 Jan 2020 18:08:46 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 47xKmt1vdMz9v0Xy; Mon, 13 Jan 2020 18:08:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1578935326; bh=9JszdThPZcrKbLGagNxNFoOFX49AMCE1MJAxuQq15/c=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=smBvGj76nnUT7O2Nerwb6Dkjq6/LDayrszAQt4gYAGJB+rfKJvztU7Yk9aCxFTZM9 YMw56Fdhnx91BJpdaXwcfImT1m2o4G7CLGwE1sCAphGj+SbPcBphYgtegj1EIJY5cm fTnCa3CWZa3EDb6DBUiihGDdLzpRHC+HBoneX+9c= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6542F8B7C9; Mon, 13 Jan 2020 18:08:51 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id F_EW3T2xMF7m; Mon, 13 Jan 2020 18:08:51 +0100 (CET) Received: from po14934vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 231D38B7BE; Mon, 13 Jan 2020 18:08:51 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 0) id EBBBC64A1D; Mon, 13 Jan 2020 17:08:50 +0000 (UTC) Message-Id: <980b880ed9a86342e05cee18e1b2ce66fbe92d4c.1578934751.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [RFC PATCH v3 12/12] powerpc/vdso: provide __arch_is_hw_counter_valid() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , arnd@arndb.de, tglx@linutronix.de, vincenzo.frascino@arm.com, luto@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, x86@kernel.org Date: Mon, 13 Jan 2020 17:08:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To avoid a double verification of the hw_counter validity, provide __arch_is_hw_counter_valid() Before: clock-gettime-realtime: vdso: 1078 nsec/call After: clock-gettime-realtime: vdso: 1064 nsec/call The * shows the test of the clock type. The > shows the additional test on the counter, that goes away with this patch Before: 5e0: 81 25 00 04 lwz r9,4(r5) *5e4: 2f 89 00 00 cmpwi cr7,r9,0 *5e8: 40 9e 01 3c bne cr7,724 <__c_kernel_clock_gettime+0x17c> 5ec: 94 21 ff e0 stwu r1,-32(r1) 5f0: 93 61 00 0c stw r27,12(r1) 5f4: 93 81 00 10 stw r28,16(r1) 5f8: 93 a1 00 14 stw r29,20(r1) 5fc: 93 c1 00 18 stw r30,24(r1) 600: 93 e1 00 1c stw r31,28(r1) 604: 7d 8d 42 e6 mftbu r12 608: 7f ac 42 e6 mftb r29 60c: 7c cd 42 e6 mftbu r6 610: 7f 8c 30 40 cmplw cr7,r12,r6 614: 40 9e ff f0 bne cr7,604 <__c_kernel_clock_gettime+0x5c> >618: 2f 8c 00 00 cmpwi cr7,r12,0 61c: 83 6b 00 28 lwz r27,40(r11) 620: 83 8b 00 2c lwz r28,44(r11) 624: 81 45 00 08 lwz r10,8(r5) 628: 80 e5 00 0c lwz r7,12(r5) >62c: 41 9c 00 b4 blt cr7,6e0 <__c_kernel_clock_gettime+0x138> 630: 81 05 00 18 lwz r8,24(r5) 634: 83 c5 00 1c lwz r30,28(r5) 638: 80 cb 00 24 lwz r6,36(r11) 63c: 83 e5 00 00 lwz r31,0(r5) 640: 7f 9f 00 40 cmplw cr7,r31,r0 644: 40 9e 00 84 bne cr7,6c8 <__c_kernel_clock_gettime+0x120> After: 5e0: 81 25 00 04 lwz r9,4(r5) *5e4: 2f 89 00 00 cmpwi cr7,r9,0 *5e8: 40 9e 01 88 bne cr7,770 <__c_kernel_clock_gettime+0x1c8> 5ec: 94 21 ff e0 stwu r1,-32(r1) 5f0: 93 61 00 0c stw r27,12(r1) 5f4: 93 81 00 10 stw r28,16(r1) 5f8: 93 a1 00 14 stw r29,20(r1) 5fc: 93 c1 00 18 stw r30,24(r1) 600: 93 e1 00 1c stw r31,28(r1) 604: 7f cd 42 e6 mftbu r30 608: 7f ac 42 e6 mftb r29 60c: 7c cd 42 e6 mftbu r6 610: 7f 9e 30 40 cmplw cr7,r30,r6 614: 40 9e ff f0 bne cr7,604 <__c_kernel_clock_gettime+0x5c> 618: 83 6b 00 28 lwz r27,40(r11) 61c: 83 8b 00 2c lwz r28,44(r11) 620: 81 45 00 08 lwz r10,8(r5) 624: 80 e5 00 0c lwz r7,12(r5) 628: 81 05 00 18 lwz r8,24(r5) 62c: 83 e5 00 1c lwz r31,28(r5) 630: 80 cb 00 24 lwz r6,36(r11) 634: 81 85 00 00 lwz r12,0(r5) 638: 7f 8c 00 40 cmplw cr7,r12,r0 63c: 40 9e 00 84 bne cr7,6c0 <__c_kernel_clock_gettime+0x118> Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/vdso/gettimeofday.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/vdso/gettimeofday.h b/arch/powerpc/include/asm/vdso/gettimeofday.h index d1e702e0ea86..c5a24f31382e 100644 --- a/arch/powerpc/include/asm/vdso/gettimeofday.h +++ b/arch/powerpc/include/asm/vdso/gettimeofday.h @@ -69,15 +69,18 @@ int clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts) } #endif -static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) +static __always_inline bool __arch_is_hw_counter_valid(s32 clock_mode) { /* * clock_mode == 0 implies that vDSO are enabled otherwise * fallback on syscall. */ - if (clock_mode != 0) - return U64_MAX; + return clock_mode == 0 ? true : false; +} +#define __arch_is_hw_counter_valid __arch_is_hw_counter_valid +static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) +{ return get_tb(); } -- 2.13.3