Received: by 10.213.65.68 with SMTP id h4csp2009664imn; Thu, 5 Apr 2018 07:31:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/qKyt3eZSBxGa9v1YvSSEH4HUpAzoJvUiYOvM3CJOR52c9Voa09wPN9UVxkbf9pkypLLfR X-Received: by 10.101.80.205 with SMTP id s13mr14659859pgp.285.1522938688629; Thu, 05 Apr 2018 07:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522938688; cv=none; d=google.com; s=arc-20160816; b=L8LdApc5gvD3MmYYjLyOhv164sAmojUYqh0ovRhlQPCGmI2ZvRJDTznOijoKbjM+5G ZsUKJXn95EBiWREFWByTRF6mAZMatU6+0IhXt7aaSonehuDPOmixvY2ZA6vcTLu6DFme Wv3Op0h1jcDwFTpTGVIrj5Qujyl1ZZqt7lcueQ9Yw0C1GKwX5zUOSjH6/Dzr+INN8nDN D0SW63Uu8xq/mgKCbd/El+pe0ZzReQbYBKLHqH+glNow5TU48HH3R2gcKjeBdeR+W1lc tpqfqkmQSlkB71u8FNYWxHjbBDbdygeQm9b0fB/5KVgIqoO837T3gm+rmFPchFi4mL1m +2iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Qy4u2hDQLowUGlhU6AQL35W8a/qZkxfnNmilFq9uv+k=; b=rHuOS8Tr0G1dnFHAQn07eh2IW+G1a8v07c+xIrtEKdP0q3wf8B8ZzUjNg+E6a2Y9In 3vDTI4EuJlvOl5eIqLxH1YwJWjY5HOufdSVSbFFN66znm2fdkr+B1cR1+oSYUXkvGSJH RkTbe8aRRfE2fGsS0L2FybMNRus/D380mjzC1ZFcuHNEEQtQj33kapgTIKrw5aLy7qbS ORpiqM1ZCx8N+F6ns+cJfZK0ayVpKJiYeG55omK6XR8PqhUs3AbeKyBGCjHttHHFYOtE lpS2eJ3al3xbafj06yfGM+72W6mY+YWhQI4/SL08EfY4ZkrOz4hdpwn5VNwgMm1kELPt EzaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CqvoHmUv; 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.31.10; Thu, 05 Apr 2018 07:31:28 -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=@gmail.com header.s=20161025 header.b=CqvoHmUv; 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 S1751352AbeDEO3c (ORCPT + 99 others); Thu, 5 Apr 2018 10:29:32 -0400 Received: from mail-oi0-f49.google.com ([209.85.218.49]:33205 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751179AbeDEO3a (ORCPT ); Thu, 5 Apr 2018 10:29:30 -0400 Received: by mail-oi0-f49.google.com with SMTP id 126-v6so22748571oig.0; Thu, 05 Apr 2018 07:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Qy4u2hDQLowUGlhU6AQL35W8a/qZkxfnNmilFq9uv+k=; b=CqvoHmUvq+vf3DMgSTmZqW9jE6oVOTB4UoU9GKnuBo3sH6kkWHhHPOPOOQiYtLFmnk C/hrlaJmWK+3WfYCiNXl3nYw9u3AukqIfqRbLubppVcNN7gjtjOt+3QyxU/t9/JvySyf +xHXEJUgbGLup9/X/VxzloDIknCWWv/oGBXk9zKtw3OXIvmMbEJqlL5untkzUTlSVNaP f3OtpZ2QEJmXgp+uF/ngPKPebx9qnDGW7gKWxjClTbaI2QmPGMspgBQTTbRR+bns+6U2 L17V5eP80QiVsgrW1inIg5NOSnSJD8M768rntf3wNBgEdcgOU2CaAEy5KVMbjYhQbP6s lazg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Qy4u2hDQLowUGlhU6AQL35W8a/qZkxfnNmilFq9uv+k=; b=GsuJuXwYlPE30525GCcTJ+M8uhRZ6JgJPU1/WYLk0e9lzwPlqF7zvdrxHkCzOmNVZF 4NmoAaQ7ZiRA3+kuiBqhyDiFdGrhwF7shvGOWALfL8OY4a1Rc/sBOw8EGoUEq9TdRxCS bTMgC8znSXkPQZUglt1mKpVIYt4Z06DjdnoOQpqyyh0ukdQCURu4LfFEdpKhrrp1A4Oq EvGwVf9UvwgW9rVktC0waVxU21wNc+Z1rW1XFvKE2gO50V9Xsul8rsIFg0kqzkc+GOhd deoV/8Y9RKvvmQdjv/Qlo69Iy/u4tC2Er63YGGY1tCSGYokSIErz+J70nAGst3tEtVma tPMg== X-Gm-Message-State: ALQs6tAYAurjPn75Ssp1o1IjRZ75ZsEfCj9Xe39YpVOp9CPfMkpEXpib 6gK1+Z4TrgHEcseRJIipWFMg6SwMmmDi3714Pxs= X-Received: by 2002:aca:e1c1:: with SMTP id y184-v6mr5985081oig.120.1522938570040; Thu, 05 Apr 2018 07:29:30 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:9f7:0:0:0:0:0 with HTTP; Thu, 5 Apr 2018 07:29:29 -0700 (PDT) In-Reply-To: <20180405141326.GH4129@hirez.programming.kicks-ass.net> References: <1736751.LdhZHb50jq@aspire.rjw.lan> <6542020.eHGLEK9V0J@aspire.rjw.lan> <20180405124757.GQ4082@hirez.programming.kicks-ass.net> <20180405141127.GS4043@hirez.programming.kicks-ass.net> <20180405141326.GH4129@hirez.programming.kicks-ass.net> From: "Rafael J. Wysocki" Date: Thu, 5 Apr 2018 16:29:29 +0200 X-Google-Sender-Auth: X1WqRCDqI88alxe5OqT0mqcVILw Message-ID: Subject: Re: [PATCH v9 10/10] cpuidle: menu: Avoid selecting shallow states with stopped tick To: Peter Zijlstra Cc: "Rafael J. Wysocki" , "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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 5, 2018 at 4:13 PM, Peter Zijlstra wrote: > On Thu, Apr 05, 2018 at 04:11:27PM +0200, Peter Zijlstra wrote: >> 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. That's possible, but then we already stopped the tick before and the CPU was in a deep idle state (or we wouldn't have got here with the tick stopped), so the extra bit of latency coming from this is not likely to matter IMO. And the code can stay simpler this way. :-) >> 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? > > To clarify, RETAIN keeps the status quo, if its off, it stays off, if > its on it stays on. That could be done, but I'm not sure if the menu governor has a good way to decide whether to use NOHZ_TICK_RETAIN or NOHZ_TICK_START. Doing NOHZ_TICK_START every time the predicted idle duration is within the tick range may be wasteful. Besides, enum tick_action and so on can be introduced later if really needed, but for now it looks like the simpler code gets the job done.