Received: by 10.213.65.68 with SMTP id h4csp1990014imn; Thu, 5 Apr 2018 07:13:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/pk9XL9bNBlH2iTTaSsjkdww2Ppy7nv/fHMv1NmVHg+eaaVdL97NujPdm4UFn268hIgI0V X-Received: by 10.98.102.79 with SMTP id a76mr17240035pfc.162.1522937627671; Thu, 05 Apr 2018 07:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522937627; cv=none; d=google.com; s=arc-20160816; b=lmlOsffdAVIFn2FZ7rwkHagrfJrQ9rl6AlB6jvjbuONPJ+wSXG0eHWEkU4W07lRIc4 wyVPLyU0C6Durrbx/dO4VrCrOo0IY1rH+PxV4QzAwcDhFtnlhNXNnpo5R2YSUrqZ7bTq sqvsDP48e2i4tsKsEl/cRFyuBj4usEnK8ym//5xZw/JCS8d9msgTt0FilI64pdnITgKX Kyg/HI8VseLvDt1TWzAB6vF6ZEK08RujY6grK0lsryLA0dJOds8W9MgtB1WVrpi0MeFw OgU6hmazv2VxCgt/WXBar8jZgaDRHJVqQvrjhg/IRPo+2LpbKq6eonmGYXPfScK1k/VB 1mPQ== 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:dkim-signature:arc-authentication-results; bh=3m0i5fM//TqPzpHBgTFW10LVGP8MvWo+4SyrlXJ8gFw=; b=HXpBczgMI14PaebRXNmnJlt6AIwDdn/qryF837/hH4yHXkPaI1MwhmZsuSpknhHT9b cUVxFXQGT04b2VLV2A/oSMewAMXxpTICkpkqad+QeRgL6obb2FFXJVYPE1ea9TDAm8kP usC4hd5ByjBdjvOMvagKSQdZ4n1aCBIO5LVnGz8jejM80PezpLAKeUAHgTTDdO9lVOUB 9s9YZb98ZASvK/+b8iPwuOXxUztCXpC6Y019Zrj3QoKmy5AYLPp8II63to+BDWpj4f3r xYNK/mq5Mmgwc90H0r4zY8OVabfxo/jqaSry2zOIn2IMaVkAahlh5CRC7YoFJz4bGs5u IOHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=h1rkMmcH; 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 l69si6175881pfk.180.2018.04.05.07.13.32; Thu, 05 Apr 2018 07:13:47 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=h1rkMmcH; 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 S1751356AbeDEOLu (ORCPT + 99 others); Thu, 5 Apr 2018 10:11:50 -0400 Received: from merlin.infradead.org ([205.233.59.134]:57686 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751216AbeDEOLs (ORCPT ); Thu, 5 Apr 2018 10:11:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3m0i5fM//TqPzpHBgTFW10LVGP8MvWo+4SyrlXJ8gFw=; b=h1rkMmcHBag+SDjquNp4O+FGG OgI7ZVoy8ySvW110+howP0F1HE05ay+m3r3ovWWIV7IM0QbMbaRGQ1+UKGJEyVLGTcAYaCIUVBFUI uFBp1P5s7IbipC1leKnxQ3HYPIEljlF5XpGzUYduJJlNSX1wsI2WwKYB7CfUwJstuWVCd9ZEjmBO9 W5EwDfjL6GkAIozmSeA9I7PodMKp2/ALj/UwBO12Ile10S37jYUmxTsA40+hIsSaAgYMnJUsmB2yI D5mfFXadHt1s1xa2rFzikt3y62pUt16Cim2R6O+SO0WA+d5QIJQSCiG0meUV16h0va0eLnzF+qcLq LVGtgHaOg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f45bs-0001cR-Ii; Thu, 05 Apr 2018 14:11:28 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0C7722029F86F; Thu, 5 Apr 2018 16:11:27 +0200 (CEST) Date: Thu, 5 Apr 2018 16:11:27 +0200 From: Peter Zijlstra To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Linux PM , Frederic Weisbecker , Thomas Gleixner , Paul McKenney , Thomas Ilsche , Doug Smythies , Rik van Riel , Aubrey Li , Mike Galbraith , LKML , Len Brown Subject: Re: [PATCH v9 10/10] cpuidle: menu: Avoid selecting shallow states with stopped tick Message-ID: <20180405141127.GS4043@hirez.programming.kicks-ass.net> References: <1736751.LdhZHb50jq@aspire.rjw.lan> <6542020.eHGLEK9V0J@aspire.rjw.lan> <20180405124757.GQ4082@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 05, 2018 at 03:49:32PM +0200, Rafael J. Wysocki wrote: > On Thu, Apr 5, 2018 at 2:47 PM, Peter Zijlstra wrote: > > On Wed, Apr 04, 2018 at 10:50:36AM +0200, Rafael J. Wysocki wrote: > >> + if (tick_nohz_tick_stopped()) { > >> + /* > >> + * If the tick is already stopped, the cost of possible short > >> + * idle duration misprediction is much higher, because the CPU > >> + * may be stuck in a shallow idle state for a long time as a > >> + * result of it. In that case say we might mispredict and try > >> + * to force the CPU into a state for which we would have stopped > >> + * the tick, unless the tick timer is going to expire really > >> + * soon anyway. > > > > Wait what; the tick was stopped, therefore it _cannot_ expire soon. > > > > *confused* > > > > Did you mean s/tick/a/ ? > > Yeah, that should be "a timer". *phew* ok, that makes a lot more sense ;-) My only concern with this is that we can now be overly pessimistic. The predictor might know that statistically it's very likely a device interrupt will arrive soon, but because the tick is already disabled, we don't dare trust it, causing possible excessive latencies. Would an alternative be to make @stop_tick be an enum capable of forcing the tick back on? enum tick_action { NOHZ_TICK_STOP, NOHZ_TICK_RETAIN, NOHZ_TICK_START, }; enum tick_action tick_action = NOHZ_TICK_STOP; state = cpuidle_select(..., &tick_action); switch (tick_action) { case NOHZ_TICK_STOP: tick_nohz_stop_tick(); break; case NOHZ_TICK_RETAIN: tick_nozh_retain_tick(); break; case NOHZ_TICK_START: tick_nohz_start_tick(); break; }; Or something along those lines?