From patchwork Sat Oct 31 10:20:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 7530661 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1DC6DBEEA4 for ; Sat, 31 Oct 2015 10:24:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 152B7206E4 for ; Sat, 31 Oct 2015 10:24:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 390742058C for ; Sat, 31 Oct 2015 10:24:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZsTJ5-00046T-1i; Sat, 31 Oct 2015 10:22:43 +0000 Received: from szxga02-in.huawei.com ([119.145.14.65]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZsTIr-0003oX-Dv for linux-arm-kernel@lists.infradead.org; Sat, 31 Oct 2015 10:22:31 +0000 Received: from 172.24.1.49 (EHLO lggeml429-hub.china.huawei.com) ([172.24.1.49]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CVK81708; Sat, 31 Oct 2015 18:21:02 +0800 (CST) Received: from [127.0.0.1] (10.177.19.219) by lggeml429-hub.china.huawei.com (10.72.61.81) with Microsoft SMTP Server id 14.3.235.1; Sat, 31 Oct 2015 18:20:55 +0800 Subject: [PATCH resend] clocksource: modify the cycle_last validation to fit for non-64bit clocksourece mask To: Thomas Gleixner References: <1445952073-7260-1-git-send-email-yangyingliang@huawei.com> <1445952073-7260-2-git-send-email-yangyingliang@huawei.com> From: Yang Yingliang Message-ID: <56349607.6070708@huawei.com> Date: Sat, 31 Oct 2015 18:20:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.177.19.219] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151031_032229_873275_BDF25338 X-CRM114-Status: UNSURE ( 9.70 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.2 (-----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 From: Yang Yingliang Check the delta of now and last to make sure it's not negative while the clocksource mask is not 64-bits. Suggested-by: Thomas Gleixner Signed-off-by: Yang Yingliang --- kernel/time/timekeeping_internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) #else static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask) diff --git a/kernel/time/timekeeping_internal.h b/kernel/time/timekeeping_internal.h index 4ea005a..cbfcd2d 100644 --- a/kernel/time/timekeeping_internal.h +++ b/kernel/time/timekeeping_internal.h @@ -16,8 +16,9 @@ extern void tk_debug_account_sleep_time(struct timespec64 *t); static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask) { cycle_t ret = (now - last) & mask; + cycle_t negative = ret & ~(mask >> 1); - return (s64) ret > 0 ? ret : 0; + return negative ? 0 : ret; }