Lines Matching refs:the

1 Interaction of Suspend code (S3) with the CPU hotplug infrastructure
6 I. How does the regular CPU hotplug code differ from how the Suspend-to-RAM
11 [This depicts the current design in the kernel, and focusses only on the
12 interactions involving the freezer and CPU hotplug and also tries to explain
13 the locking involved. It outlines the notifications involved as well.
14 But please note that here, only the call paths are illustrated, with the aim
19 On a high level, the suspend-resume cycle goes like this:
61 Common | before taking down the CPU |
88 Resuming back is likewise, with the counterparts being (in the order of
93 | Call _cpu_up() [for all those cpus in the frozen_cpus mask, in a loop]
102 It is to be noted here that the pm_mutex lock is acquired at the very
104 after the entire cycle is complete (i.e., suspend + resume).
130 Common | before taking down the CPU
144 So, as can be seen from the two diagrams (the parts marked as "Common code"),
145 regular CPU hotplug and the suspend code path converge at the _cpu_down() and
146 _cpu_up() functions. They differ in the arguments passed to these functions,
147 in that during regular CPU hotplug, 0 is passed for the 'tasks_frozen'
148 argument. But during suspend, since the tasks are already frozen by the time
149 the non-boot CPUs are offlined or onlined, the _cpu_*() functions are called
150 with the 'tasks_frozen' argument set to 1.
163 II. What are the issues involved in CPU hotplug?
167 update on the CPUs, as discussed below:
169 [Please bear in mind that the kernel requests the microcode images from
170 userspace, using the request_firmware() function defined in
174 a. When all the CPUs are identical:
176 This is the most common situation and it is quite straightforward: we want
177 to apply the same microcode revision to each of the CPUs.
178 To give an example of x86, the collect_cpu_info() function defined in
179 arch/x86/kernel/microcode_core.c helps in discovering the type of the CPU
180 and thereby in applying the correct microcode revision to it.
181 But note that the kernel does not maintain a common microcode image for the
185 b. When some of the CPUs are different than the rest:
188 to different CPUs, the kernel maintains a copy of the correct microcode
194 type of) CPU is hot-plugged into the system:
196 In the current design of the kernel, whenever a CPU is taken offline during
197 a regular CPU hotplug operation, upon receiving the CPU_DEAD notification
198 (which is sent by the CPU hotplug code), the microcode update driver's
199 callback for that event reacts by freeing the kernel's copy of the
202 Hence, when a new CPU is brought online, since the kernel finds that it
203 doesn't have the microcode image, it does the CPU type/model discovery
204 afresh and then requests the userspace for the appropriate microcode image
207 For example, in x86, the mc_cpu_callback() function (which is the microcode
210 instead of microcode_resume_cpu() when it finds that the kernel doesn't
211 have a valid microcode image. This ensures that the CPU type/model
212 discovery is performed and the right microcode is applied to the CPU after
219 physically removing or inserting CPUs, the CPUs are not actually powered
220 off during a CPU offline. They are just put to the lowest C-states possible.
222 when the CPUs are brought back online, since they wouldn't have lost the
223 image during the CPU offline operation.
225 This is the usual scenario encountered during a resume after a suspend.
226 However, in the case of hibernation, since all the CPUs are completely
227 powered off, during restore it becomes necessary to apply the microcode
228 images to all the CPUs.
234 In the current design of the kernel however, during a CPU offline operation
235 as part of the suspend/hibernate cycle (the CPU_DEAD_FROZEN notification),
236 the existing copy of microcode image in the kernel is not freed up.
237 And during the CPU online operations (during resume/restore), since the
238 kernel finds that it already has copies of the microcode images for all the
239 CPUs, it just applies them to the CPUs, avoiding any re-discovery of CPU
240 type/model and the need for validating whether the microcode revisions are
241 right for the CPUs or not (due to the above assumption that physical CPU
251 1. When invoking regular CPU hotplug, the 'tasks_frozen' argument passed to
252 the _cpu_down() and _cpu_up() functions is *always* 0.
253 This might not reflect the true current state of the system, since the
256 sent during the cpu online/offline events (eg, CPU_ONLINE notification
258 inappropriate code by the callbacks registered for such CPU hotplug events.
260 2. If a regular CPU hotplug stress test happens to race with the freezer due
261 to a suspend operation in progress at the same time, then we could hit the
265 into the kernel, since the freezing has not yet begun.
267 * If cpu online has not yet completed the microcode update stuff by now,
268 it will now start waiting on the frozen userspace in the
269 TASK_UNINTERRUPTIBLE state, in order to get the microcode image.
270 * Now the freezer continues and tries to freeze the remaining tasks. But
271 due to this wait mentioned above, the freezer won't be able to freeze
272 the cpu online hotplug task and hence freezing of tasks fails.
274 As a result of this task freezing failure, the suspend operation gets