From patchwork Thu Sep 25 08:32:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 4973741 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6AC1F9F1D4 for ; Thu, 25 Sep 2014 08:37:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21B1C20295 for ; Thu, 25 Sep 2014 08:37:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB0E12020F for ; Thu, 25 Sep 2014 08:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751902AbaIYIgW (ORCPT ); Thu, 25 Sep 2014 04:36:22 -0400 Received: from mga03.intel.com ([134.134.136.65]:61732 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751601AbaIYIgT (ORCPT ); Thu, 25 Sep 2014 04:36:19 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 25 Sep 2014 01:34:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,595,1406617200"; d="scan'208";a="608342368" Received: from lantianyu-ws.sh.intel.com (HELO localhost) ([10.239.37.18]) by orsmga002.jf.intel.com with ESMTP; 25 Sep 2014 01:36:15 -0700 From: Lan Tianyu To: peterz@infradead.org, mingo@kernel.org, rafael.j.wysocki@intel.com, toshi.kani@hp.com, akpm@linux-foundation.org, tianyu.lan@intel.com, ktkhai@parallels.com, fabf@skynet.be, laijs@cn.fujitsu.com, srivatsa.bhat@linux.vnet.ibm.com, srivatsa@mit.edu, ego@linux.vnet.ibm.com, viresh.kumar@linaro.org Cc: todd.e.brandt@linux.intel.com, tipbot@zytor.com, wangyun@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [RFC PATCH V3 1/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Date: Thu, 25 Sep 2014 16:32:03 +0800 Message-Id: <1411633925-9018-2-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1411633925-9018-1-git-send-email-tianyu.lan@intel.com> References: <1411633925-9018-1-git-send-email-tianyu.lan@intel.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the current world, all nonboot cpus are enalbed serially during system resume. System resume sequence is that boot cpu enables nonboot cpu one by one and then resume devices. Before resuming devices, there are few tasks assigned to nonboot cpus after they are brought up. This waste cpu usage. To accelerate S3, this patchset is to allow boot cpu to go forward to resume devices after bringing up one nonboot cpu and starting a thread. The thread will be in charge of bringing up other frozen cpus. The thread will be scheduled to the first online cpu to run . This makes enabling cpu2~x parallel with resuming devices. Signed-off-by: Lan Tianyu --- kernel/cpu.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index 356450f..24c4889 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -572,8 +572,41 @@ void __weak arch_enable_nonboot_cpus_end(void) { } +static int _cpu_up_for_pm(int cpu) +{ + int error; + + trace_suspend_resume(TPS("CPU_ON"), cpu, true); + error = _cpu_up(cpu, 1); + trace_suspend_resume(TPS("CPU_ON"), cpu, false); + if (error) { + pr_warn("Error taking CPU%d up: %d\n", cpu, error); + return error; + } + + pr_info("CPU%d is up\n", cpu); + return 0; +} + +static int async_enable_nonboot_cpus(void *data) +{ + int cpu; + + arch_enable_nonboot_cpus_begin(); + + for_each_cpu(cpu, frozen_cpus) { + _cpu_up_for_pm(cpu); + } + + arch_enable_nonboot_cpus_end(); + cpumask_clear(frozen_cpus); + cpu_maps_update_done(); + return 0; +} + void __ref enable_nonboot_cpus(void) { + struct task_struct *tsk; int cpu, error; /* Allow everyone to use the CPU hotplug again */ @@ -584,21 +617,33 @@ void __ref enable_nonboot_cpus(void) pr_info("Enabling non-boot CPUs ...\n"); - arch_enable_nonboot_cpus_begin(); + cpu = cpumask_first(frozen_cpus); + cpumask_clear_cpu(cpu, frozen_cpus); + error = _cpu_up_for_pm(cpu); + if (error) { + pr_err("Failed to bring up first non-boot cpu.\n"); + goto fail; + } - for_each_cpu(cpu, frozen_cpus) { - trace_suspend_resume(TPS("CPU_ON"), cpu, true); - error = _cpu_up(cpu, 1); - trace_suspend_resume(TPS("CPU_ON"), cpu, false); - if (!error) { - pr_info("CPU%d is up\n", cpu); - continue; - } - pr_warn("Error taking CPU%d up: %d\n", cpu, error); + tsk = kthread_run(async_enable_nonboot_cpus, + NULL, "async-enable-nonboot-cpus"); + if (IS_ERR(tsk)) { + pr_err("Failed to create async enable nonboot cpus thread.\n"); + goto fail; } + return; +fail: + /* + * If fail to bring up the first frozen cpu or + * start async thread, enable these rest frozen cpus + * on the boot cpu. + */ + arch_enable_nonboot_cpus_begin(); + for_each_cpu(cpu, frozen_cpus) { + _cpu_up_for_pm(cpu); + } arch_enable_nonboot_cpus_end(); - cpumask_clear(frozen_cpus); out: cpu_maps_update_done();