Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753203AbcL2QyC (ORCPT ); Thu, 29 Dec 2016 11:54:02 -0500 Received: from mail-wj0-f193.google.com ([209.85.210.193]:36246 "EHLO mail-wj0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753114AbcL2QyA (ORCPT ); Thu, 29 Dec 2016 11:54:00 -0500 Date: Thu, 29 Dec 2016 17:53:53 +0100 From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Peter Zijlstra , James Hartsock , Ingo Molnar , Rik van Riel Subject: Re: [PATCH] nohz: Fix collision between tick and other hrtimers Message-ID: <20161229165350.GC2765@lerouge> References: <1482596100-16494-1-git-send-email-fweisbec@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1711 Lines: 45 On Thu, Dec 29, 2016 at 05:42:48PM +0100, Thomas Gleixner wrote: > On Sat, 24 Dec 2016, Frederic Weisbecker wrote: > > static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts, > > ktime_t now, int cpu) > > { > > - struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); > > u64 basemono, next_tick, next_tmr, next_rcu, delta, expires; > > unsigned long seq, basejiff; > > ktime_t tick; > > @@ -767,7 +766,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts, > > tick.tv64 = expires; > > > > /* Skip reprogram of event if its not changed */ > > - if (ts->tick_stopped && (expires == dev->next_event.tv64)) > > + if (ts->tick_stopped && (expires == ts->next_tick.tv64)) > > goto out; > > Good catch! > > > > > /* > > @@ -787,6 +786,8 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts, > > trace_tick_stop(1, TICK_DEP_MASK_NONE); > > } > > > > + ts->next_tick = tick; > > + > > /* > > * If the expiration time == KTIME_MAX, then we simply stop > > * the tick timer. > > @@ -803,7 +804,7 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts, > > tick_program_event(tick, 1); > > out: > > /* Update the estimated sleep length */ > > - ts->sleep_length = ktime_sub(dev->next_event, now); > > + ts->sleep_length = ktime_sub(ts->next_tick, now); > > This is wrong. If the next event is earlier than the next estimated tick > then tick_nohz_get_sleep_length() will return crap and the idle governor > will go into a deeper C-state than sensible. Ah I see, the governor wants to know about the next timer, whether it is the tick or not, right? I'll fix that and improve the comment along. Thanks.