Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753339AbdGJBtK (ORCPT ); Sun, 9 Jul 2017 21:49:10 -0400 Received: from mga06.intel.com ([134.134.136.31]:24495 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753286AbdGJBtH (ORCPT ); Sun, 9 Jul 2017 21:49:07 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,337,1496127600"; d="scan'208";a="1193388633" From: Aubrey Li To: tglx@linutronix.de, peterz@infradead.org, len.brown@intel.com, rjw@rjwysocki.net, ak@linux.intel.com, tim.c.chen@linux.intel.com, arjan@linux.intel.com, paulmck@linux.vnet.ibm.com, yang.zhang.wz@gmail.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Aubrey Li Subject: [RFC PATCH v1 07/11] cpuidle: make idle residency update more generic Date: Mon, 10 Jul 2017 09:38:37 +0800 Message-Id: <1499650721-5928-8-git-send-email-aubrey.li@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499650721-5928-1-git-send-email-aubrey.li@intel.com> References: <1499650721-5928-1-git-send-email-aubrey.li@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1645 Lines: 49 From: Aubrey Li Current cpuidle governor updates the last idle residency with the hardware c-state exit latency, which is not applicable for fast idle path, so we update idle residency in idle routine instead. --- drivers/cpuidle/cpuidle.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 2b7d7bf..97aacab 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -306,8 +306,6 @@ static void cpuidle_update(struct cpuidle_driver *drv, { struct cpuidle_governor_stat *gov_stat = (struct cpuidle_governor_stat *)&(dev->gov_stat); - int last_idx = gov_stat->last_state_idx; - struct cpuidle_state *target = &drv->states[last_idx]; unsigned int measured_us; unsigned int new_factor; @@ -329,12 +327,6 @@ static void cpuidle_update(struct cpuidle_driver *drv, /* measured value */ measured_us = cpuidle_get_last_residency(dev); - /* Deduct exit latency */ - if (measured_us > 2 * target->exit_latency) - measured_us -= target->exit_latency; - else - measured_us /= 2; - /* Make sure our coefficients do not exceed unity */ if (measured_us > gov_stat->next_timer_us) measured_us = gov_stat->next_timer_us; @@ -481,6 +473,11 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, diff = ktime_us_delta(time_end, time_start); if (diff > INT_MAX) diff = INT_MAX; + else if (diff > 2 * target_state->exit_latency) + /* Deduct exit latency */ + diff -= target_state->exit_latency; + else + diff /= 2; dev->last_residency = (int) diff; -- 2.7.4