From patchwork Thu Apr 21 12:21:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8899971 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B78019F441 for ; Thu, 21 Apr 2016 12:21:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D6E88202EC for ; Thu, 21 Apr 2016 12:21:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F178320121 for ; Thu, 21 Apr 2016 12:21:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B3B26EC99; Thu, 21 Apr 2016 12:21:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) by gabe.freedesktop.org (Postfix) with ESMTPS id 692216EC99 for ; Thu, 21 Apr 2016 12:21:40 +0000 (UTC) Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue003) with ESMTPSA (Nemesis) id 0MfVBH-1b506K07Tv-00P6Lp; Thu, 21 Apr 2016 14:21:31 +0200 From: Arnd Bergmann To: Tina Ruchandani Subject: Re: [PATCH v2] drm/msm: Use 64-bit timekeeping Date: Thu, 21 Apr 2016 14:21:28 +0200 Message-ID: <4114093.bsncTYaCqE@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: <20160413095214.GA101605@localhost> MIME-Version: 1.0 X-Provags-ID: V03:K0:68Hhe/z5n7v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Reding X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thursday 21 April 2016 04:39:04 Tina Ruchandani wrote: > >> which only does one 64-bit division, and it's one that we can probably > >> optimize out in the future (we can check in ktime_ms_delta whether the > >> difference is more than 2^32 nanoseconds as the fast path). > > It looks like ktime_divns already has that optimization for 32-bit divisor, > so your solution should avoid the 64-bit division. I meant an optimization for a 32-bit dividend, not divisor, e.g. doing: I also just looked at the implementation of do_div() in include/asm-generic/div64.h, and it already does that for non-constant divisors, but I don't understand __div64_const32() enough to know if the compiler end up doing the same optimization for the constant divisor we have here. Arnd diff --git a/include/linux/ktime.h b/include/linux/ktime.h index 2b6a204bd8d4..4fbf735ec0af 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h @@ -169,13 +169,17 @@ static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2) extern s64 __ktime_divns(const ktime_t kt, s64 div); static inline s64 ktime_divns(const ktime_t kt, s64 div) { + s64 ns = kt.tv64; + /* * Negative divisors could cause an inf loop, * so bug out here. */ BUG_ON(div < 0); - if (__builtin_constant_p(div) && !(div >> 32)) { - s64 ns = kt.tv64; + + if ((ns >> 32) == 0) { + return (s32)ns / div; + else if (__builtin_constant_p(div) && !(div >> 32)) { u64 tmp = ns < 0 ? -ns : ns; do_div(tmp, div);