Lines Matching full:cpu

1 /* CPU control.
12 #include <linux/cpu.h>
52 * an ongoing cpu hotplug operation.
89 * Note that during a cpu-hotplug operation, the new readers, if any,
174 static inline void check_for_tasks(int cpu) in check_for_tasks() argument
180 if (task_cpu(p) == cpu && p->state == TASK_RUNNING && in check_for_tasks()
182 printk(KERN_WARNING "Task %s (pid = %d) is on cpu %d " in check_for_tasks()
184 p->comm, task_pid_nr(p), cpu, in check_for_tasks()
195 /* Take this CPU down. */
201 /* Ensure this CPU doesn't handle any more interrupts. */ in take_cpu_down()
211 static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) in _cpu_down() argument
214 void *hcpu = (void *)(long)cpu; in _cpu_down()
224 if (!cpu_online(cpu)) in _cpu_down()
233 printk("%s: attempt to take down CPU %u failed\n", in _cpu_down()
234 __func__, cpu); in _cpu_down()
238 err = __stop_machine(take_cpu_down, &tcd_param, cpumask_of(cpu)); in _cpu_down()
240 /* CPU didn't die: tell everyone. Can't complain. */ in _cpu_down()
245 BUG_ON(cpu_online(cpu)); in _cpu_down()
249 * runnable tasks from the cpu, there's only the idle task left now in _cpu_down()
254 while (!idle_cpu(cpu)) in _cpu_down()
257 /* This actually kills the CPU. */ in _cpu_down()
258 __cpu_die(cpu); in _cpu_down()
260 /* CPU is completely dead: tell everyone. Too late to complain. */ in _cpu_down()
263 check_for_tasks(cpu); in _cpu_down()
272 int __ref cpu_down(unsigned int cpu) in cpu_down() argument
283 err = _cpu_down(cpu, 0); in cpu_down()
293 static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen) in _cpu_up() argument
296 void *hcpu = (void *)(long)cpu; in _cpu_up()
299 if (cpu_online(cpu) || !cpu_present(cpu)) in _cpu_up()
306 printk(KERN_WARNING "%s: attempt to bring up CPU %u failed\n", in _cpu_up()
307 __func__, cpu); in _cpu_up()
312 ret = __cpu_up(cpu); in _cpu_up()
315 BUG_ON(!cpu_online(cpu)); in _cpu_up()
328 int __cpuinit cpu_up(unsigned int cpu) in cpu_up() argument
337 if (!cpu_possible(cpu)) { in cpu_up()
338 printk(KERN_ERR "can't online cpu %d because it is not " in cpu_up()
339 "configured as may-hotadd at boot time\n", cpu); in cpu_up()
348 nid = cpu_to_node(cpu); in cpu_up()
358 "Can't online cpu %d due to NULL pgdat\n", cpu); in cpu_up()
376 err = _cpu_up(cpu, 0); in cpu_up()
397 int cpu, first_cpu, error = 0; in disable_nonboot_cpus() local
403 * with the userspace trying to use the CPU hotplug at the same time in disable_nonboot_cpus()
409 for_each_online_cpu(cpu) { in disable_nonboot_cpus()
410 if (cpu == first_cpu) in disable_nonboot_cpus()
412 error = _cpu_down(cpu, 1); in disable_nonboot_cpus()
414 cpumask_set_cpu(cpu, frozen_cpus); in disable_nonboot_cpus()
416 printk(KERN_ERR "Error taking CPU%d down: %d\n", in disable_nonboot_cpus()
417 cpu, error); in disable_nonboot_cpus()
445 int cpu, error; in enable_nonboot_cpus() local
447 /* Allow everyone to use the CPU hotplug again */ in enable_nonboot_cpus()
457 for_each_cpu(cpu, frozen_cpus) { in enable_nonboot_cpus()
458 error = _cpu_up(cpu, 1); in enable_nonboot_cpus()
460 printk(KERN_INFO "CPU%d is up\n", cpu); in enable_nonboot_cpus()
463 printk(KERN_WARNING "Error taking CPU%d up: %d\n", cpu, error); in enable_nonboot_cpus()
482 * Prevent regular CPU hotplug from racing with the freezer, by disabling CPU
484 * to continue until any currently running CPU hotplug operation gets
488 * CPU hotplug path and released only after it is complete. Thus, we
489 * (and hence the freezer) will block here until any currently running CPU
501 * When tasks have been thawed, re-enable regular CPU hotplug (which had been
512 * When callbacks for CPU hotplug notifications are being executed, we must
516 * Hence we need to prevent the freezer from racing with regular CPU hotplug.
518 * This synchronization is implemented by mutually excluding regular CPU
556 * notify_cpu_starting(cpu) - call the CPU_STARTING notifiers
557 * @cpu: cpu that just started
560 * It must be called by the arch code on the new cpu, before the new cpu
561 * enables interrupts and before the "boot" cpu returns from __cpu_up().
563 void __cpuinit notify_cpu_starting(unsigned int cpu) in notify_cpu_starting() argument
568 if (frozen_cpus != NULL && cpumask_test_cpu(cpu, frozen_cpus)) in notify_cpu_starting()
571 cpu_notify(val, (void *)(long)cpu); in notify_cpu_starting()
580 * It is used by cpumask_of() to get a constant address to a CPU
625 void set_cpu_possible(unsigned int cpu, bool possible) in set_cpu_possible() argument
628 cpumask_set_cpu(cpu, to_cpumask(cpu_possible_bits)); in set_cpu_possible()
630 cpumask_clear_cpu(cpu, to_cpumask(cpu_possible_bits)); in set_cpu_possible()
633 void set_cpu_present(unsigned int cpu, bool present) in set_cpu_present() argument
636 cpumask_set_cpu(cpu, to_cpumask(cpu_present_bits)); in set_cpu_present()
638 cpumask_clear_cpu(cpu, to_cpumask(cpu_present_bits)); in set_cpu_present()
641 void set_cpu_online(unsigned int cpu, bool online) in set_cpu_online() argument
644 cpumask_set_cpu(cpu, to_cpumask(cpu_online_bits)); in set_cpu_online()
646 cpumask_clear_cpu(cpu, to_cpumask(cpu_online_bits)); in set_cpu_online()
649 void set_cpu_active(unsigned int cpu, bool active) in set_cpu_active() argument
652 cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits)); in set_cpu_active()
654 cpumask_clear_cpu(cpu, to_cpumask(cpu_active_bits)); in set_cpu_active()