* [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices
@ 2014-09-25 8:32 Lan Tianyu
2014-09-25 8:32 ` [RFC PATCH V3 1/3] " Lan Tianyu
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Lan Tianyu @ 2014-09-25 8:32 UTC (permalink / raw)
To: peterz, mingo, rafael.j.wysocki, toshi.kani, akpm, tianyu.lan,
ktkhai, fabf, laijs, srivatsa.bhat, ego, srivatsa, viresh.kumar
Cc: todd.e.brandt, tipbot, wangyun, linux-kernel, linux-pm
This patchset is to parallel enabling nonboot cpus with resuming devices
during system resume in order to accelerate S2RAM. From test result on
a 8 logical core Haswell machine, system resume time reduces from 347ms
to 217ms with this patchset.
In the current world, all nonboot cpus are enabled 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 wastes cpu usage.
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.
Patch 2 is to change the policy of init MTRR/PAT for nonboot cpus. Original
code is to init all nonboot cpus' MTRR/PAT after all nonboot cpus coming online
during system resume. Now parallel enabling nonboot cpus with resuming devices and
nonboot cpus will be assigned with tasks before all cpus are online. So
it's necessary to do init MTRR/PAT just after one nonboot cpus comes online
just like dynamic single cpu online.
Patch 3 is to guarantee that all cpus are online before changing cpufreq_suspended
flag in the cpufreq_resume() to avoid breaking cpufreq subsystem.
Lan Tianyu (3):
PM/CPU: Parallel enalbing nonboot cpus with resume devices
X86/CPU: Initialize MTRR/PAT when each cpu is online during system
resume.
Cpufreq: Hold cpu_add_remove_lock before change cpufreq_suspended flag
drivers/cpufreq/cpufreq.c | 2 ++
kernel/cpu.c | 64 +++++++++++++++++++++++++++++++++++++++--------
2 files changed, 55 insertions(+), 11 deletions(-)
--
1.8.4.rc0.1.g8f6a3e5.dirty
^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH V3 1/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices
2014-09-25 8:32 [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Lan Tianyu
@ 2014-09-25 8:32 ` Lan Tianyu
2014-09-25 8:32 ` [RFC PATCH V2 2/3] X86/CPU: Initialize MTRR/PAT when each cpu is online during system resume Lan Tianyu
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Lan Tianyu @ 2014-09-25 8:32 UTC (permalink / raw)
To: peterz, mingo, rafael.j.wysocki, toshi.kani, akpm, tianyu.lan,
ktkhai, fabf, laijs, srivatsa.bhat, srivatsa, ego, viresh.kumar
Cc: todd.e.brandt, tipbot, wangyun, linux-kernel, linux-pm
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 <tianyu.lan@intel.com>
---
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();
--
1.8.4.rc0.1.g8f6a3e5.dirty
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC PATCH V2 2/3] X86/CPU: Initialize MTRR/PAT when each cpu is online during system resume.
2014-09-25 8:32 [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Lan Tianyu
2014-09-25 8:32 ` [RFC PATCH V3 1/3] " Lan Tianyu
@ 2014-09-25 8:32 ` Lan Tianyu
2014-09-25 8:32 ` [RFC PATCH V3 3/3] Cpufreq: Hold cpu_add_remove_lock before change cpufreq_suspended flag Lan Tianyu
2014-10-08 20:54 ` [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Peter Zijlstra
3 siblings, 0 replies; 8+ messages in thread
From: Lan Tianyu @ 2014-09-25 8:32 UTC (permalink / raw)
To: peterz, mingo, rafael.j.wysocki, srivatsa.bhat, toshi.kani,
tianyu.lan, ego, ktkhai, laijs, todd.e.brandt, srivatsa, fabf,
viresh.kumar
Cc: akpm, tipbot, linux-kernel, linux-pm
SDM Vol 3a section titled "MTRR considerations in MP systems" specifies
the need for synchronizing the logical cpu's while initializing/updating
MTRR.
Commit d0af9eed5a(x86, pat/mtrr: Rendezvous all the cpus for MTRR/PAT init)
delay the MTRR/PAT init for APs till all the logical cpu's come online and
the rendezvous process at the end of AP's bringup, will initialize the MTRR/PAT
for all AP's during boot and resume.
Currently, APs enabling are paralleled with resume devices during system resume
and the AP will be assigned with task before all APs' bringup. MTRR/PAT should
be initialized before running tasks. So this patch is to remove
set_mtrr_aps_delayed_init() for system resume and do the MTRR/PAT init when
the AP comes online just like dynamic single cpu online.
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
kernel/cpu.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 24c4889..30ffdd9 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -592,13 +592,10 @@ 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;
--
1.8.4.rc0.1.g8f6a3e5.dirty
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [RFC PATCH V3 3/3] Cpufreq: Hold cpu_add_remove_lock before change cpufreq_suspended flag
2014-09-25 8:32 [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Lan Tianyu
2014-09-25 8:32 ` [RFC PATCH V3 1/3] " Lan Tianyu
2014-09-25 8:32 ` [RFC PATCH V2 2/3] X86/CPU: Initialize MTRR/PAT when each cpu is online during system resume Lan Tianyu
@ 2014-09-25 8:32 ` Lan Tianyu
2014-10-08 20:54 ` [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Peter Zijlstra
3 siblings, 0 replies; 8+ messages in thread
From: Lan Tianyu @ 2014-09-25 8:32 UTC (permalink / raw)
To: peterz, mingo, rafael.j.wysocki, toshi.kani, akpm, tianyu.lan,
ktkhai, fabf, laijs, srivatsa.bhat, ego, srivatsa, viresh.kumar
Cc: todd.e.brandt, tipbot, wangyun, linux-kernel, linux-pm
Now, enabling non-boot cpus will parallel with resuming devices.
Cpu online may take place after cpufreq resume. But all cpu should be up
before clearing cpufreq_suspended flag in the cpufreq_resume(). Cpufreq
core uses this flag to decide to do light-weight init or full init. Light
-weight init/tear down is dedicated for cpu hotplug during system pm. To
keep this rule, hold cpu_add_remove_lock during changing cpufreq_suspended
flag.
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
drivers/cpufreq/cpufreq.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 37951ec..b03f7dd 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1689,7 +1689,9 @@ void cpufreq_resume(void)
if (!cpufreq_driver)
return;
+ cpu_maps_update_begin();
cpufreq_suspended = false;
+ cpu_maps_update_done();
if (!has_target())
return;
--
1.8.4.rc0.1.g8f6a3e5.dirty
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices
2014-09-25 8:32 [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Lan Tianyu
` (2 preceding siblings ...)
2014-09-25 8:32 ` [RFC PATCH V3 3/3] Cpufreq: Hold cpu_add_remove_lock before change cpufreq_suspended flag Lan Tianyu
@ 2014-10-08 20:54 ` Peter Zijlstra
2014-10-08 22:01 ` Rafael J. Wysocki
2014-10-09 1:18 ` Lan Tianyu
3 siblings, 2 replies; 8+ messages in thread
From: Peter Zijlstra @ 2014-10-08 20:54 UTC (permalink / raw)
To: Lan Tianyu
Cc: mingo, rafael.j.wysocki, toshi.kani, akpm, ktkhai, fabf, laijs,
srivatsa.bhat, ego, srivatsa, viresh.kumar, todd.e.brandt, tipbot,
wangyun, linux-kernel, linux-pm, Thomas Gleixner
On Thu, Sep 25, 2014 at 04:32:02PM +0800, Lan Tianyu wrote:
> This patchset is to parallel enabling nonboot cpus with resuming devices
> during system resume in order to accelerate S2RAM. From test result on
> a 8 logical core Haswell machine, system resume time reduces from 347ms
> to 217ms with this patchset.
>
> In the current world, all nonboot cpus are enabled 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 wastes cpu usage.
>
> 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.
So I feel we should really clean up hotplug before doing anything like
this. Its a trainwreck and just piling more and more hacks ontop isn't
going to help any.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices
2014-10-08 20:54 ` [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Peter Zijlstra
@ 2014-10-08 22:01 ` Rafael J. Wysocki
2014-10-09 1:18 ` Lan Tianyu
1 sibling, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2014-10-08 22:01 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Lan Tianyu, mingo, rafael.j.wysocki, toshi.kani, akpm, ktkhai,
fabf, laijs, srivatsa.bhat, ego, srivatsa, viresh.kumar,
todd.e.brandt, tipbot, wangyun, linux-kernel, linux-pm,
Thomas Gleixner
On Wednesday, October 08, 2014 10:54:41 PM Peter Zijlstra wrote:
> On Thu, Sep 25, 2014 at 04:32:02PM +0800, Lan Tianyu wrote:
> > This patchset is to parallel enabling nonboot cpus with resuming devices
> > during system resume in order to accelerate S2RAM. From test result on
> > a 8 logical core Haswell machine, system resume time reduces from 347ms
> > to 217ms with this patchset.
> >
> > In the current world, all nonboot cpus are enabled 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 wastes cpu usage.
> >
> > 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.
>
> So I feel we should really clean up hotplug before doing anything like
> this. Its a trainwreck and just piling more and more hacks ontop isn't
> going to help any.
Agreed.
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices
2014-10-08 20:54 ` [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Peter Zijlstra
2014-10-08 22:01 ` Rafael J. Wysocki
@ 2014-10-09 1:18 ` Lan Tianyu
2014-10-22 6:06 ` Lan Tianyu
1 sibling, 1 reply; 8+ messages in thread
From: Lan Tianyu @ 2014-10-09 1:18 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mingo, rafael.j.wysocki, toshi.kani, akpm, ktkhai, fabf, laijs,
srivatsa.bhat, ego, srivatsa, viresh.kumar, todd.e.brandt, tipbot,
wangyun, linux-kernel, linux-pm, Thomas Gleixner
On 2014年10月09日 04:54, Peter Zijlstra wrote:
> On Thu, Sep 25, 2014 at 04:32:02PM +0800, Lan Tianyu wrote:
>> This patchset is to parallel enabling nonboot cpus with resuming devices
>> during system resume in order to accelerate S2RAM. From test result on
>> a 8 logical core Haswell machine, system resume time reduces from 347ms
>> to 217ms with this patchset.
>>
>> In the current world, all nonboot cpus are enabled 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 wastes cpu usage.
>>
>> 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.
>
> So I feel we should really clean up hotplug before doing anything like
> this. Its a trainwreck and just piling more and more hacks ontop isn't
> going to help any.
>
Hi Peter:
Sorry, I don't know the gap of hotplug clearly. Could you elaborate it?
--
Best regards
Tianyu Lan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices
2014-10-09 1:18 ` Lan Tianyu
@ 2014-10-22 6:06 ` Lan Tianyu
0 siblings, 0 replies; 8+ messages in thread
From: Lan Tianyu @ 2014-10-22 6:06 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mingo, rafael.j.wysocki, toshi.kani, akpm, ktkhai, fabf, laijs,
srivatsa.bhat, ego, srivatsa, viresh.kumar, todd.e.brandt, tipbot,
wangyun, linux-kernel, linux-pm, Thomas Gleixner
On 2014年10月09日 09:18, Lan Tianyu wrote:
> On 2014年10月09日 04:54, Peter Zijlstra wrote:
>> On Thu, Sep 25, 2014 at 04:32:02PM +0800, Lan Tianyu wrote:
>>> This patchset is to parallel enabling nonboot cpus with resuming devices
>>> during system resume in order to accelerate S2RAM. From test result on
>>> a 8 logical core Haswell machine, system resume time reduces from 347ms
>>> to 217ms with this patchset.
>>>
>>> In the current world, all nonboot cpus are enabled 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 wastes cpu usage.
>>>
>>> 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.
>>
>> So I feel we should really clean up hotplug before doing anything like
>> this. Its a trainwreck and just piling more and more hacks ontop isn't
>> going to help any.
>>
>
> Hi Peter:
> Sorry, I don't know the gap of hotplug clearly. Could you elaborate it?
>
Hi Peter:
Could you elaborate the gap of hotplug? Thanks.
--
Best regards
Tianyu Lan
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-10-22 6:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-25 8:32 [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Lan Tianyu
2014-09-25 8:32 ` [RFC PATCH V3 1/3] " Lan Tianyu
2014-09-25 8:32 ` [RFC PATCH V2 2/3] X86/CPU: Initialize MTRR/PAT when each cpu is online during system resume Lan Tianyu
2014-09-25 8:32 ` [RFC PATCH V3 3/3] Cpufreq: Hold cpu_add_remove_lock before change cpufreq_suspended flag Lan Tianyu
2014-10-08 20:54 ` [RFC PATCH V3 0/3] PM/CPU: Parallel enalbing nonboot cpus with resume devices Peter Zijlstra
2014-10-08 22:01 ` Rafael J. Wysocki
2014-10-09 1:18 ` Lan Tianyu
2014-10-22 6:06 ` Lan Tianyu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).