Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752893AbdI3HVv (ORCPT ); Sat, 30 Sep 2017 03:21:51 -0400 Received: from mga01.intel.com ([192.55.52.88]:36037 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752868AbdI3HVs (ORCPT ); Sat, 30 Sep 2017 03:21:48 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,456,1500966000"; d="scan'208";a="1020089330" From: Aubrey Li To: tglx@linutronix.de, peterz@infradead.org, rjw@rjwysocki.net, len.brown@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Aubrey Li , Aubrey Li Subject: [RFC PATCH v2 7/8] cpuidle: introduce irq timing to make idle prediction Date: Sat, 30 Sep 2017 15:20:33 +0800 Message-Id: <1506756034-6340-8-git-send-email-aubrey.li@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506756034-6340-1-git-send-email-aubrey.li@intel.com> References: <1506756034-6340-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: 1921 Lines: 64 Introduce irq timings output as a factor to predict the duration of the coming idle Signed-off-by: Aubrey Li --- drivers/cpuidle/Kconfig | 1 + drivers/cpuidle/cpuidle.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index 7e48eb5..8b07e1c 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -5,6 +5,7 @@ config CPU_IDLE default y if ACPI || PPC_PSERIES select CPU_IDLE_GOV_LADDER if (!NO_HZ && !NO_HZ_IDLE) select CPU_IDLE_GOV_MENU if (NO_HZ || NO_HZ_IDLE) + select IRQ_TIMINGS help CPU idle is a generic framework for supporting software-controlled idle processor power management. It includes modular cross-platform diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 5d4f0b6..be56cea 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "cpuidle.h" @@ -342,13 +343,27 @@ void cpuidle_entry_end(void) void cpuidle_predict(void) { struct cpuidle_device *dev = cpuidle_get_device(); - unsigned int overhead_threshold; + unsigned int idle_interval, overhead_threshold; + u64 now, next_evt; if (!dev) return; overhead_threshold = dev->idle_stat.overhead * sysctl_fast_idle_ratio; + /* + * check irq timings if the next event is coming soon + */ + now = local_clock(); + local_irq_disable(); + next_evt = irq_timings_next_event(now); + local_irq_enable(); + idle_interval = div_u64(next_evt - now, NSEC_PER_USEC); + if (idle_interval < overhead_threshold) { + dev->idle_stat.fast_idle = true; + return; + } + if (cpuidle_curr_governor->predict) { dev->idle_stat.predicted_us = cpuidle_curr_governor->predict(); /* -- 2.7.4