PM/CPU: Parallel enalbing nonboot cpus with resume devices
RFC PATCH v2 1/1 PM/CPU: Parallel enalbing nonboot cpus with resume devices
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 waste cpu usage.
To accelerate S3, this patches allows boot cpu to go forward to resume devices after bringing up one nonboot cpu. The nonboot cpu will be in charge of bringing up other cpus. This makes enabling cpu2~x parallel with resuming devices.
---
Change since V1:
Remove PM_PARALLEL_CPU_UP_FOR_SUSPEND kernel config and make
paralleling cpu as default behaviour. Add error handling for failure of the first frozen cpu online.
So far, I just tested the patch on the Intel machines. It's better to test it on the others Arch platforms. Appreciate a lot if some one can help test it.
kernel/cpu.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 12 deletions(-)
kernel/cpu.c +58 -12
@@ -551,8 +551,42 @@ void __weak arch_enable_nonboot_cpus_end(void) { } +static int _cpu_up_with_trace (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; + +cpu_maps_update_begin (); +arch_enable_nonboot_cpus_begin (); + +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (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 */
@@ -563,22 +597,34 @@ 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); -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 ; + error =_cpu_up_with_trace (cpu); +if (cpumask_empty (frozen_cpus)) + goto out; + +if (error) { +/* +* If fail to bring up the first frozen cpus, +* enable the rest frozen cpus on the boot cpu. +*/ +arch_enable_nonboot_cpus_begin (); +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (cpu); } -pr_warn ("Error taking CPU%d up: %d\n" , cpu, error); - } +arch_enable_nonboot_cpus_end (); -arch_enable_nonboot_cpus_end (); + }else { + tsk =kthread_create_on_cpu (async_enable_nonboot_cpus, +NULL , cpu,"async-enable-nonboot-cpus" ); +if (IS_ERR (tsk)) { +pr_err ("Failed to create async enable nonboot cpus thread.\n" ); + goto out; + } -cpumask_clear (frozen_cpus); +kthread_unpark (tsk); + } out:cpu_maps_update_done (); }
Signature · 1 line
1.8.4.rc0.1.g8f6a3e5.dirty
Quoted 17 lines · Lan Tianyu
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 waste cpu usage.
To accelerate S3, this patches allows boot cpu to go forward to resume devices after bringing up one nonboot cpu. The nonboot cpu will be in charge of bringing up other cpus. This makes enabling cpu2~x parallel with resuming devices.
Signed-off-by Lan Tianyu <[email protected]>---
Change since V1:
RemovePM_PARALLEL_CPU_UP_FOR_SUSPENDkernel config and make
paralleling cpu as default behaviour. Add error handling for failure of the first frozen cpu online.
Quoted 4 lines
So far, I just tested the patch on the Intel machines. It's better to test it on the others Arch platforms. Appreciate a lot if some one can help test it.
Hi All:
Any comments on this patch? Thanks.
Quoted 98 lines
kernel/cpu.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 12 deletions(-)kernel/cpu.c +58
-12@@ -551,8 +551,42 @@ void __weak arch_enable_nonboot_cpus_end(void) { } +static int _cpu_up_with_trace (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; + +cpu_maps_update_begin (); +arch_enable_nonboot_cpus_begin (); + +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (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 */ @@ -563,22 +597,34 @@ 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); -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 ; + error =_cpu_up_with_trace (cpu); +if (cpumask_empty (frozen_cpus)) + goto out; + +if (error) { +/* +* If fail to bring up the first frozen cpus, +* enable the rest frozen cpus on the boot cpu. +*/ +arch_enable_nonboot_cpus_begin (); +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (cpu); } -pr_warn ("Error taking CPU%d up: %d\n" , cpu, error); - } +arch_enable_nonboot_cpus_end (); -arch_enable_nonboot_cpus_end (); + }else { + tsk =kthread_create_on_cpu (async_enable_nonboot_cpus, +NULL , cpu,"async-enable-nonboot-cpus" ); +if (IS_ERR (tsk)) { +pr_err ("Failed to create async enable nonboot cpus thread.\n" ); + goto out; + } -cpumask_clear (frozen_cpus); +kthread_unpark (tsk); + } out:cpu_maps_update_done (); }
Signature · 2 lines
Best regards Tianyu Lan
Quoted 18 lines · Lan Tianyu
Quoted 17 lines · Lan Tianyu
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 waste cpu usage.
To accelerate S3, this patches allows boot cpu to go forward to resume devices after bringing up one nonboot cpu. The nonboot cpu will be in charge of bringing up other cpus. This makes enabling cpu2~x parallel with resuming devices.
Signed-off-by Lan Tianyu <[email protected]>---
Change since V1:
RemovePM_PARALLEL_CPU_UP_FOR_SUSPENDkernel config and make
paralleling cpu as default behaviour. Add error handling for failure of the first frozen cpu online.
Quoted 6 lines
Quoted 4 lines
So far, I just tested the patch on the Intel machines. It's better to test it on the others Arch platforms. Appreciate a lot if some one can help test it.
Hi All:
Any comments on this patch? Thanks.
You need to ensure that the async thing completes before cpufreq_resume() or bad things will happen I think.
Quoted 11 lines
Quoted 11 lines
kernel/cpu.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 12 deletions(-)kernel/cpu.c +0
-0@@ -551,8 +551,42 @@ void __weak arch_enable_nonboot_cpus_end(void) { }
Quoted 1 line
kernel/cpu.c void __weak arch_enable_nonboot_cpus_end(void) · line 554
Quoted 1 line
kernel/cpu.c +1
-0+static int _cpu_up_with_trace (int cpu)
Better name?
Quoted 13 lines
Quoted 13 lines
kernel/cpu.c +13
-0+{ +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 ;
Quoted 8 lines
kernel/cpu.c void __weak arch_enable_nonboot_cpus_end(void) · line 575
Quoted 8 lines
kernel/cpu.c +8
-0+} + +static int async_enable_nonboot_cpus (void *data) +{ +int cpu; + +cpu_maps_update_begin (); +arch_enable_nonboot_cpus_begin ();
Shouldn't you call this before trying to bring up the first one?
Quoted 49 lines
Quoted 49 lines
kernel/cpu.c +27
-10+ +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (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 */ @@ -563,22 +597,34 @@ 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); -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 ; + error =_cpu_up_with_trace (cpu); +if (cpumask_empty (frozen_cpus)) + goto out; + +if (error) { +/* +* If fail to bring up the first frozen cpus, +* enable the rest frozen cpus on the boot cpu. +*/ +arch_enable_nonboot_cpus_begin (); +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (cpu); } -pr_warn ("Error taking CPU%d up: %d\n" , cpu, error); - } +arch_enable_nonboot_cpus_end ();
Quoted 4 lines
kernel/cpu.c void __ref enable_nonboot_cpus(void) · line 620
Quoted 4 lines
kernel/cpu.c +3
-1-arch_enable_nonboot_cpus_end (); + }else { + tsk =kthread_create_on_cpu (async_enable_nonboot_cpus, +NULL , cpu,"async-enable-nonboot-cpus" );
Does it really need to run on the other CPU? If the idea is to avoid waiting mostly, the async thread can start running on the boot CPU just fine I suppose.
Quoted 5 lines
Quoted 5 lines
kernel/cpu.c +4
-0+if (IS_ERR (tsk)) { +pr_err ("Failed to create async enable nonboot cpus thread.\n" ); + goto out; + }
Quoted 8 lines
kernel/cpu.c void __ref enable_nonboot_cpus(void) · line 630
Quoted 7 lines
kernel/cpu.c +2
-1-cpumask_clear (frozen_cpus); +kthread_unpark (tsk); + } out:cpu_maps_update_done (); }
Rafael
Quoted 27 lines · Rafael J. Wysocki
Quoted 26 lines · Lan Tianyu
Quoted 25 lines · Lan Tianyu
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 waste cpu usage.To accelerate S3, this patches allows boot cpu to go forward to resume devices after bringing up one nonboot cpu. The nonboot cpu will be in charge of bringing up other cpus. This makes enabling cpu2~x parallel with resuming devices.
Signed-off-by Lan Tianyu <[email protected]>---
Change since V1:
RemovePM_PARALLEL_CPU_UP_FOR_SUSPENDkernel config and make
paralleling cpu as default behaviour. Add error handling for failure of the first frozen cpu online.So far, I just tested the patch on the Intel machines. It's better to test it on the others Arch platforms. Appreciate a lot if some one can help test it.
Quoted 6 lines
Quoted 2 lines
Hi All:
Any comments on this patch? Thanks.You need to ensure that the async thing completes before
cpufreq_resume()or bad things will happen I think.
Hi Rafael:
Thanks for reminder. You are right. I checked cpufreq code andcpufreq_suspend will be set to false in the cpufreq_resume(). If cpu online is later than cpufreq_resume() and cpufreq policy on the cpu will not be recovered since cpufreq_suspend has been cleared. cpu_maps_update_begin() can be used to wait all cpu online before clearing cpufreq_suspend.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
kernel/cpu.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 12 deletions(-)
Quoted 10 lines
Quoted 8 lines
kernel/cpu.c void __weak arch_enable_nonboot_cpus_end(void) · line 553
Quoted 8 lines
kernel/cpu.c +0
-0@@ -551,8 +551,42 @@ void __weak arch_enable_nonboot_cpus_end(void) { } +static int _cpu_up_with_trace(int cpu)Better name?
How about _cpu_up_for_pm? The new function is only called during suspend and hibernation.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
kernel/cpu.c +15
-0+{ +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 ; +} +
Quoted 8 lines
Quoted 6 lines
kernel/cpu.c void __weak arch_enable_nonboot_cpus_end(void) · line 575
Quoted 6 lines
kernel/cpu.c +6
-0+static int async_enable_nonboot_cpus (void *data) +{ +int cpu; + +cpu_maps_update_begin (); +arch_enable_nonboot_cpus_begin ();Shouldn't you call this before trying to bring up the first one?
arch_enable_nonboot_cpus_begin() is just to set a mtrr_aps_delayed_init flag in the mtrr code to delay all init mtrr during the following cpu online. arch_enable_nonboot_cpus_done() will do init mtrr on the all cpus.
According SDM 11.11.8, all processors must have the same MTRR values. Original model of system resume is that all cpus are online serially, delay all init mtrr when one nonboot cpu is online and do it for all cpus at the end of enabling nonboot cpus. In the parallel situation, nonboot cpu will have task before all cpus online. So it's necessary to do init mtrr when the target cpu is online.
Actually from my opinion, arch_enable_nonboot_cpus_begin/done() should not use in the parallel case. I plan to write another patch to do it.
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
kernel/cpu.c +27
-8+ +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (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 */ @@ -563,22 +597,34 @@ 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); - 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 ; + error =_cpu_up_with_trace (cpu); +if (cpumask_empty (frozen_cpus)) + goto out; + +if (error) { +/* +* If fail to bring up the first frozen cpus, +* enable the rest frozen cpus on the boot cpu. +*/ +arch_enable_nonboot_cpus_begin (); +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (cpu); } -pr_warn ("Error taking CPU%d up: %d\n" , cpu, error); - } +arch_enable_nonboot_cpus_end ();
Quoted 8 lines
Quoted 4 lines
kernel/cpu.c void __ref enable_nonboot_cpus(void) · line 620
Quoted 4 lines
kernel/cpu.c +3
-0-arch_enable_nonboot_cpus_end (); + }else { + tsk =kthread_create_on_cpu (async_enable_nonboot_cpus, +NULL , cpu,"async-enable-nonboot-cpus" );Does it really need to run on the other CPU? If the idea is to avoid waiting mostly, the async thread can start running on the boot CPU just fine I suppose.
Running "enabling nonboot cpu" on the other CPU dedicates to avoid disturbing the start of resume task. If two threads run on one CPU, they will compete for CPU resource. Generally, when cpu1 up and there are two threads, they should run respectively on the cpu0 and cpu1. Any way, I will do test to compare the difference.
Thanks for review.
Quoted 17 lines
Quoted 14 lines
kernel/cpu.c void __ref enable_nonboot_cpus(void) · line 630
Quoted 13 lines
kernel/cpu.c +6
-0+if (IS_ERR (tsk)) { + pr_err("Failed to create async enable nonboot cpus thread.\n"); + goto out; + } -cpumask_clear (frozen_cpus); +kthread_unpark (tsk); + } out:cpu_maps_update_done (); }Rafael
Signature · 2 lines
Best regards Tianyu Lan
Hi Lan,
Sorry missed this repost! Couple of comments.
On Fri, Aug 22, 2014 at 04:33:40PM +0800, Lan Tianyu wrote:
[.. snip ..]
Quoted 46 lines
kernel/cpu.c +35
-1+static int _cpu_up_with_trace (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; + +cpu_maps_update_begin (); +arch_enable_nonboot_cpus_begin (); + +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (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 */ @@ -563,22 +597,34 @@ void __ref enable_nonboot_cpus(void)pr_info ("Enabling non-boot CPUs ...\n" ); -arch_enable_nonboot_cpus_begin (); + cpu =cpumask_first (frozen_cpus);
kernel/cpu.c void __ref enable_nonboot_cpus(void) · line 603
Quoted 10 lines
kernel/cpu.c +2
-7+cpumask_clear_cpu (cpu, frozen_cpus); -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 ; + error =_cpu_up_with_trace (cpu);
If cpu fails to come up, you need to add a pr_warn() citing the reason why it failed to come up.
Quoted 13 lines
kernel/cpu.c +11
-1+if (cpumask_empty (frozen_cpus)) + goto out; + +if (error) { +/* +* If fail to bring up the first frozen cpus, +* enable the rest frozen cpus on the boot cpu. +*/ +arch_enable_nonboot_cpus_begin (); +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (cpu); } -pr_warn ("Error taking CPU%d up: %d\n" , cpu, error);
kernel/cpu.c void __ref enable_nonboot_cpus(void) · line 623
Quoted 10 lines
kernel/cpu.c +7
-2- } +arch_enable_nonboot_cpus_end (); -arch_enable_nonboot_cpus_end (); + }else { + tsk =kthread_create_on_cpu (async_enable_nonboot_cpus, +NULL , cpu,"async-enable-nonboot-cpus" ); +if (IS_ERR (tsk)) { +pr_err ("Failed to create async enable nonboot cpus thread.\n" ); + goto out;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is not good. If you fail to create a kthread on the first non-boot cpu, that means none of the other non-boot cpus will be brought up.
Hence you might want to consider reordering the code in such a manner that if the first non-boot cpu fails to come up or if you fail to create the kthread task, then the boot cpu will boot the remaining non boot cpus.
--
Thanks and Regards
gautham.
Quoted 4 lines · Gautham R Shenoy
Hi Lan,
Sorry missed this repost! Couple of comments.
Np, Thanks for review :)
Quoted 51 lines · Lan Tianyu
[.. snip ..]
Quoted 48 lines
kernel/cpu.c +36
-1+static int _cpu_up_with_trace (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; + +cpu_maps_update_begin (); +arch_enable_nonboot_cpus_begin (); + +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (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 */ @@ -563,22 +597,34 @@ 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);
Quoted 11 lines
kernel/cpu.c void __ref enable_nonboot_cpus(void) · line 603
Quoted 8 lines
kernel/cpu.c +1
-7-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 ; + error =_cpu_up_with_trace (cpu);If cpu fails to come up, you need to add a
pr_warn()citing the reason why it failed to come up.
Ok.
Quoted 30 lines
Quoted 15 lines
kernel/cpu.c +11
-1+if (cpumask_empty (frozen_cpus)) + goto out; + +if (error) { +/* +* If fail to bring up the first frozen cpus, +* enable the rest frozen cpus on the boot cpu. +*/ +arch_enable_nonboot_cpus_begin (); +for_each_cpu (cpu, frozen_cpus) { +_cpu_up_with_trace (cpu); } -pr_warn ("Error taking CPU%d up: %d\n" , cpu, error);kernel/cpu.c void __ref enable_nonboot_cpus(void) · line 623
Quoted 10 lines
kernel/cpu.c +7
-2- } +arch_enable_nonboot_cpus_end (); -arch_enable_nonboot_cpus_end (); + }else { + tsk =kthread_create_on_cpu (async_enable_nonboot_cpus, +NULL , cpu,"async-enable-nonboot-cpus" ); +if (IS_ERR (tsk)) { +pr_err ("Failed to create async enable nonboot cpus thread.\n" ); + goto out;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is not good. If you fail to create a kthread on the first non-boot cpu, that means none of the other non-boot cpus will be brought up.
Quoted 4 lines
Hence you might want to consider reordering the code in such a manner that if the first non-boot cpu fails to come up or if you fail to create the kthread task, then the boot cpu will boot the remaining non boot cpus.
Yes, this sounds good and will do it in the new version.
Quoted 5 lines
--
Thanks and Regards
gautham.
Signature · 2 lines
Best regards Tianyu Lan