Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753391AbdGJBtS (ORCPT ); Sun, 9 Jul 2017 21:49:18 -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 S1753305AbdGJBtP (ORCPT ); Sun, 9 Jul 2017 21:49:15 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,337,1496127600"; d="scan'208";a="1193388664" 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 11/11] sched/idle: Add a tuning knob to allow changing fast idle threshold Date: Mon, 10 Jul 2017 09:38:41 +0800 Message-Id: <1499650721-5928-12-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: 2408 Lines: 82 From: Aubrey Li Short idle periods varies from different workload, make the switch tunable --- include/linux/sched/sysctl.h | 1 + kernel/sched/idle.c | 5 +++-- kernel/sysctl.c | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h index 0f5ecd4..9771506 100644 --- a/include/linux/sched/sysctl.h +++ b/include/linux/sched/sysctl.h @@ -65,6 +65,7 @@ extern unsigned int sysctl_sched_autogroup_enabled; extern int sysctl_sched_rr_timeslice; extern int sched_rr_timeslice; +extern unsigned int sysctl_fast_idle_threshold; extern int sched_rr_handler(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 3358db2..555b02d 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -287,6 +287,8 @@ static void cpuidle_generic(void) tick_nohz_idle_exit(); } +unsigned int sysctl_fast_idle_threshold = USEC_PER_SEC / HZ / 2; + /* * Generic idle loop implementation * @@ -295,7 +297,6 @@ 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: * @@ -309,7 +310,7 @@ static void do_idle(void) predicted_idle_us = cpuidle_predict(); - if (likely(predicted_idle_us < short_idle_threshold)) + if (likely(predicted_idle_us < sysctl_fast_idle_threshold)) cpuidle_fast(); else cpuidle_generic(); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 8c8714f..0acf81d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -128,6 +128,7 @@ static int __maybe_unused four = 4; static unsigned long one_ul = 1; static int one_hundred = 100; static int one_thousand = 1000; +static int one_tick_to_us = USEC_PER_SEC / HZ; #ifdef CONFIG_PRINTK static int ten_thousand = 10000; #endif @@ -1201,6 +1202,15 @@ static struct ctl_table kern_table[] = { .extra2 = &one, }, #endif + { + .procname = "sched_fast_idle_threshold", + .data = &sysctl_fast_idle_threshold, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = &zero, + .extra2 = &one_tick_to_us, + }, { } }; -- 2.7.4