Skip to content

Commit 8bb7844

Browse files
rjwysockiLinus Torvalds
authored andcommitted
Add suspend-related notifications for CPU hotplug
Since nonboot CPUs are now disabled after tasks and devices have been frozen and the CPU hotplug infrastructure is used for this purpose, we need special CPU hotplug notifications that will help the CPU-hotplug-aware subsystems distinguish normal CPU hotplug events from CPU hotplug events related to a system-wide suspend or resume operation in progress. This patch introduces such notifications and causes them to be used during suspend and resume transitions. It also changes all of the CPU-hotplug-aware subsystems to take these notifications into consideration (for now they are handled in the same way as the corresponding "normal" ones). [oleg@tv-sign.ru: cleanups] Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Cc: Gautham R Shenoy <ego@in.ibm.com> Cc: Pavel Machek <pavel@ucw.cz> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f37bc27 commit 8bb7844

47 files changed

Lines changed: 152 additions & 27 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/cpu-hotplug.txt‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,17 @@ Q: What happens when a CPU is being logically offlined?
217217
A: The following happen, listed in no particular order :-)
218218

219219
- A notification is sent to in-kernel registered modules by sending an event
220-
CPU_DOWN_PREPARE
220+
CPU_DOWN_PREPARE or CPU_DOWN_PREPARE_FROZEN, depending on whether or not the
221+
CPU is being offlined while tasks are frozen due to a suspend operation in
222+
progress
221223
- All process is migrated away from this outgoing CPU to a new CPU
222224
- All interrupts targeted to this CPU is migrated to a new CPU
223225
- timers/bottom half/task lets are also migrated to a new CPU
224226
- Once all services are migrated, kernel calls an arch specific routine
225227
__cpu_disable() to perform arch specific cleanup.
226228
- Once this is successful, an event for successful cleanup is sent by an event
227-
CPU_DEAD.
229+
CPU_DEAD (or CPU_DEAD_FROZEN if tasks are frozen due to a suspend while the
230+
CPU is being offlined).
228231

229232
"It is expected that each service cleans up when the CPU_DOWN_PREPARE
230233
notifier is called, when CPU_DEAD is called its expected there is nothing
@@ -242,9 +245,11 @@ A: This is what you would need in your kernel code to receive notifications.
242245

243246
switch (action) {
244247
case CPU_ONLINE:
248+
case CPU_ONLINE_FROZEN:
245249
foobar_online_action(cpu);
246250
break;
247251
case CPU_DEAD:
252+
case CPU_DEAD_FROZEN:
248253
foobar_dead_action(cpu);
249254
break;
250255
}

‎arch/i386/kernel/cpu/intel_cacheinfo.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,11 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
733733
sys_dev = get_cpu_sysdev(cpu);
734734
switch (action) {
735735
case CPU_ONLINE:
736+
case CPU_ONLINE_FROZEN:
736737
cache_add_dev(sys_dev);
737738
break;
738739
case CPU_DEAD:
740+
case CPU_DEAD_FROZEN:
739741
cache_remove_dev(sys_dev);
740742
break;
741743
}

‎arch/i386/kernel/cpu/mcheck/therm_throt.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,12 @@ static __cpuinit int thermal_throttle_cpu_callback(struct notifier_block *nfb,
137137
mutex_lock(&therm_cpu_lock);
138138
switch (action) {
139139
case CPU_ONLINE:
140+
case CPU_ONLINE_FROZEN:
140141
err = thermal_throttle_add_dev(sys_dev);
141142
WARN_ON(err);
142143
break;
143144
case CPU_DEAD:
145+
case CPU_DEAD_FROZEN:
144146
thermal_throttle_remove_dev(sys_dev);
145147
break;
146148
}

‎arch/i386/kernel/cpuid.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,11 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long ac
169169

170170
switch (action) {
171171
case CPU_ONLINE:
172+
case CPU_ONLINE_FROZEN:
172173
cpuid_device_create(cpu);
173174
break;
174175
case CPU_DEAD:
176+
case CPU_DEAD_FROZEN:
175177
device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
176178
break;
177179
}

‎arch/i386/kernel/microcode.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,13 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
775775
sys_dev = get_cpu_sysdev(cpu);
776776
switch (action) {
777777
case CPU_ONLINE:
778+
case CPU_ONLINE_FROZEN:
778779
case CPU_DOWN_FAILED:
780+
case CPU_DOWN_FAILED_FROZEN:
779781
mc_sysdev_add(sys_dev);
780782
break;
781783
case CPU_DOWN_PREPARE:
784+
case CPU_DOWN_PREPARE_FROZEN:
782785
mc_sysdev_remove(sys_dev);
783786
break;
784787
}

‎arch/i386/kernel/msr.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
153153

154154
switch (action) {
155155
case CPU_ONLINE:
156+
case CPU_ONLINE_FROZEN:
156157
msr_device_create(cpu);
157158
break;
158159
case CPU_DEAD:
160+
case CPU_DEAD_FROZEN:
159161
device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
160162
break;
161163
}

‎arch/ia64/kernel/err_inject.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,11 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
236236
sys_dev = get_cpu_sysdev(cpu);
237237
switch (action) {
238238
case CPU_ONLINE:
239+
case CPU_ONLINE_FROZEN:
239240
err_inject_add_dev(sys_dev);
240241
break;
241242
case CPU_DEAD:
243+
case CPU_DEAD_FROZEN:
242244
err_inject_remove_dev(sys_dev);
243245
break;
244246
}

‎arch/ia64/kernel/palinfo.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,11 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
975975

976976
switch (action) {
977977
case CPU_ONLINE:
978+
case CPU_ONLINE_FROZEN:
978979
create_palinfo_proc_entries(hotcpu);
979980
break;
980981
case CPU_DEAD:
982+
case CPU_DEAD_FROZEN:
981983
remove_palinfo_proc_entries(hotcpu);
982984
break;
983985
}

‎arch/ia64/kernel/salinfo.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
582582
struct salinfo_data *data;
583583
switch (action) {
584584
case CPU_ONLINE:
585+
case CPU_ONLINE_FROZEN:
585586
spin_lock_irqsave(&data_saved_lock, flags);
586587
for (i = 0, data = salinfo_data;
587588
i < ARRAY_SIZE(salinfo_data);
@@ -592,6 +593,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
592593
spin_unlock_irqrestore(&data_saved_lock, flags);
593594
break;
594595
case CPU_DEAD:
596+
case CPU_DEAD_FROZEN:
595597
spin_lock_irqsave(&data_saved_lock, flags);
596598
for (i = 0, data = salinfo_data;
597599
i < ARRAY_SIZE(salinfo_data);

‎arch/ia64/kernel/topology.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,11 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
412412
sys_dev = get_cpu_sysdev(cpu);
413413
switch (action) {
414414
case CPU_ONLINE:
415+
case CPU_ONLINE_FROZEN:
415416
cache_add_dev(sys_dev);
416417
break;
417418
case CPU_DEAD:
419+
case CPU_DEAD_FROZEN:
418420
cache_remove_dev(sys_dev);
419421
break;
420422
}

0 commit comments

Comments
 (0)