From patchwork Tue Jan 29 02:58:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fli24 X-Patchwork-Id: 2058881 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A1CB440106 for ; Tue, 29 Jan 2013 02:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752988Ab3A2C74 (ORCPT ); Mon, 28 Jan 2013 21:59:56 -0500 Received: from mga03.intel.com ([143.182.124.21]:15654 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750874Ab3A2C74 (ORCPT ); Mon, 28 Jan 2013 21:59:56 -0500 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga101.ch.intel.com with ESMTP; 28 Jan 2013 18:59:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,555,1355126400"; d="scan'208";a="196091360" Received: from fli24-hp-compaq-8100-elite-cmt-pc.sh.intel.com (HELO [10.239.67.67]) ([10.239.67.67]) by AZSMGA002.ch.intel.com with ESMTP; 28 Jan 2013 18:59:53 -0800 Subject: [PATCH] suspend: enable freeze timeout configuration through sysctl From: fli24 To: rjw@sisk.pl, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, chuansheng.liu@intel.com, fei.li@intel.com Date: Tue, 29 Jan 2013 10:58:20 +0800 Message-ID: <1359428300.3211.3.camel@fli24-HP-Compaq-8100-Elite-CMT-PC> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org At present, the timeout value for freezing tasks is fixed as 20s, which is too long for handheld device usage, especially for mobile phone. In order to improve user experience, we enable freeze timeout configuration through sysctl, so that we can tune the value easily for concrete usage, such as smaller value for handheld device such as mobile phone. Signed-off-by: Liu Chuansheng Signed-off-by: Li Fei --- include/linux/freezer.h | 5 +++++ kernel/power/process.c | 4 ++-- kernel/sysctl.c | 12 ++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/linux/freezer.h b/include/linux/freezer.h index e4238ce..f37b3be 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -13,6 +13,11 @@ extern bool pm_freezing; /* PM freezing in effect */ extern bool pm_nosig_freezing; /* PM nosig freezing in effect */ /* + * Timeout for stopping processes + */ +extern unsigned int sysctl_freeze_process_timeout_secs; + +/* * Check if a process has been frozen */ static inline bool frozen(struct task_struct *p) diff --git a/kernel/power/process.c b/kernel/power/process.c index d5a258b..f7eb7c9 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c @@ -21,7 +21,7 @@ /* * Timeout for stopping processes */ -#define TIMEOUT (20 * HZ) +unsigned int __read_mostly sysctl_freeze_process_timeout_secs = 20; static int try_to_freeze_tasks(bool user_only) { @@ -36,7 +36,7 @@ static int try_to_freeze_tasks(bool user_only) do_gettimeofday(&start); - end_time = jiffies + TIMEOUT; + end_time = jiffies + sysctl_freeze_process_timeout_secs * HZ; if (!user_only) freeze_workqueues_begin(); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index c88878d..f88bcb9 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -90,6 +90,9 @@ #include #endif +#ifdef CONFIG_FREEZER +#include +#endif #if defined(CONFIG_SYSCTL) @@ -1047,6 +1050,15 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_dointvec, }, #endif +#ifdef CONFIG_FREEZER + { + .procname = "freeze_process_timeout_secs", + .data = &sysctl_freeze_process_timeout_secs, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +#endif { } };