From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_PASS,T_DKIMWL_WL_HIGH,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E782CC4321D for ; Thu, 16 Aug 2018 13:27:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E7142147E for ; Thu, 16 Aug 2018 13:27:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="WF29SbJQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E7142147E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391626AbeHPQ0F (ORCPT ); Thu, 16 Aug 2018 12:26:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:41662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727244AbeHPQ0E (ORCPT ); Thu, 16 Aug 2018 12:26:04 -0400 Received: from localhost (LFbn-NCY-1-241-207.w83-194.abo.wanadoo.fr [83.194.85.207]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6FBFB2147D; Thu, 16 Aug 2018 13:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1534426048; bh=JNbZ2K2nIc9EC+wfVOxUASszoZlVEu3uUXfNAKIOq5Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WF29SbJQLr39zUGhzsJEdr73OqMQYEAnFKVwhnG0SwJqAJ0svb3y/QB6gty95/lLA Lf0tsPbFiMHeA+VBQiif6AQ0+0ACHZmeoq51ONXIApCzj6VPereD7hSir6Uh/uT1/t PEM09MOcghbv84xMFQiePwS3rVxRD3zzuFksliWo= Date: Thu, 16 Aug 2018 15:27:24 +0200 From: Frederic Weisbecker To: "Rafael J. Wysocki" Cc: Peter Zijlstra , Linux PM , LKML , Ingo Molnar , Leo Yan Subject: Re: [PATCH] sched: idle: Avoid retaining the tick when it has been stopped Message-ID: <20180816132723.GA6010@lerouge> References: <2161372.IsD4PDzmmY@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2161372.IsD4PDzmmY@aspire.rjw.lan> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 09, 2018 at 07:08:34PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > If the tick has been stopped already, but the governor has not asked to > stop it (which it can do sometimes), the idle loop should invoke > tick_nohz_idle_stop_tick(), to let tick_nohz_stop_tick() take care > of this case properly. > > Fixes: 554c8aa8ecad (sched: idle: Select idle state before stopping the tick) > Signed-off-by: Rafael J. Wysocki > --- > kernel/sched/idle.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Index: linux-pm/kernel/sched/idle.c > =================================================================== > --- linux-pm.orig/kernel/sched/idle.c > +++ linux-pm/kernel/sched/idle.c > @@ -190,7 +190,7 @@ static void cpuidle_idle_call(void) > */ > next_state = cpuidle_select(drv, dev, &stop_tick); > > - if (stop_tick) > + if (stop_tick || tick_nohz_tick_stopped()) > tick_nohz_idle_stop_tick(); > else > tick_nohz_idle_retain_tick(); So what if tick_nohz_idle_stop_tick() sees no timer to schedule and cancels it, we may remain idle in a shallow state for a long while? Otherwise we can have something like this: diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index da9455a..408c985 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -806,6 +806,9 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu) static void tick_nohz_retain_tick(struct tick_sched *ts) { ts->timer_expires_base = 0; + + if (ts->tick_stopped) + tick_nohz_restart(ts, ktime_get()); } #ifdef CONFIG_NO_HZ_FULL