From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752701AbbC3FvH (ORCPT ); Mon, 30 Mar 2015 01:51:07 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:39905 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751288AbbC3FvF (ORCPT ); Mon, 30 Mar 2015 01:51:05 -0400 Message-ID: <5518E43A.5070606@linux.vnet.ibm.com> Date: Mon, 30 Mar 2015 11:20:50 +0530 From: Preeti U Murthy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Viresh Kumar , Ingo Molnar , Peter Zijlstra , Thomas Gleixner CC: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Kevin Hilman , Daniel Lezcano , Frederic Weisbecker Subject: Re: [PATCH 3/3] clockevents: Switch state to ONESHOT_STOPPED for unused clockevent devices References: <98b55223ab29cd5fb9b1f4a384cb7edd86578ea5.1427475606.git.viresh.kumar@linaro.org> In-Reply-To: <98b55223ab29cd5fb9b1f4a384cb7edd86578ea5.1427475606.git.viresh.kumar@linaro.org> Content-Type: text/plain; charset=ISO-8859-6 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15033005-0025-0000-0000-0000098D8A4D Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/27/2015 10:44 PM, Viresh Kumar wrote: > Clockevent device can now be stopped by switching to ONESHOT_STOPPED state, to > avoid getting spurious interrupts on a tickless CPU. > > Switch state to ONESHOT_STOPPED at following places: > > 1.) NOHZ_MODE_LOWRES Mode > > Timers & hrtimers are dependent on tick for their working in this mode and the > only place from where clockevent device is programmed is the tick-code. > > In LOWRES mode we skip reprogramming the clockevent device in > tick_nohz_stop_sched_tick() if expires == KTIME_MAX. In addition to that we must > also switch the clockevent device to ONESHOT_STOPPED state to avoid all spurious > interrupts that may follow. > > 2.) NOHZ_MODE_HIGHRES Mode > > Tick & timers are dependent on hrtimers for their working in this mode and the > only place from where clockevent device is programmed is the hrtimer-code. > > There are two places here from which we reprogram the clockevent device or skip > reprogramming it on expires == KTIME_MAX. > > Signed-off-by: Viresh Kumar > --- > kernel/time/hrtimer.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- > kernel/time/tick-sched.c | 3 +++ > 2 files changed, 45 insertions(+), 4 deletions(-) > > diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c > index 045ba7e2be6c..89d4b593dfc0 100644 > --- a/kernel/time/hrtimer.c > +++ b/kernel/time/hrtimer.c > @@ -543,8 +543,19 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal) > if (cpu_base->hang_detected) > return; > > - if (cpu_base->expires_next.tv64 != KTIME_MAX) > + if (cpu_base->expires_next.tv64 != KTIME_MAX) { > tick_program_event(cpu_base->expires_next, 1); > + } else { > + struct clock_event_device *dev = > + __this_cpu_read(tick_cpu_device.evtdev); > + /* > + * Don't need clockevent device anymore, stop it. > + * > + * We reach here only for NOHZ_MODE_HIGHRES mode and we are > + * guaranteed that no timers/hrtimers are enqueued on this cpu. > + */ > + clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED); > + } > } > > /* > @@ -1312,9 +1323,36 @@ void hrtimer_interrupt(struct clock_event_device *dev) > cpu_base->in_hrtirq = 0; > raw_spin_unlock(&cpu_base->lock); > > - /* Reprogramming necessary ? */ > - if (expires_next.tv64 == KTIME_MAX || > - !tick_program_event(expires_next, 0)) { > + if (expires_next.tv64 == KTIME_MAX) { > + struct clock_event_device *dev = > + __this_cpu_read(tick_cpu_device.evtdev); > + > + cpu_base->hang_detected = 0; > + > + /* > + * Don't need clockevent device anymore, stop it. > + * > + * We reach here only for NOHZ_MODE_HIGHRES mode and we are > + * guaranteed that no timers/hrtimers are enqueued on this cpu. > + * > + * Most of the scenarios will be covered by similar code > + * present in hrtimer_force_reprogram(), as we always try to > + * evaluate tick requirement on idle/irq exit and cancel > + * tick-sched hrtimer when tick isn't required anymore. > + * > + * It is required here as well as a special case. > + * > + * Last hrtimer fires on a tickless CPU and doesn't rearm > + * itself. tick_nohz_irq_exit() reevaluates next event and it > + * gets expires == KTIME_MAX. Because tick was already stopped, > + * and last expires == new_expires, we return early. And the > + * clockevent device is never stopped. > + */ > + clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED); > + return; > + } > + > + if (!tick_program_event(expires_next, 0)) { > cpu_base->hang_detected = 0; > return; > } > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c > index 47c04edd07df..ff271a26fa4d 100644 > --- a/kernel/time/tick-sched.c > +++ b/kernel/time/tick-sched.c > @@ -685,6 +685,9 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts, > if (unlikely(expires.tv64 == KTIME_MAX)) { > if (ts->nohz_mode == NOHZ_MODE_HIGHRES) > hrtimer_cancel(&ts->sched_timer); > + else > + /* stop clock event device */ > + clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT_STOPPED); > goto out; > } > Reviewed-by: Preeti U. Murthy