Received: by 10.213.65.68 with SMTP id h4csp2120164imn; Sun, 8 Apr 2018 20:12:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+RzjgYhNiPsmN2zH9B8vHCHoiKM4E5hjun2WmKUyQjZRxicTUJEbLmOgTOAmLW5of/Qpzk X-Received: by 10.99.3.144 with SMTP id 138mr24094461pgd.364.1523243528706; Sun, 08 Apr 2018 20:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243528; cv=none; d=google.com; s=arc-20160816; b=KkiIXgQwnnqSd/rTztc4i5LPrsaXjfmsF9+PUYeghhhOJeDGQoG9B3zGANfRuKcyV+ HS8gW4riIyPMaivtgxqYESy6tp5jXxfgSJREcj5IuwOqJ8Xh88gJfagVn9SSyIi/RG7p yw4X9FjE2tZNNFaj2UQEkj3We3SPJq/uY2W9+FX5M9JyzXAuWzEWOkJIih2FZjJvjlM0 /N2Sf+ch7I8ur+mNE38qeTbXfifmiLRhrGr17dEFM+NWeXpTd1nwkEIflFqidtyfJBgc USQMI+3ZTWtZk4C92XF+3Rxyvrrc6HHontsR8o1x8J7EctXPRAT0Q+VSO3xgOVxD662f EjDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=GH6DUTnl+FJmm5LsQooh/EcMPRMpCqmIqNyAOJ4CqVU=; b=vB7MaKrZXEHzOS2CwYxGlagQgM8zeJIUq+DSil482CnXLGdcjmwagUx+P9x/mdr32I Av2hRcFTf2EQ81YaOU7m65jdgAkjwqFKpnIg0QBRHIVH99Ld6lPGzvhQXdyHRTWRurU+ 15p8UW+p6Jz6pEhJDXT4fBOpGJ30RLWPoqm0yG40JQ4MNksu+5yj7upFj9MPmvIspKJv UIlk9tQq0XISHvzVj3cGpZpD3g66cHUSGyPZKzQrR2wzf82QlMCNyFltLQadCaP++jgp SPx6kj7xl2XS08fMGO/MG8Gdw1adRV38EdgdW52c/bLOTB1/ICti6w7dgYAOZKTn1L4B lpIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i196si794661pgc.625.2018.04.08.20.11.31; Sun, 08 Apr 2018 20:12:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932550AbeDICl7 (ORCPT + 99 others); Sun, 8 Apr 2018 22:41:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:40850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932446AbeDICl4 (ORCPT ); Sun, 8 Apr 2018 22:41:56 -0400 Received: from localhost (LFbn-NCY-1-193-82.w83-194.abo.wanadoo.fr [83.194.41.82]) (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 2403420834; Mon, 9 Apr 2018 02:41:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2403420834 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=frederic@kernel.org Date: Mon, 9 Apr 2018 04:41:51 +0200 From: Frederic Weisbecker To: "Rafael J. Wysocki" Cc: Linux PM , Peter Zijlstra , Frederic Weisbecker , Thomas Gleixner , Paul McKenney , Thomas Ilsche , Doug Smythies , Rik van Riel , Aubrey Li , Mike Galbraith , LKML , Len Brown Subject: Re: [PATCH v9 08/10] sched: idle: Select idle state before stopping the tick Message-ID: <20180409024150.GB21904@lerouge> References: <1736751.LdhZHb50jq@aspire.rjw.lan> <13248276.RivpnYp3Yv@aspire.rjw.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13248276.RivpnYp3Yv@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 Wed, Apr 04, 2018 at 10:47:06AM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > In order to address the issue with short idle duration predictions > by the idle governor after the scheduler tick has been stopped, > reorder the code in cpuidle_idle_call() so that the governor idle > state selection runs before tick_nohz_idle_go_idle() and use the > "nohz" hint returned by cpuidle_select() to decide whether or not > to stop the tick. > > This isn't straightforward, because menu_select() invokes > tick_nohz_get_sleep_length() to get the time to the next timer > event and the number returned by the latter comes from > __tick_nohz_idle_stop_tick(). Fortunately, however, it is possible > to compute that number without actually stopping the tick and with > the help of the existing code. > > Namely, tick_nohz_get_sleep_length() can be made call > tick_nohz_next_event(), introduced earlier, to get the time to the > next non-highres timer event. If that happens, tick_nohz_next_event() > need not be called by __tick_nohz_idle_stop_tick() again. > > If it turns out that the scheduler tick cannot be stopped going > forward or the next timer event is too close for the tick to be > stopped, tick_nohz_get_sleep_length() can simply return the time to > the next event currently programmed into the corresponding clock > event device. > > In addition to knowing the return value of tick_nohz_next_event(), > however, tick_nohz_get_sleep_length() needs to know the time to the > next highres timer event, but with the scheduler tick timer excluded, > which can be computed with the help of hrtimer_get_next_event(). > > That minimum of that number and the tick_nohz_next_event() return > value is the total time to the next timer event with the assumption > that the tick will be stopped. It can be returned to the idle > governor which can use it for predicting idle duration (under the > assumption that the tick will be stopped) and deciding whether or > not it makes sense to stop the tick before putting the CPU into the > selected idle state. > > With the above, the sleep_length field in struct tick_sched is not > necessary any more, so drop it. > > Signed-off-by: Rafael J. Wysocki Reviewed-by: Frederic Weisbecker