From patchwork Tue Jun 11 07:41:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinya Kuribayashi X-Patchwork-Id: 2700321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 78D00DF23A for ; Tue, 11 Jun 2013 07:42:37 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UmJDt-0006j2-F6; Tue, 11 Jun 2013 07:42:33 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UmJDq-0005Bn-QU; Tue, 11 Jun 2013 07:42:30 +0000 Received: from relmlor3.renesas.com ([210.160.252.173]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UmJDn-0005BH-KB for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2013 07:42:29 +0000 Received: from relmlir2.idc.renesas.com ([10.200.68.152]) by relmlor3.idc.renesas.com ( SJSMS) with ESMTP id <0MO700KEZXDX2I80@relmlor3.idc.renesas.com> for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2013 16:41:57 +0900 (JST) Received: from relmlac3.idc.renesas.com ([10.200.69.23]) by relmlir2.idc.renesas.com ( SJSMS) with ESMTP id <0MO700KVAXDWDAC0@relmlir2.idc.renesas.com> for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2013 16:41:57 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 2E35F1809C; Tue, 11 Jun 2013 16:41:56 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id AAEE8180A7; Tue, 11 Jun 2013 16:41:56 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id SAA15478; Tue, 11 Jun 2013 16:41:56 +0900 X-IronPort-AV: E=Sophos; i="4.87,843,1363100400"; d="scan'208"; a="130169628" Received: from unknown (HELO [10.161.64.55]) ([10.161.64.55]) by relmlii1.idc.renesas.com with ESMTP; Tue, 11 Jun 2013 16:41:56 +0900 Message-id: <51B6D4C4.9080400@renesas.com> Date: Tue, 11 Jun 2013 16:41:56 +0900 From: Shinya Kuribayashi User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-version: 1.0 To: prarit@redhat.com, john.stultz@linaro.org Subject: hrtimer: one more expiry time overflow check in hrtimer_interrupt X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130611_034227_871115_136DD0A6 X-CRM114-Status: GOOD ( 11.68 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 HDRS_LCASE Odd capitalization of message header 0.0 T_MANY_HDRS_LCASE Odd capitalization of multiple message headers Cc: takashi.yoshii.zj@renesas.com, hiroyuki.yokoyama.vx@renesas.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When executing a date command to set the system date and time to a few seconds before the 2038 problem expiration time, we got a WARN_ON_ONCE() like this: root@renesas:~# date -s "2038-1-19 3:14:00" Tue Jan 19 03:14:00 GMT 2038 (then wait for 7-8 seconds) root@renesas:~# [ 27.662658] ------------[ cut here ]------------ [ 27.667297] WARNING: at kernel/time/clockevents.c:209 clockevents_program_event+0x3c/0x138() [ 27.675720] Modules linked in: [ 27.678802] [] (unwind_backtrace+0x0/0xe0) from [] (warn_slowpath_common+0x4c/0x64) [ 27.688201] [] (warn_slowpath_common+0x4c/0x64) from [] (warn_slowpath_null+0x18/0x1c) [ 27.697845] [] (warn_slowpath_null+0x18/0x1c) from [] (clockevents_program_event+0x3c/0x138) [ 27.708007] [] (clockevents_program_event+0x3c/0x138) from [] (tick_program_event+0x2c/0x34) [ 27.718170] [] (tick_program_event+0x2c/0x34) from [] (hrtimer_interrupt+0x268/0x2a8) [ 27.727752] [] (hrtimer_interrupt+0x268/0x2a8) from [] (cmt_timer_interrupt+0x2c/0x34) [ 27.737396] [] (cmt_timer_interrupt+0x2c/0x34) from [] (handle_irq_event_percpu+0xb0/0x2a8) [ 27.747467] [] (handle_irq_event_percpu+0xb0/0x2a8) from [] (handle_irq_event+0x58/0x74) [ 27.757293] [] (handle_irq_event+0x58/0x74) from [] (handle_fasteoi_irq+0xc0/0x148) [ 27.766662] [] (handle_fasteoi_irq+0xc0/0x148) from [] (generic_handle_irq+0x20/0x30) [ 27.776245] [] (generic_handle_irq+0x20/0x30) from [] (handle_IRQ+0x60/0x84) [ 27.785003] [] (handle_IRQ+0x60/0x84) from [] (gic_handle_irq+0x34/0x4c) [ 27.793426] [] (gic_handle_irq+0x34/0x4c) from [] (__irq_svc+0x40/0x70) [ 27.801788] Exception stack(0xc04aff68 to 0xc04affb0) [ 27.806823] ff60: 00000000 f0100000 00000001 00000000 c04ae000 c04ec388 [ 27.815002] ff80: c04b604c c0840d80 40004059 412fc093 00000000 00000000 c04ce140 c04affb0 [ 27.823150] ffa0: c000f064 c000f068 60000013 ffffffff [ 27.828216] [] (__irq_svc+0x40/0x70) from [] (default_idle+0x24/0x2c) [ 27.836395] [] (default_idle+0x24/0x2c) from [] (cpu_idle+0x74/0xc8) [ 27.844451] [] (cpu_idle+0x74/0xc8) from [] (start_kernel+0x248/0x288) [ 27.852722] ---[ end trace 9d8ad385bde80fd3 ]--- [ 27.857330] hrtimer: interrupt took 0 ns This is triggered with our v3.4-based custom ARM kernel, but we confirmed that v3.10-rc can still have the same problem. I found a similar issue fixed in v3.9 by Prarit Bhargava in commit 8f294b5a13 (hrtimer: Add expiry time overflow check in hrtimer_interrupt, 2013-04-08). It tried to resolve a overflow issue detected around 1970 + 100 seconds. On the other hand, we have another call site of tick_program_event() at the bottom of hrtimer_interrupt(). The warning this time is triggered there, so we need to apply the same fix to it. Reported-by: Hiroyuki Yokoyama Signed-off-by: Shinya Kuribayashi --- Hi Prarit-san and John-san, http://git.kernel.org/linus/8f294b5a139ee4b75e890ad5b443c93d1e558a8b hrtimer: Add expiry time overflow check in hrtimer_interrupt I tried to fix the other case of overflow issues in hrtimer_interrupt(), but not sure it should be worked around like this in the first place. Any comments are appreciated, thanks in advance. -- Shinya Kuribayashi Renesas Electronics diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index cdd5607..a42d712 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -1368,6 +1370,8 @@ retry: expires_next = ktime_add_ns(now, 100 * NSEC_PER_MSEC); else expires_next = ktime_add(now, delta); + if (expires_next.tv64 < 0) + expires_next.tv64 = KTIME_MAX; tick_program_event(expires_next, 1); printk_once(KERN_WARNING "hrtimer: interrupt took %llu ns\n", ktime_to_ns(delta));