Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753294AbdGJBtC (ORCPT ); Sun, 9 Jul 2017 21:49:02 -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 S1753270AbdGJBtA (ORCPT ); Sun, 9 Jul 2017 21:49:00 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,337,1496127600"; d="scan'208";a="1193388577" 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 04/11] sched/idle: make the fast idle path for short idle periods Date: Mon, 10 Jul 2017 09:38:34 +0800 Message-Id: <1499650721-5928-5-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: 914 Lines: 37 From: Aubrey Li The system will enter a fast idle loop if the predicted idle period is shorter than the threshold. --- kernel/sched/idle.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index cf6c11f..16a766c 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -280,6 +280,8 @@ static void cpuidle_generic(void) */ static void do_idle(void) { + unsigned int predicted_idle_us; + unsigned int short_idle_threshold = jiffies_to_usecs(1) / 2; /* * If the arch has a polling bit, we maintain an invariant: * @@ -291,7 +293,12 @@ static void do_idle(void) __current_set_polling(); - cpuidle_generic(); + predicted_idle_us = cpuidle_predict(); + + if (likely(predicted_idle_us < short_idle_threshold)) + cpuidle_fast(); + else + cpuidle_generic(); __current_clr_polling(); -- 2.7.4