Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp695494imm; Thu, 31 May 2018 07:52:18 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJWqKMdznMltddIaxU69lR05Hh9A9YNTIf6SCe40OM3AVtCaD4Ae4by9D3XRunxKgccFx+D X-Received: by 2002:a63:9902:: with SMTP id d2-v6mr375822pge.166.1527778338703; Thu, 31 May 2018 07:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527778338; cv=none; d=google.com; s=arc-20160816; b=oahhuVPGuw3mOpyEP7pL/T8vEGPIExL1MTvnphm8tT0G7jHcgg/BG/mUoFLCKHcuIL EiB2+pw/zz2RjJWHx3QtJXymm0ARdYeRqFt4QouuGbX8UEMD1RK6Y8LLJJ1y/19G2z+E ZNik6QR89Ad9VCsd0G4kZFm3z3tPZl2Wp8xH2RyL0IfeGwoUtstAjUswMEJsH1hVG1dG 1vZ+ZLa3fSpqE8nxTx0XabFz5jk6Yve1wdJCs28MiH5966xY8X/RxOGlduLNoUXGnpbt ETnAkVaqVYqdWAcvHsfaKKyhUZVLlLxB4L45EwdeHnUVN+Ib3Rc1KFnrbC2vUfzmsTOQ fbyw== 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=Q3VBWNUU8ZwiSg4KJxxcXpZtceU5+5kyN3Qn/WywIKg=; b=PA69y6nL93ito84EHRg27ldaId6P9JqwN3718Ex8w/8LC4lx3v7lSjff8HG//lftTx NgCWfzTEejL31QreaIR03620bdSlS9XuGoxntf+7elkEUlPbI7ScIiZxyVTuyg1GLVy/ gg4jtdtbrtnsdMMGuoZ9wLPWe6JjTnafOrO7NTJIRhh5kNGsbfzyd33UQUe5bPRaVyk6 BUFj6VF05O3T0Pazc53SjxvDKqtutBFMDj2r3SjAYGWXfCxe97XUo/Rz4BBuRSHfrzI6 QeZUAAj/XcFzWL25Fr/o9DhjdoUbF1GxcKg1irlhdQN6yIupUVgsMpcs987lW1cwnGvf 1otw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=h+DoIdaR; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t69-v6si12536857pgd.55.2018.05.31.07.52.04; Thu, 31 May 2018 07:52:18 -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=pass header.i=@gmail.com header.s=20161025 header.b=h+DoIdaR; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755467AbeEaOvb (ORCPT + 99 others); Thu, 31 May 2018 10:51:31 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:42323 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755302AbeEaOvI (ORCPT ); Thu, 31 May 2018 10:51:08 -0400 Received: by mail-ua0-f194.google.com with SMTP id x18-v6so8437230uaj.9; Thu, 31 May 2018 07:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Q3VBWNUU8ZwiSg4KJxxcXpZtceU5+5kyN3Qn/WywIKg=; b=h+DoIdaR8qwjDn9vyPCRfQdNpqDHjfg9HGnv9Z+MLTFvyPyrGvI11KsUo5PwI2HysS KU7PDpvlnKOIrgeJUW1a2t/WaYUJg9qQVHYigHKIoSdZlUCh4SOQx9tUXfZh6oH2uBy5 SdBgGG3LjQaidE3htGt4tfBI8x7PiDKrvasHjA+aESN4a+WDX81zYYjswFZQza8sO0Zh OA5ahwkebhLIBKklgCDtz4qGIoC6rd6Er6dSPfmamFpwS4atv1ttUFsAzVUvYFAnqe+X JvQV0xiPdqzUKp+3B+HZoenj5MNubm7+bdMe/HSzs18ErCNjlmxNDPur+GNIqJPdBfmw 3C3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Q3VBWNUU8ZwiSg4KJxxcXpZtceU5+5kyN3Qn/WywIKg=; b=CxQ81Uk5ONy8a9ygq5k8pXYq5NNAfioWV1aEwDM7f+J7vkNjCGUKOxxdBuPwjX7xXM ykh6CPl+U10mxLXIIOyVO3Q1UHvUbP686Ao6A6NsETLYDnckAIF/gHj2LKMyUJprpKkw thTKwvhCCf3pkeJ4wbuNPAYoPPOMHe+JzS/22dlqhy4D/0YxJGT2/shw+V16sHzUg7Pw bZH2LJ+SvjXt3jW80TnRfYULQiyLgeBCoM+kusJ+zk+9DC5wSh6bG5eb2T5dUSPzOmkj iAUJ78mDRjfOSTE2/rnks3GEpfCD0MHHcgevE1y9LFmViYTLd5ZIEJ2ETEh6iviJTFsh b2Yw== X-Gm-Message-State: APt69E1G25858psG/B15G47nv3xV5A5VzsWWNfTzxez/Ld0OD80y+YYg cCIpaIhsjOeHw320/7qqoJG58yg6MCnV73UVqCcE5Q== X-Received: by 2002:a9f:3613:: with SMTP id r19-v6mr1524886uad.49.1527778266955; Thu, 31 May 2018 07:51:06 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:549e:0:0:0:0:0 with HTTP; Thu, 31 May 2018 07:51:05 -0700 (PDT) In-Reply-To: <1527768909-32637-1-git-send-email-ego@linux.vnet.ibm.com> References: <1527768909-32637-1-git-send-email-ego@linux.vnet.ibm.com> From: Balbir Singh Date: Fri, 1 Jun 2018 00:51:05 +1000 Message-ID: Subject: Re: [PATCH] cpuidle:powernv: Make the snooze timeout dynamic. To: "Gautham R. Shenoy" Cc: "Rafael J. Wysocki" , Daniel Lezcano , Michael Ellerman , Stewart Smith , Michael Neuling , Vaidyanathan Srinivasan , Shilpasri G Bhat , Akshay Adiga , Nicholas Piggin , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , "linux-kernel@vger.kernel.org" , linux-pm@vger.kernel.org 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, May 31, 2018 at 10:15 PM, Gautham R. Shenoy wrote: > From: "Gautham R. Shenoy" > > The commit 78eaa10f027c ("cpuidle: powernv/pseries: Auto-promotion of > snooze to deeper idle state") introduced a timeout for the snooze idle > state so that it could be eventually be promoted to a deeper idle > state. The snooze timeout value is static and set to the target > residency of the next idle state, which would train the cpuidle > governor to pick the next idle state eventually. > > The unfortunate side-effect of this is that if the next idle state(s) > is disabled, the CPU will forever remain in snooze, despite the fact > that the system is completely idle, and other deeper idle states are > available. > > This patch fixes the issue by dynamically setting the snooze timeout > to the target residency of the next enabled state on the device. > > Before Patch > ================== > POWER8 : Only nap disabled. > $cpupower monitor sleep 30 > sleep took 30.01297 seconds and exited with status 0 > |Idle_Stats > PKG |CORE|CPU | snoo | Nap | Fast > 0| 8| 0| 96.41| 0.00| 0.00 > 0| 8| 1| 96.43| 0.00| 0.00 > 0| 8| 2| 96.47| 0.00| 0.00 > 0| 8| 3| 96.35| 0.00| 0.00 > 0| 8| 4| 96.37| 0.00| 0.00 > 0| 8| 5| 96.37| 0.00| 0.00 > 0| 8| 6| 96.47| 0.00| 0.00 > 0| 8| 7| 96.47| 0.00| 0.00 > > POWER9: Shallow states (stop0lite, stop1lite, stop2lite, stop0, stop1, > stop2) disabled: > $cpupower monitor sleep 30 > sleep took 30.05033 seconds and exited with status 0 > |Idle_Stats > PKG |CORE|CPU | snoo | stop | stop | stop | stop | stop | stop | stop | stop > 0| 16| 0| 89.79| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00 > 0| 16| 1| 90.12| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00 > 0| 16| 2| 90.21| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00 > 0| 16| 3| 90.29| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00 > > After Patch > ====================== > POWER8 : Only nap disabled. > $ cpupower monitor sleep 30 > sleep took 30.01200 seconds and exited with status 0 > |Idle_Stats > PKG |CORE|CPU | snoo | Nap | Fast > 0| 8| 0| 16.58| 0.00| 77.21 > 0| 8| 1| 18.42| 0.00| 75.38 > 0| 8| 2| 4.70| 0.00| 94.09 > 0| 8| 3| 17.06| 0.00| 81.73 > 0| 8| 4| 3.06| 0.00| 95.73 > 0| 8| 5| 7.00| 0.00| 96.80 > 0| 8| 6| 1.00| 0.00| 98.79 > 0| 8| 7| 5.62| 0.00| 94.17 > > POWER9: Shallow states (stop0lite, stop1lite, stop2lite, stop0, stop1, > stop2) disabled: > > $cpupower monitor sleep 30 > sleep took 30.02110 seconds and exited with status 0 > |Idle_Stats > PKG |CORE|CPU | snoo | stop | stop | stop | stop | stop | stop | stop | stop > 0| 0| 0| 0.69| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 9.39| 89.70 > 0| 0| 1| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.05| 93.21 > 0| 0| 2| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 89.93 > 0| 0| 3| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 0.00| 93.26 > > Signed-off-by: Gautham R. Shenoy > --- > drivers/cpuidle/cpuidle-powernv.c | 32 ++++++++++++++++++++++++++------ > 1 file changed, 26 insertions(+), 6 deletions(-) > > diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c > index 1a8234e..d29e4f0 100644 > --- a/drivers/cpuidle/cpuidle-powernv.c > +++ b/drivers/cpuidle/cpuidle-powernv.c > @@ -43,9 +43,31 @@ struct stop_psscr_table { > > static struct stop_psscr_table stop_psscr_table[CPUIDLE_STATE_MAX] __read_mostly; > > -static u64 snooze_timeout __read_mostly; > +static u64 default_snooze_timeout __read_mostly; > static bool snooze_timeout_en __read_mostly; > > +static u64 get_snooze_timeout(struct cpuidle_device *dev, > + struct cpuidle_driver *drv, > + int index) > +{ > + int i; > + > + if (unlikely(!snooze_timeout_en)) > + return default_snooze_timeout; > + > + for (i = index + 1; i < drv->state_count; i++) { > + struct cpuidle_state *s = &drv->states[i]; > + struct cpuidle_state_usage *su = &dev->states_usage[i]; > + > + if (s->disabled || su->disable) > + continue; > + > + return s->target_residency * tb_ticks_per_usec; Can we ensure this is not prone to overflow? Otherwise looks good Reviewed-by: Balbir Singh