From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753337AbbDBNeU (ORCPT ); Thu, 2 Apr 2015 09:34:20 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:51577 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752640AbbDBNeR (ORCPT ); Thu, 2 Apr 2015 09:34:17 -0400 Date: Thu, 2 Apr 2015 15:34:03 +0200 From: Peter Zijlstra To: Viresh Kumar Cc: Ingo Molnar , Thomas Gleixner , linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Kevin Hilman , Daniel Lezcano , Preeti U Murthy , Frederic Weisbecker Subject: Re: [PATCH 2/3] clockevents: Restart clockevent device before using it again Message-ID: <20150402133403.GY23123@twins.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 27, 2015 at 10:44:28PM +0530, Viresh Kumar wrote: > Only hrtimer_reprogram() is responsible for programming the clockevent device > for next event, if the clockevent device is stopped earlier. And updating that > alone is sufficient here. > +++ b/kernel/time/hrtimer.c > @@ -566,6 +566,7 @@ static int hrtimer_reprogram(struct hrtimer *timer, > { > struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); > ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset); > + struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); > int res; > > WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0); > @@ -610,6 +611,10 @@ static int hrtimer_reprogram(struct hrtimer *timer, > if (cpu_base->hang_detected) > return 0; > > + /* Switchback to ONESHOT state */ > + if (unlikely(dev->state == CLOCK_EVT_STATE_ONESHOT_STOPPED)) > + clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT); > + > /* > * Clockevents returns -ETIME, when the event was in the past. > */ Should we not do this in tick_program_event() instead? Note that there are a few more places that call that, the two in the hrtimer_interrupt() should be safe because if we're handling the interrupt its cannot be stopped anyhow. hrtimer_force_reprogram() seems to need the annotation regardless. Furthermore, by putting it in tick_program_event() you also don't need to fixup tick_nohz_restart(). Or am I completely missing something?