Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423508AbbEENXp (ORCPT ); Tue, 5 May 2015 09:23:45 -0400 Received: from www.linutronix.de ([62.245.132.108]:49892 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422884AbbEENXg (ORCPT ); Tue, 5 May 2015 09:23:36 -0400 Date: Tue, 5 May 2015 15:23:53 +0200 (CEST) From: Thomas Gleixner To: Andreas Sandberg cc: linux-kernel@vger.kernel.org, Preeti U Murthy , stable@vger.kernel.org, Catalin Marinas , Mark Rutland Subject: Re: [PATCH] tick: Fix hang caused by hrtimer in broadcast mode In-Reply-To: <1429880765-5558-1-git-send-email-andreas.sandberg@arm.com> Message-ID: References: <1429880765-5558-1-git-send-email-andreas.sandberg@arm.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) 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 Content-Length: 2228 Lines: 53 On Fri, 24 Apr 2015, Andreas Sandberg wrote: > The hrtimer callback in the hrtimer's tick broadcast code sometimes > incorrectly ends up scheduling events at the current tick causing the > kernel to hang servicing the same hrtimer forever. This typically > happens when a device is swapped out by > tick_install_broadcast_device(), which replaces the event handler with > clock_events_handle_noop() and sets the device mode to > CLOCK_EVT_MODE_UNUSED. If the timer is scheduled when this happens, > the next_event field will not be updated and the hrtimer ends up being > restarted at the current tick. To prevent this from happening, only > try to restart the hrtimer if the broadcast clock event device is in > one of the active modes and try to cancel the timer when entering the > CLOCK_EVT_MODE_UNUSED mode. > > Signed-off-by: Andreas Sandberg > Acked-by: Mark Rutland > Tested-by: Catalin Marinas > --- > kernel/time/tick-broadcast-hrtimer.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/kernel/time/tick-broadcast-hrtimer.c b/kernel/time/tick-broadcast-hrtimer.c > index 6aac4be..a20c605 100644 > --- a/kernel/time/tick-broadcast-hrtimer.c > +++ b/kernel/time/tick-broadcast-hrtimer.c > @@ -22,6 +22,7 @@ static void bc_set_mode(enum clock_event_mode mode, > struct clock_event_device *bc) > { > switch (mode) { > + case CLOCK_EVT_MODE_UNUSED: > case CLOCK_EVT_MODE_SHUTDOWN: > /* > * Note, we cannot cancel the timer here as we might > @@ -99,10 +100,14 @@ static enum hrtimer_restart bc_handler(struct hrtimer *t) > { > ce_broadcast_hrtimer.event_handler(&ce_broadcast_hrtimer); > > - if (ce_broadcast_hrtimer.next_event.tv64 == KTIME_MAX) > + switch (ce_broadcast_hrtimer.mode) { > + case CLOCK_EVT_MODE_PERIODIC: That case is pointless. The mode cannot be periodic simply because .features lacks the periodic flag. Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/