From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932332AbdJZM5s (ORCPT ); Thu, 26 Oct 2017 08:57:48 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:58879 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932204AbdJZM5r (ORCPT ); Thu, 26 Oct 2017 08:57:47 -0400 Date: Thu, 26 Oct 2017 14:57:41 +0200 (CEST) From: Thomas Gleixner To: Neeraj Upadhyay cc: sramana@codeaurora.org, sboyd@codeaurora.org, LKML , John Stultz Subject: Re: Query regarding __hrtimer_get_next_event() In-Reply-To: <2981b733-84ea-b46f-b16c-91aaa5a96c6c@codeaurora.org> Message-ID: References: <2981b733-84ea-b46f-b16c-91aaa5a96c6c@codeaurora.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Oct 2017, Neeraj Upadhyay wrote: > We have one query regarding the __hrtimer_get_next_event(). > The expires_next.tv64 is set to 0 if it is < 0. We observed > an hrtimer interrupt storm for one of the hrtimers with > below properties: > > * Expires for the hrtimer was set to KTIME_MAX. > * cpu base was HRTIMER_BASE_REALTIME with negative base->offset. > * Due to below sub, expires overflowed to a negative value and > expires_next.tv64 was set to 0 > expires = ktime_sub(hrtimer_get_expires(timer), base->offset); > * Due to this, clockevent was programmed to min_delta_ns, everytime > as __hrtimer_get_next_event() returned 0. > > > This may not be a valid use case (queuing a hrtimer with KTIME_MAX) > expires, but should we guard the hrtimer next event code against > this by using KTIME_MAX upper bound. Is something like below a > proper way to guard it? Or am I missing something here? Can you please explain how you managed to have a negative base->offset? Thanks, tglx