atomic_set(&cpu_counter, 0); atomic_set(&freeze, 1); smp_call_function(smp_pause, NULL, 0, 0); while (atomic_read(&cpu_counter) < (num_online_cpus() - 1)) { cpu_relax(); barrier();
error = 0; cpus_clear(frozen_cpus); printk("Freezing cpus ...\n"); for_each_online_cpu(cpu) { if (cpu == 0) continue; error = cpu_down(cpu); if (!error) { cpu_set(cpu, frozen_cpus); printk("CPU%d is down\n", cpu); continue; } printk("Error taking cpu %d down: %d\n", cpu, error);
void disable_nonboot_cpus(void){	oldmask = current->cpus_allowed;	set_cpus_allowed(current, cpumask_of_cpu(0));	printk("Freezing CPUs (at %d)", raw_smp_processor_id());	current->state = TASK_INTERRUPTIBLE;	schedule_timeout(HZ);	printk("...");	BUG_ON(raw_smp_processor_id() != 0);	/* FIXME: for this to work, all the CPUs must be running	 * "idle" thread (or we deadlock). Is that guaranteed? */	atomic_set(&cpu_counter, 0);	atomic_set(&freeze, 1);	smp_call_function(smp_pause, NULL, 0, 0);	while (atomic_read(&cpu_counter) < (num_online_cpus() - 1)) {		cpu_relax();		barrier();	}	printk("ok\n");}