Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp884824imm; Wed, 4 Jul 2018 07:36:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfWmRgDRKZl8b2yijoFcp7PszL9YQ2NDBbO6hjx2yf7nSbMBCFteixeMC8D0OQOzikTACBn X-Received: by 2002:a65:45cc:: with SMTP id m12-v6mr2186176pgr.160.1530715007270; Wed, 04 Jul 2018 07:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530715007; cv=none; d=google.com; s=arc-20160816; b=KLHFKlE91fCOt5/J0w9+wczRKcDd0sr95YX5TuU+3F+l5+kvMsfwYi4N7OzotQ2r6B Htw4YSUQO9Qv3v+rKDfi2cZnt4kz28KDsI9hJK9iED3ymuUgZenlhd84kXrH1MNillRE WS9WiO09PK8mqoXw18+PGAsfvgCuoJkVMCNxMtG8azR2sz/mKooNfV3kqxo+Sh+7jx38 u50Y5J/HOJwxb/Jdn18k64wXM3LxAJ38gAbDLEDUtgaQl2eps55tAVczR4hTLZKb7lhn YqMiD2UURfBCgxKf9eul441cREm8ApX3BC65/EMhzxYJT5VzQRNmgN/IBf7HdTaSFam6 sM0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=MtWXu1QqvM8ucnLotmZ14T2CXEyGSFgNQfaBLXdGUIU=; b=UMW8stqWO1BaylFhwh4vvwDm4VkBQIYb6Vgw687SE9lWMm1He9YIGE5N9t0lf44+sL LuadNEwg5/oCtXhi+MFXZwCBf+h8+iNffdBuXdOcMJq89bxI54+24TTsKSYrSBHqPznn D9AoqN+e+tGeaEPySuKn41xZwefgvOyguxC1iS3K+yHkzKQpci8s0pTfPaya7kiu3YqI kFQWDwPjw5p4cGLHFrUOAW/PKVf7p6hWmcMsFMW6LgZhSZrPQzCAOhtnTn8XLLABVbfK 1ry33k4bTYdLEgvlMXPlKDwmSbzE2VRfpcxbvoH0xgrXZ4by6+TSVcY7en7Rh5RRlOT2 mBbA== ARC-Authentication-Results: i=1; mx.google.com; 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 o61-v6si3650517pld.109.2018.07.04.07.36.33; Wed, 04 Jul 2018 07:36:47 -0700 (PDT) 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; 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 S1752755AbeGDOft (ORCPT + 99 others); Wed, 4 Jul 2018 10:35:49 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:47794 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750855AbeGDOfr (ORCPT ); Wed, 4 Jul 2018 10:35:47 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1faisi-0000FP-7g; Wed, 04 Jul 2018 16:35:44 +0200 Date: Wed, 4 Jul 2018 16:35:43 +0200 (CEST) From: Thomas Gleixner To: Guo Ren cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org, jason@lakedaemon.net, arnd@arndb.de, c-sky_gcc_upstream@c-sky.com, gnu-csky@mentor.com, thomas.petazzoni@bootlin.com, wbx@uclibc-ng.org, green.hu@gmail.com Subject: Re: [PATCH V2 18/19] clocksource: add C-SKY clocksource drivers In-Reply-To: <20180704104957.GB23536@guoren> Message-ID: References: <20180704104957.GB23536@guoren> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 4 Jul 2018, Guo Ren wrote: > On Tue, Jul 03, 2018 at 11:39:05AM +0200, Thomas Gleixner wrote: > > > +static inline u64 get_ccvr(void) > > > +{ > > > + u32 lo, hi, t; > > > + > > > + do { > > > + hi = mfcr(PTIM_CCVR_HI); > > > + lo = mfcr(PTIM_CCVR_LO); > > > + t = mfcr(PTIM_CCVR_HI); > > > + } while(t != hi); > > > > No idea which frequency this timer ticks at, but if the 32 bit wrap does > > not come too fast, then you really should avoid that loop. That function is > > called very frequently. > > 0000006c : > hi = mfcr(PTIM_CCVR_HI); > 6c: c1c26023 mfcr r3, cr<2, 14> > lo = mfcr(PTIM_CCVR_LO); > 70: c1c36021 mfcr r1, cr<3, 14> > t = mfcr(PTIM_CCVR_HI); > 74: c1c26022 mfcr r2, cr<2, 14> > } while(t != hi); > 78: 648e cmpne r3, r2 > 7a: 0bf9 bt 0x6c // 6c > > When two read cr<2, 14> is not equal, we'll retry. So only when > CCVR_LO is at 0xffffffff between the two read of CCVR_HI. That's very > very small probability event for "bt 0x6c". > > Don't worry about the "do {...} whie(t != hi)", it's no performance issue. But _three_ mfcr plus a conditional jump which _cannot_ be predicted are a performance issue. When you can replace that with a single mfcr, then you win a lot, really. The time keeping and the sched clock code can handle that nicely unless you really have fast wrap arounds on the LO word. Thanks, tglx