11da177e4SLinus Torvalds /* CPU control. 21da177e4SLinus Torvalds * (C) 2001, 2002, 2003, 2004 Rusty Russell 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * This code is licenced under the GPL. 51da177e4SLinus Torvalds */ 61da177e4SLinus Torvalds #include <linux/proc_fs.h> 71da177e4SLinus Torvalds #include <linux/smp.h> 81da177e4SLinus Torvalds #include <linux/init.h> 91da177e4SLinus Torvalds #include <linux/notifier.h> 101da177e4SLinus Torvalds #include <linux/sched.h> 111da177e4SLinus Torvalds #include <linux/unistd.h> 121da177e4SLinus Torvalds #include <linux/cpu.h> 13cb79295eSAnton Vorontsov #include <linux/oom.h> 14cb79295eSAnton Vorontsov #include <linux/rcupdate.h> 159984de1aSPaul Gortmaker #include <linux/export.h> 16e4cc2f87SAnton Vorontsov #include <linux/bug.h> 171da177e4SLinus Torvalds #include <linux/kthread.h> 181da177e4SLinus Torvalds #include <linux/stop_machine.h> 1981615b62SIngo Molnar #include <linux/mutex.h> 205a0e3ad6STejun Heo #include <linux/gfp.h> 2179cfbdfaSSrivatsa S. Bhat #include <linux/suspend.h> 221da177e4SLinus Torvalds 2338498a67SThomas Gleixner #include "smpboot.h" 2438498a67SThomas Gleixner 2598a79d6aSRusty Russell #ifdef CONFIG_SMP 26b3199c02SRusty Russell /* Serializes the updates to cpu_online_mask, cpu_present_mask */ 27aa953877SLinus Torvalds static DEFINE_MUTEX(cpu_add_remove_lock); 281da177e4SLinus Torvalds 2979a6cdebSLai Jiangshan /* 3079a6cdebSLai Jiangshan * The following two API's must be used when attempting 3179a6cdebSLai Jiangshan * to serialize the updates to cpu_online_mask, cpu_present_mask. 3279a6cdebSLai Jiangshan */ 3379a6cdebSLai Jiangshan void cpu_maps_update_begin(void) 3479a6cdebSLai Jiangshan { 3579a6cdebSLai Jiangshan mutex_lock(&cpu_add_remove_lock); 3679a6cdebSLai Jiangshan } 3779a6cdebSLai Jiangshan 3879a6cdebSLai Jiangshan void cpu_maps_update_done(void) 3979a6cdebSLai Jiangshan { 4079a6cdebSLai Jiangshan mutex_unlock(&cpu_add_remove_lock); 4179a6cdebSLai Jiangshan } 4279a6cdebSLai Jiangshan 435c113fbeSDaniel J Blueman static RAW_NOTIFIER_HEAD(cpu_chain); 441da177e4SLinus Torvalds 45e3920fb4SRafael J. Wysocki /* If set, cpu_up and cpu_down will return -EBUSY and do nothing. 46e3920fb4SRafael J. Wysocki * Should always be manipulated under cpu_add_remove_lock 47e3920fb4SRafael J. Wysocki */ 48e3920fb4SRafael J. Wysocki static int cpu_hotplug_disabled; 49e3920fb4SRafael J. Wysocki 5079a6cdebSLai Jiangshan #ifdef CONFIG_HOTPLUG_CPU 5179a6cdebSLai Jiangshan 52d221938cSGautham R Shenoy static struct { 53d221938cSGautham R Shenoy struct task_struct *active_writer; 54d221938cSGautham R Shenoy struct mutex lock; /* Synchronizes accesses to refcount, */ 55d221938cSGautham R Shenoy /* 56d221938cSGautham R Shenoy * Also blocks the new readers during 57d221938cSGautham R Shenoy * an ongoing cpu hotplug operation. 58d221938cSGautham R Shenoy */ 59d221938cSGautham R Shenoy int refcount; 6031950eb6SLinus Torvalds } cpu_hotplug = { 6131950eb6SLinus Torvalds .active_writer = NULL, 6231950eb6SLinus Torvalds .lock = __MUTEX_INITIALIZER(cpu_hotplug.lock), 6331950eb6SLinus Torvalds .refcount = 0, 6431950eb6SLinus Torvalds }; 65d221938cSGautham R Shenoy 6686ef5c9aSGautham R Shenoy void get_online_cpus(void) 67a9d9baa1SAshok Raj { 68d221938cSGautham R Shenoy might_sleep(); 69d221938cSGautham R Shenoy if (cpu_hotplug.active_writer == current) 70aa953877SLinus Torvalds return; 71d221938cSGautham R Shenoy mutex_lock(&cpu_hotplug.lock); 72d221938cSGautham R Shenoy cpu_hotplug.refcount++; 73d221938cSGautham R Shenoy mutex_unlock(&cpu_hotplug.lock); 74d221938cSGautham R Shenoy 75a9d9baa1SAshok Raj } 7686ef5c9aSGautham R Shenoy EXPORT_SYMBOL_GPL(get_online_cpus); 77a9d9baa1SAshok Raj 7886ef5c9aSGautham R Shenoy void put_online_cpus(void) 79a9d9baa1SAshok Raj { 80d221938cSGautham R Shenoy if (cpu_hotplug.active_writer == current) 81aa953877SLinus Torvalds return; 82d221938cSGautham R Shenoy mutex_lock(&cpu_hotplug.lock); 83075663d1SSrivatsa S. Bhat 84075663d1SSrivatsa S. Bhat if (WARN_ON(!cpu_hotplug.refcount)) 85075663d1SSrivatsa S. Bhat cpu_hotplug.refcount++; /* try to fix things up */ 86075663d1SSrivatsa S. Bhat 87d2ba7e2aSOleg Nesterov if (!--cpu_hotplug.refcount && unlikely(cpu_hotplug.active_writer)) 88d2ba7e2aSOleg Nesterov wake_up_process(cpu_hotplug.active_writer); 89d221938cSGautham R Shenoy mutex_unlock(&cpu_hotplug.lock); 90d221938cSGautham R Shenoy 91a9d9baa1SAshok Raj } 9286ef5c9aSGautham R Shenoy EXPORT_SYMBOL_GPL(put_online_cpus); 93a9d9baa1SAshok Raj 94d221938cSGautham R Shenoy /* 95d221938cSGautham R Shenoy * This ensures that the hotplug operation can begin only when the 96d221938cSGautham R Shenoy * refcount goes to zero. 97d221938cSGautham R Shenoy * 98d221938cSGautham R Shenoy * Note that during a cpu-hotplug operation, the new readers, if any, 99d221938cSGautham R Shenoy * will be blocked by the cpu_hotplug.lock 100d221938cSGautham R Shenoy * 101d2ba7e2aSOleg Nesterov * Since cpu_hotplug_begin() is always called after invoking 102d2ba7e2aSOleg Nesterov * cpu_maps_update_begin(), we can be sure that only one writer is active. 103d221938cSGautham R Shenoy * 104d221938cSGautham R Shenoy * Note that theoretically, there is a possibility of a livelock: 105d221938cSGautham R Shenoy * - Refcount goes to zero, last reader wakes up the sleeping 106d221938cSGautham R Shenoy * writer. 107d221938cSGautham R Shenoy * - Last reader unlocks the cpu_hotplug.lock. 108d221938cSGautham R Shenoy * - A new reader arrives at this moment, bumps up the refcount. 109d221938cSGautham R Shenoy * - The writer acquires the cpu_hotplug.lock finds the refcount 110d221938cSGautham R Shenoy * non zero and goes to sleep again. 111d221938cSGautham R Shenoy * 112d221938cSGautham R Shenoy * However, this is very difficult to achieve in practice since 11386ef5c9aSGautham R Shenoy * get_online_cpus() not an api which is called all that often. 114d221938cSGautham R Shenoy * 115d221938cSGautham R Shenoy */ 116d221938cSGautham R Shenoy static void cpu_hotplug_begin(void) 117d221938cSGautham R Shenoy { 118d221938cSGautham R Shenoy cpu_hotplug.active_writer = current; 119d2ba7e2aSOleg Nesterov 120d2ba7e2aSOleg Nesterov for (;;) { 121d2ba7e2aSOleg Nesterov mutex_lock(&cpu_hotplug.lock); 122d2ba7e2aSOleg Nesterov if (likely(!cpu_hotplug.refcount)) 123d2ba7e2aSOleg Nesterov break; 124d2ba7e2aSOleg Nesterov __set_current_state(TASK_UNINTERRUPTIBLE); 125d221938cSGautham R Shenoy mutex_unlock(&cpu_hotplug.lock); 126d221938cSGautham R Shenoy schedule(); 127d221938cSGautham R Shenoy } 128d221938cSGautham R Shenoy } 129d221938cSGautham R Shenoy 130d221938cSGautham R Shenoy static void cpu_hotplug_done(void) 131d221938cSGautham R Shenoy { 132d221938cSGautham R Shenoy cpu_hotplug.active_writer = NULL; 133d221938cSGautham R Shenoy mutex_unlock(&cpu_hotplug.lock); 134d221938cSGautham R Shenoy } 13579a6cdebSLai Jiangshan 13616e53dbfSSrivatsa S. Bhat /* 13716e53dbfSSrivatsa S. Bhat * Wait for currently running CPU hotplug operations to complete (if any) and 13816e53dbfSSrivatsa S. Bhat * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects 13916e53dbfSSrivatsa S. Bhat * the 'cpu_hotplug_disabled' flag. The same lock is also acquired by the 14016e53dbfSSrivatsa S. Bhat * hotplug path before performing hotplug operations. So acquiring that lock 14116e53dbfSSrivatsa S. Bhat * guarantees mutual exclusion from any currently running hotplug operations. 14216e53dbfSSrivatsa S. Bhat */ 14316e53dbfSSrivatsa S. Bhat void cpu_hotplug_disable(void) 14416e53dbfSSrivatsa S. Bhat { 14516e53dbfSSrivatsa S. Bhat cpu_maps_update_begin(); 14616e53dbfSSrivatsa S. Bhat cpu_hotplug_disabled = 1; 14716e53dbfSSrivatsa S. Bhat cpu_maps_update_done(); 14816e53dbfSSrivatsa S. Bhat } 14916e53dbfSSrivatsa S. Bhat 15016e53dbfSSrivatsa S. Bhat void cpu_hotplug_enable(void) 15116e53dbfSSrivatsa S. Bhat { 15216e53dbfSSrivatsa S. Bhat cpu_maps_update_begin(); 15316e53dbfSSrivatsa S. Bhat cpu_hotplug_disabled = 0; 15416e53dbfSSrivatsa S. Bhat cpu_maps_update_done(); 15516e53dbfSSrivatsa S. Bhat } 15616e53dbfSSrivatsa S. Bhat 15779a6cdebSLai Jiangshan #else /* #if CONFIG_HOTPLUG_CPU */ 15879a6cdebSLai Jiangshan static void cpu_hotplug_begin(void) {} 15979a6cdebSLai Jiangshan static void cpu_hotplug_done(void) {} 16025985edcSLucas De Marchi #endif /* #else #if CONFIG_HOTPLUG_CPU */ 16179a6cdebSLai Jiangshan 1621da177e4SLinus Torvalds /* Need to know about CPUs going up/down? */ 163f7b16c10SSam Ravnborg int __ref register_cpu_notifier(struct notifier_block *nb) 1641da177e4SLinus Torvalds { 165bd5349cfSNeil Brown int ret; 166d221938cSGautham R Shenoy cpu_maps_update_begin(); 167bd5349cfSNeil Brown ret = raw_notifier_chain_register(&cpu_chain, nb); 168d221938cSGautham R Shenoy cpu_maps_update_done(); 169bd5349cfSNeil Brown return ret; 1701da177e4SLinus Torvalds } 17165edc68cSChandra Seetharaman 172e9fb7631SAkinobu Mita static int __cpu_notify(unsigned long val, void *v, int nr_to_call, 173e9fb7631SAkinobu Mita int *nr_calls) 174e9fb7631SAkinobu Mita { 175e6bde73bSAkinobu Mita int ret; 176e6bde73bSAkinobu Mita 177e6bde73bSAkinobu Mita ret = __raw_notifier_call_chain(&cpu_chain, val, v, nr_to_call, 178e9fb7631SAkinobu Mita nr_calls); 179e6bde73bSAkinobu Mita 180e6bde73bSAkinobu Mita return notifier_to_errno(ret); 181e9fb7631SAkinobu Mita } 182e9fb7631SAkinobu Mita 183e9fb7631SAkinobu Mita static int cpu_notify(unsigned long val, void *v) 184e9fb7631SAkinobu Mita { 185e9fb7631SAkinobu Mita return __cpu_notify(val, v, -1, NULL); 186e9fb7631SAkinobu Mita } 187e9fb7631SAkinobu Mita 18800b9b0afSLinus Torvalds #ifdef CONFIG_HOTPLUG_CPU 18900b9b0afSLinus Torvalds 190e9fb7631SAkinobu Mita static void cpu_notify_nofail(unsigned long val, void *v) 191e9fb7631SAkinobu Mita { 19200b9b0afSLinus Torvalds BUG_ON(cpu_notify(val, v)); 193e9fb7631SAkinobu Mita } 1941da177e4SLinus Torvalds EXPORT_SYMBOL(register_cpu_notifier); 1951da177e4SLinus Torvalds 1969647155fSSam Ravnborg void __ref unregister_cpu_notifier(struct notifier_block *nb) 1971da177e4SLinus Torvalds { 198d221938cSGautham R Shenoy cpu_maps_update_begin(); 199bd5349cfSNeil Brown raw_notifier_chain_unregister(&cpu_chain, nb); 200d221938cSGautham R Shenoy cpu_maps_update_done(); 2011da177e4SLinus Torvalds } 2021da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_cpu_notifier); 2031da177e4SLinus Torvalds 204e4cc2f87SAnton Vorontsov /** 205e4cc2f87SAnton Vorontsov * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU 206e4cc2f87SAnton Vorontsov * @cpu: a CPU id 207e4cc2f87SAnton Vorontsov * 208e4cc2f87SAnton Vorontsov * This function walks all processes, finds a valid mm struct for each one and 209e4cc2f87SAnton Vorontsov * then clears a corresponding bit in mm's cpumask. While this all sounds 210e4cc2f87SAnton Vorontsov * trivial, there are various non-obvious corner cases, which this function 211e4cc2f87SAnton Vorontsov * tries to solve in a safe manner. 212e4cc2f87SAnton Vorontsov * 213e4cc2f87SAnton Vorontsov * Also note that the function uses a somewhat relaxed locking scheme, so it may 214e4cc2f87SAnton Vorontsov * be called only for an already offlined CPU. 215e4cc2f87SAnton Vorontsov */ 216cb79295eSAnton Vorontsov void clear_tasks_mm_cpumask(int cpu) 217cb79295eSAnton Vorontsov { 218cb79295eSAnton Vorontsov struct task_struct *p; 219cb79295eSAnton Vorontsov 220cb79295eSAnton Vorontsov /* 221cb79295eSAnton Vorontsov * This function is called after the cpu is taken down and marked 222cb79295eSAnton Vorontsov * offline, so its not like new tasks will ever get this cpu set in 223cb79295eSAnton Vorontsov * their mm mask. -- Peter Zijlstra 224cb79295eSAnton Vorontsov * Thus, we may use rcu_read_lock() here, instead of grabbing 225cb79295eSAnton Vorontsov * full-fledged tasklist_lock. 226cb79295eSAnton Vorontsov */ 227e4cc2f87SAnton Vorontsov WARN_ON(cpu_online(cpu)); 228cb79295eSAnton Vorontsov rcu_read_lock(); 229cb79295eSAnton Vorontsov for_each_process(p) { 230cb79295eSAnton Vorontsov struct task_struct *t; 231cb79295eSAnton Vorontsov 232e4cc2f87SAnton Vorontsov /* 233e4cc2f87SAnton Vorontsov * Main thread might exit, but other threads may still have 234e4cc2f87SAnton Vorontsov * a valid mm. Find one. 235e4cc2f87SAnton Vorontsov */ 236cb79295eSAnton Vorontsov t = find_lock_task_mm(p); 237cb79295eSAnton Vorontsov if (!t) 238cb79295eSAnton Vorontsov continue; 239cb79295eSAnton Vorontsov cpumask_clear_cpu(cpu, mm_cpumask(t->mm)); 240cb79295eSAnton Vorontsov task_unlock(t); 241cb79295eSAnton Vorontsov } 242cb79295eSAnton Vorontsov rcu_read_unlock(); 243cb79295eSAnton Vorontsov } 244cb79295eSAnton Vorontsov 2451da177e4SLinus Torvalds static inline void check_for_tasks(int cpu) 2461da177e4SLinus Torvalds { 2471da177e4SLinus Torvalds struct task_struct *p; 2486fac4829SFrederic Weisbecker cputime_t utime, stime; 2491da177e4SLinus Torvalds 2501da177e4SLinus Torvalds write_lock_irq(&tasklist_lock); 2511da177e4SLinus Torvalds for_each_process(p) { 2526fac4829SFrederic Weisbecker task_cputime(p, &utime, &stime); 25311854247SPeter Zijlstra if (task_cpu(p) == cpu && p->state == TASK_RUNNING && 2546fac4829SFrederic Weisbecker (utime || stime)) 2559d3cfc4cSFrans Pop printk(KERN_WARNING "Task %s (pid = %d) is on cpu %d " 2569d3cfc4cSFrans Pop "(state = %ld, flags = %x)\n", 257ba25f9dcSPavel Emelyanov p->comm, task_pid_nr(p), cpu, 258ba25f9dcSPavel Emelyanov p->state, p->flags); 2591da177e4SLinus Torvalds } 2601da177e4SLinus Torvalds write_unlock_irq(&tasklist_lock); 2611da177e4SLinus Torvalds } 2621da177e4SLinus Torvalds 263db912f96SAvi Kivity struct take_cpu_down_param { 264db912f96SAvi Kivity unsigned long mod; 265db912f96SAvi Kivity void *hcpu; 266db912f96SAvi Kivity }; 267db912f96SAvi Kivity 2681da177e4SLinus Torvalds /* Take this CPU down. */ 269514a20a5SSam Ravnborg static int __ref take_cpu_down(void *_param) 2701da177e4SLinus Torvalds { 271db912f96SAvi Kivity struct take_cpu_down_param *param = _param; 2721da177e4SLinus Torvalds int err; 2731da177e4SLinus Torvalds 2741da177e4SLinus Torvalds /* Ensure this CPU doesn't handle any more interrupts. */ 2751da177e4SLinus Torvalds err = __cpu_disable(); 2761da177e4SLinus Torvalds if (err < 0) 277f3705136SZwane Mwaikambo return err; 278f3705136SZwane Mwaikambo 279e9fb7631SAkinobu Mita cpu_notify(CPU_DYING | param->mod, param->hcpu); 28014e568e7SThomas Gleixner /* Park the stopper thread */ 28114e568e7SThomas Gleixner kthread_park(current); 282f3705136SZwane Mwaikambo return 0; 2831da177e4SLinus Torvalds } 2841da177e4SLinus Torvalds 285e3920fb4SRafael J. Wysocki /* Requires cpu_add_remove_lock to be held */ 286514a20a5SSam Ravnborg static int __ref _cpu_down(unsigned int cpu, int tasks_frozen) 2871da177e4SLinus Torvalds { 288e7407dccSHeiko Carstens int err, nr_calls = 0; 289e7407dccSHeiko Carstens void *hcpu = (void *)(long)cpu; 2908bb78442SRafael J. Wysocki unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0; 291db912f96SAvi Kivity struct take_cpu_down_param tcd_param = { 292db912f96SAvi Kivity .mod = mod, 293db912f96SAvi Kivity .hcpu = hcpu, 294db912f96SAvi Kivity }; 2951da177e4SLinus Torvalds 296e3920fb4SRafael J. Wysocki if (num_online_cpus() == 1) 297e3920fb4SRafael J. Wysocki return -EBUSY; 2981da177e4SLinus Torvalds 299e3920fb4SRafael J. Wysocki if (!cpu_online(cpu)) 300e3920fb4SRafael J. Wysocki return -EINVAL; 3011da177e4SLinus Torvalds 302d221938cSGautham R Shenoy cpu_hotplug_begin(); 3034d51985eSMichael Rodriguez 304e9fb7631SAkinobu Mita err = __cpu_notify(CPU_DOWN_PREPARE | mod, hcpu, -1, &nr_calls); 305e6bde73bSAkinobu Mita if (err) { 306a0d8cdb6SAkinobu Mita nr_calls--; 307e9fb7631SAkinobu Mita __cpu_notify(CPU_DOWN_FAILED | mod, hcpu, nr_calls, NULL); 3081da177e4SLinus Torvalds printk("%s: attempt to take down CPU %u failed\n", 309af1f16d0SHarvey Harrison __func__, cpu); 310baaca49fSGautham R Shenoy goto out_release; 3111da177e4SLinus Torvalds } 312f97f8f06SThomas Gleixner smpboot_park_threads(cpu); 3131da177e4SLinus Torvalds 314e0b582ecSRusty Russell err = __stop_machine(take_cpu_down, &tcd_param, cpumask_of(cpu)); 31504321587SRusty Russell if (err) { 3161da177e4SLinus Torvalds /* CPU didn't die: tell everyone. Can't complain. */ 317f97f8f06SThomas Gleixner smpboot_unpark_threads(cpu); 318e9fb7631SAkinobu Mita cpu_notify_nofail(CPU_DOWN_FAILED | mod, hcpu); 3196a1bdc1bSOleg Nesterov goto out_release; 3201da177e4SLinus Torvalds } 32104321587SRusty Russell BUG_ON(cpu_online(cpu)); 3221da177e4SLinus Torvalds 32348c5ccaeSPeter Zijlstra /* 32448c5ccaeSPeter Zijlstra * The migration_call() CPU_DYING callback will have removed all 32548c5ccaeSPeter Zijlstra * runnable tasks from the cpu, there's only the idle task left now 32648c5ccaeSPeter Zijlstra * that the migration thread is done doing the stop_machine thing. 32751a96c77SPeter Zijlstra * 32851a96c77SPeter Zijlstra * Wait for the stop thread to go away. 32948c5ccaeSPeter Zijlstra */ 33051a96c77SPeter Zijlstra while (!idle_cpu(cpu)) 33151a96c77SPeter Zijlstra cpu_relax(); 3321da177e4SLinus Torvalds 3331da177e4SLinus Torvalds /* This actually kills the CPU. */ 3341da177e4SLinus Torvalds __cpu_die(cpu); 3351da177e4SLinus Torvalds 3361da177e4SLinus Torvalds /* CPU is completely dead: tell everyone. Too late to complain. */ 337e9fb7631SAkinobu Mita cpu_notify_nofail(CPU_DEAD | mod, hcpu); 3381da177e4SLinus Torvalds 3391da177e4SLinus Torvalds check_for_tasks(cpu); 3401da177e4SLinus Torvalds 341baaca49fSGautham R Shenoy out_release: 342d221938cSGautham R Shenoy cpu_hotplug_done(); 343e9fb7631SAkinobu Mita if (!err) 344e9fb7631SAkinobu Mita cpu_notify_nofail(CPU_POST_DEAD | mod, hcpu); 345e3920fb4SRafael J. Wysocki return err; 346e3920fb4SRafael J. Wysocki } 347e3920fb4SRafael J. Wysocki 348514a20a5SSam Ravnborg int __ref cpu_down(unsigned int cpu) 349e3920fb4SRafael J. Wysocki { 3509ea09af3SHeiko Carstens int err; 351e3920fb4SRafael J. Wysocki 352d221938cSGautham R Shenoy cpu_maps_update_begin(); 353e761b772SMax Krasnyansky 354e761b772SMax Krasnyansky if (cpu_hotplug_disabled) { 355e3920fb4SRafael J. Wysocki err = -EBUSY; 356e761b772SMax Krasnyansky goto out; 357e761b772SMax Krasnyansky } 358e761b772SMax Krasnyansky 3598bb78442SRafael J. Wysocki err = _cpu_down(cpu, 0); 360e3920fb4SRafael J. Wysocki 361e761b772SMax Krasnyansky out: 362d221938cSGautham R Shenoy cpu_maps_update_done(); 3631da177e4SLinus Torvalds return err; 3641da177e4SLinus Torvalds } 365b62b8ef9SZhang Rui EXPORT_SYMBOL(cpu_down); 3661da177e4SLinus Torvalds #endif /*CONFIG_HOTPLUG_CPU*/ 3671da177e4SLinus Torvalds 368e3920fb4SRafael J. Wysocki /* Requires cpu_add_remove_lock to be held */ 369*0db0628dSPaul Gortmaker static int _cpu_up(unsigned int cpu, int tasks_frozen) 3701da177e4SLinus Torvalds { 371baaca49fSGautham R Shenoy int ret, nr_calls = 0; 3721da177e4SLinus Torvalds void *hcpu = (void *)(long)cpu; 3738bb78442SRafael J. Wysocki unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0; 3743bb5d2eeSSuresh Siddha struct task_struct *idle; 3751da177e4SLinus Torvalds 376d221938cSGautham R Shenoy cpu_hotplug_begin(); 37738498a67SThomas Gleixner 3785e5041f3SYasuaki Ishimatsu if (cpu_online(cpu) || !cpu_present(cpu)) { 3795e5041f3SYasuaki Ishimatsu ret = -EINVAL; 3805e5041f3SYasuaki Ishimatsu goto out; 3815e5041f3SYasuaki Ishimatsu } 3825e5041f3SYasuaki Ishimatsu 3833bb5d2eeSSuresh Siddha idle = idle_thread_get(cpu); 3843bb5d2eeSSuresh Siddha if (IS_ERR(idle)) { 3853bb5d2eeSSuresh Siddha ret = PTR_ERR(idle); 38638498a67SThomas Gleixner goto out; 3873bb5d2eeSSuresh Siddha } 38838498a67SThomas Gleixner 389f97f8f06SThomas Gleixner ret = smpboot_create_threads(cpu); 390f97f8f06SThomas Gleixner if (ret) 391f97f8f06SThomas Gleixner goto out; 392f97f8f06SThomas Gleixner 393e9fb7631SAkinobu Mita ret = __cpu_notify(CPU_UP_PREPARE | mod, hcpu, -1, &nr_calls); 394e6bde73bSAkinobu Mita if (ret) { 395a0d8cdb6SAkinobu Mita nr_calls--; 3964d51985eSMichael Rodriguez printk(KERN_WARNING "%s: attempt to bring up CPU %u failed\n", 397af1f16d0SHarvey Harrison __func__, cpu); 3981da177e4SLinus Torvalds goto out_notify; 3991da177e4SLinus Torvalds } 4001da177e4SLinus Torvalds 4011da177e4SLinus Torvalds /* Arch-specific enabling code. */ 4023bb5d2eeSSuresh Siddha ret = __cpu_up(cpu, idle); 4031da177e4SLinus Torvalds if (ret != 0) 4041da177e4SLinus Torvalds goto out_notify; 4056978c705SEric Sesterhenn BUG_ON(!cpu_online(cpu)); 4061da177e4SLinus Torvalds 407f97f8f06SThomas Gleixner /* Wake the per cpu threads */ 408f97f8f06SThomas Gleixner smpboot_unpark_threads(cpu); 409f97f8f06SThomas Gleixner 4101da177e4SLinus Torvalds /* Now call notifier in preparation. */ 411e9fb7631SAkinobu Mita cpu_notify(CPU_ONLINE | mod, hcpu); 4121da177e4SLinus Torvalds 4131da177e4SLinus Torvalds out_notify: 4141da177e4SLinus Torvalds if (ret != 0) 415e9fb7631SAkinobu Mita __cpu_notify(CPU_UP_CANCELED | mod, hcpu, nr_calls, NULL); 41638498a67SThomas Gleixner out: 417d221938cSGautham R Shenoy cpu_hotplug_done(); 418e3920fb4SRafael J. Wysocki 4191da177e4SLinus Torvalds return ret; 4201da177e4SLinus Torvalds } 421e3920fb4SRafael J. Wysocki 422*0db0628dSPaul Gortmaker int cpu_up(unsigned int cpu) 423e3920fb4SRafael J. Wysocki { 424e3920fb4SRafael J. Wysocki int err = 0; 425cf23422bSminskey guo 426cf23422bSminskey guo #ifdef CONFIG_MEMORY_HOTPLUG 427cf23422bSminskey guo int nid; 428cf23422bSminskey guo pg_data_t *pgdat; 429cf23422bSminskey guo #endif 430cf23422bSminskey guo 431e0b582ecSRusty Russell if (!cpu_possible(cpu)) { 43273e753a5SKAMEZAWA Hiroyuki printk(KERN_ERR "can't online cpu %d because it is not " 43373e753a5SKAMEZAWA Hiroyuki "configured as may-hotadd at boot time\n", cpu); 43487d5e023SChen Gong #if defined(CONFIG_IA64) 43573e753a5SKAMEZAWA Hiroyuki printk(KERN_ERR "please check additional_cpus= boot " 43673e753a5SKAMEZAWA Hiroyuki "parameter\n"); 43773e753a5SKAMEZAWA Hiroyuki #endif 43873e753a5SKAMEZAWA Hiroyuki return -EINVAL; 43973e753a5SKAMEZAWA Hiroyuki } 440e3920fb4SRafael J. Wysocki 441cf23422bSminskey guo #ifdef CONFIG_MEMORY_HOTPLUG 442cf23422bSminskey guo nid = cpu_to_node(cpu); 443cf23422bSminskey guo if (!node_online(nid)) { 444cf23422bSminskey guo err = mem_online_node(nid); 445cf23422bSminskey guo if (err) 446cf23422bSminskey guo return err; 447cf23422bSminskey guo } 448cf23422bSminskey guo 449cf23422bSminskey guo pgdat = NODE_DATA(nid); 450cf23422bSminskey guo if (!pgdat) { 451cf23422bSminskey guo printk(KERN_ERR 452cf23422bSminskey guo "Can't online cpu %d due to NULL pgdat\n", cpu); 453cf23422bSminskey guo return -ENOMEM; 454cf23422bSminskey guo } 455cf23422bSminskey guo 4564eaf3f64SHaicheng Li if (pgdat->node_zonelists->_zonerefs->zone == NULL) { 4574eaf3f64SHaicheng Li mutex_lock(&zonelists_mutex); 4589adb62a5SJiang Liu build_all_zonelists(NULL, NULL); 4594eaf3f64SHaicheng Li mutex_unlock(&zonelists_mutex); 4604eaf3f64SHaicheng Li } 461cf23422bSminskey guo #endif 462cf23422bSminskey guo 463d221938cSGautham R Shenoy cpu_maps_update_begin(); 464e761b772SMax Krasnyansky 465e761b772SMax Krasnyansky if (cpu_hotplug_disabled) { 466e3920fb4SRafael J. Wysocki err = -EBUSY; 467e761b772SMax Krasnyansky goto out; 468e761b772SMax Krasnyansky } 469e761b772SMax Krasnyansky 4708bb78442SRafael J. Wysocki err = _cpu_up(cpu, 0); 471e3920fb4SRafael J. Wysocki 472e761b772SMax Krasnyansky out: 473d221938cSGautham R Shenoy cpu_maps_update_done(); 474e3920fb4SRafael J. Wysocki return err; 475e3920fb4SRafael J. Wysocki } 476a513f6baSPaul E. McKenney EXPORT_SYMBOL_GPL(cpu_up); 477e3920fb4SRafael J. Wysocki 478f3de4be9SRafael J. Wysocki #ifdef CONFIG_PM_SLEEP_SMP 479e0b582ecSRusty Russell static cpumask_var_t frozen_cpus; 480e3920fb4SRafael J. Wysocki 481e3920fb4SRafael J. Wysocki int disable_nonboot_cpus(void) 482e3920fb4SRafael J. Wysocki { 483e9a5f426SRafael J. Wysocki int cpu, first_cpu, error = 0; 484e3920fb4SRafael J. Wysocki 485d221938cSGautham R Shenoy cpu_maps_update_begin(); 486e0b582ecSRusty Russell first_cpu = cpumask_first(cpu_online_mask); 4879ee349adSXiaotian Feng /* 4889ee349adSXiaotian Feng * We take down all of the non-boot CPUs in one shot to avoid races 489e3920fb4SRafael J. Wysocki * with the userspace trying to use the CPU hotplug at the same time 490e3920fb4SRafael J. Wysocki */ 491e0b582ecSRusty Russell cpumask_clear(frozen_cpus); 4926ad4c188SPeter Zijlstra 493e3920fb4SRafael J. Wysocki printk("Disabling non-boot CPUs ...\n"); 494e3920fb4SRafael J. Wysocki for_each_online_cpu(cpu) { 495e3920fb4SRafael J. Wysocki if (cpu == first_cpu) 496e3920fb4SRafael J. Wysocki continue; 4978bb78442SRafael J. Wysocki error = _cpu_down(cpu, 1); 498feae3203SMike Travis if (!error) 499e0b582ecSRusty Russell cpumask_set_cpu(cpu, frozen_cpus); 500feae3203SMike Travis else { 501e3920fb4SRafael J. Wysocki printk(KERN_ERR "Error taking CPU%d down: %d\n", 502e3920fb4SRafael J. Wysocki cpu, error); 503e3920fb4SRafael J. Wysocki break; 504e3920fb4SRafael J. Wysocki } 505e3920fb4SRafael J. Wysocki } 50686886e55SJoseph Cihula 507e3920fb4SRafael J. Wysocki if (!error) { 508e3920fb4SRafael J. Wysocki BUG_ON(num_online_cpus() > 1); 509e3920fb4SRafael J. Wysocki /* Make sure the CPUs won't be enabled by someone else */ 510e3920fb4SRafael J. Wysocki cpu_hotplug_disabled = 1; 511e3920fb4SRafael J. Wysocki } else { 512e1d9fd2eSIngo Molnar printk(KERN_ERR "Non-boot CPUs are not disabled\n"); 513e3920fb4SRafael J. Wysocki } 514d221938cSGautham R Shenoy cpu_maps_update_done(); 515e3920fb4SRafael J. Wysocki return error; 516e3920fb4SRafael J. Wysocki } 517e3920fb4SRafael J. Wysocki 518d0af9eedSSuresh Siddha void __weak arch_enable_nonboot_cpus_begin(void) 519d0af9eedSSuresh Siddha { 520d0af9eedSSuresh Siddha } 521d0af9eedSSuresh Siddha 522d0af9eedSSuresh Siddha void __weak arch_enable_nonboot_cpus_end(void) 523d0af9eedSSuresh Siddha { 524d0af9eedSSuresh Siddha } 525d0af9eedSSuresh Siddha 526fa7303e2SSam Ravnborg void __ref enable_nonboot_cpus(void) 527e3920fb4SRafael J. Wysocki { 528e3920fb4SRafael J. Wysocki int cpu, error; 529e3920fb4SRafael J. Wysocki 530e3920fb4SRafael J. Wysocki /* Allow everyone to use the CPU hotplug again */ 531d221938cSGautham R Shenoy cpu_maps_update_begin(); 532e3920fb4SRafael J. Wysocki cpu_hotplug_disabled = 0; 533e0b582ecSRusty Russell if (cpumask_empty(frozen_cpus)) 5341d64b9cbSRafael J. Wysocki goto out; 535e3920fb4SRafael J. Wysocki 5364d51985eSMichael Rodriguez printk(KERN_INFO "Enabling non-boot CPUs ...\n"); 537d0af9eedSSuresh Siddha 538d0af9eedSSuresh Siddha arch_enable_nonboot_cpus_begin(); 539d0af9eedSSuresh Siddha 540e0b582ecSRusty Russell for_each_cpu(cpu, frozen_cpus) { 5418bb78442SRafael J. Wysocki error = _cpu_up(cpu, 1); 542e3920fb4SRafael J. Wysocki if (!error) { 5434d51985eSMichael Rodriguez printk(KERN_INFO "CPU%d is up\n", cpu); 544e3920fb4SRafael J. Wysocki continue; 545e3920fb4SRafael J. Wysocki } 5461d64b9cbSRafael J. Wysocki printk(KERN_WARNING "Error taking CPU%d up: %d\n", cpu, error); 547e3920fb4SRafael J. Wysocki } 548d0af9eedSSuresh Siddha 549d0af9eedSSuresh Siddha arch_enable_nonboot_cpus_end(); 550d0af9eedSSuresh Siddha 551e0b582ecSRusty Russell cpumask_clear(frozen_cpus); 5521d64b9cbSRafael J. Wysocki out: 553d221938cSGautham R Shenoy cpu_maps_update_done(); 554e3920fb4SRafael J. Wysocki } 555e0b582ecSRusty Russell 556d7268a31SFenghua Yu static int __init alloc_frozen_cpus(void) 557e0b582ecSRusty Russell { 558e0b582ecSRusty Russell if (!alloc_cpumask_var(&frozen_cpus, GFP_KERNEL|__GFP_ZERO)) 559e0b582ecSRusty Russell return -ENOMEM; 560e0b582ecSRusty Russell return 0; 561e0b582ecSRusty Russell } 562e0b582ecSRusty Russell core_initcall(alloc_frozen_cpus); 56379cfbdfaSSrivatsa S. Bhat 56479cfbdfaSSrivatsa S. Bhat /* 56579cfbdfaSSrivatsa S. Bhat * When callbacks for CPU hotplug notifications are being executed, we must 56679cfbdfaSSrivatsa S. Bhat * ensure that the state of the system with respect to the tasks being frozen 56779cfbdfaSSrivatsa S. Bhat * or not, as reported by the notification, remains unchanged *throughout the 56879cfbdfaSSrivatsa S. Bhat * duration* of the execution of the callbacks. 56979cfbdfaSSrivatsa S. Bhat * Hence we need to prevent the freezer from racing with regular CPU hotplug. 57079cfbdfaSSrivatsa S. Bhat * 57179cfbdfaSSrivatsa S. Bhat * This synchronization is implemented by mutually excluding regular CPU 57279cfbdfaSSrivatsa S. Bhat * hotplug and Suspend/Hibernate call paths by hooking onto the Suspend/ 57379cfbdfaSSrivatsa S. Bhat * Hibernate notifications. 57479cfbdfaSSrivatsa S. Bhat */ 57579cfbdfaSSrivatsa S. Bhat static int 57679cfbdfaSSrivatsa S. Bhat cpu_hotplug_pm_callback(struct notifier_block *nb, 57779cfbdfaSSrivatsa S. Bhat unsigned long action, void *ptr) 57879cfbdfaSSrivatsa S. Bhat { 57979cfbdfaSSrivatsa S. Bhat switch (action) { 58079cfbdfaSSrivatsa S. Bhat 58179cfbdfaSSrivatsa S. Bhat case PM_SUSPEND_PREPARE: 58279cfbdfaSSrivatsa S. Bhat case PM_HIBERNATION_PREPARE: 58316e53dbfSSrivatsa S. Bhat cpu_hotplug_disable(); 58479cfbdfaSSrivatsa S. Bhat break; 58579cfbdfaSSrivatsa S. Bhat 58679cfbdfaSSrivatsa S. Bhat case PM_POST_SUSPEND: 58779cfbdfaSSrivatsa S. Bhat case PM_POST_HIBERNATION: 58816e53dbfSSrivatsa S. Bhat cpu_hotplug_enable(); 58979cfbdfaSSrivatsa S. Bhat break; 59079cfbdfaSSrivatsa S. Bhat 59179cfbdfaSSrivatsa S. Bhat default: 59279cfbdfaSSrivatsa S. Bhat return NOTIFY_DONE; 59379cfbdfaSSrivatsa S. Bhat } 59479cfbdfaSSrivatsa S. Bhat 59579cfbdfaSSrivatsa S. Bhat return NOTIFY_OK; 59679cfbdfaSSrivatsa S. Bhat } 59779cfbdfaSSrivatsa S. Bhat 59879cfbdfaSSrivatsa S. Bhat 599d7268a31SFenghua Yu static int __init cpu_hotplug_pm_sync_init(void) 60079cfbdfaSSrivatsa S. Bhat { 6016e32d479SFenghua Yu /* 6026e32d479SFenghua Yu * cpu_hotplug_pm_callback has higher priority than x86 6036e32d479SFenghua Yu * bsp_pm_callback which depends on cpu_hotplug_pm_callback 6046e32d479SFenghua Yu * to disable cpu hotplug to avoid cpu hotplug race. 6056e32d479SFenghua Yu */ 60679cfbdfaSSrivatsa S. Bhat pm_notifier(cpu_hotplug_pm_callback, 0); 60779cfbdfaSSrivatsa S. Bhat return 0; 60879cfbdfaSSrivatsa S. Bhat } 60979cfbdfaSSrivatsa S. Bhat core_initcall(cpu_hotplug_pm_sync_init); 61079cfbdfaSSrivatsa S. Bhat 611f3de4be9SRafael J. Wysocki #endif /* CONFIG_PM_SLEEP_SMP */ 61268f4f1ecSMax Krasnyansky 613e545a614SManfred Spraul /** 614e545a614SManfred Spraul * notify_cpu_starting(cpu) - call the CPU_STARTING notifiers 615e545a614SManfred Spraul * @cpu: cpu that just started 616e545a614SManfred Spraul * 617e545a614SManfred Spraul * This function calls the cpu_chain notifiers with CPU_STARTING. 618e545a614SManfred Spraul * It must be called by the arch code on the new cpu, before the new cpu 619e545a614SManfred Spraul * enables interrupts and before the "boot" cpu returns from __cpu_up(). 620e545a614SManfred Spraul */ 621*0db0628dSPaul Gortmaker void notify_cpu_starting(unsigned int cpu) 622e545a614SManfred Spraul { 623e545a614SManfred Spraul unsigned long val = CPU_STARTING; 624e545a614SManfred Spraul 625e545a614SManfred Spraul #ifdef CONFIG_PM_SLEEP_SMP 626e0b582ecSRusty Russell if (frozen_cpus != NULL && cpumask_test_cpu(cpu, frozen_cpus)) 627e545a614SManfred Spraul val = CPU_STARTING_FROZEN; 628e545a614SManfred Spraul #endif /* CONFIG_PM_SLEEP_SMP */ 629e9fb7631SAkinobu Mita cpu_notify(val, (void *)(long)cpu); 630e545a614SManfred Spraul } 631e545a614SManfred Spraul 63268f4f1ecSMax Krasnyansky #endif /* CONFIG_SMP */ 633b8d317d1SMike Travis 634e56b3bc7SLinus Torvalds /* 635e56b3bc7SLinus Torvalds * cpu_bit_bitmap[] is a special, "compressed" data structure that 636e56b3bc7SLinus Torvalds * represents all NR_CPUS bits binary values of 1<<nr. 637e56b3bc7SLinus Torvalds * 638e0b582ecSRusty Russell * It is used by cpumask_of() to get a constant address to a CPU 639e56b3bc7SLinus Torvalds * mask value that has a single bit set only. 640e56b3bc7SLinus Torvalds */ 641b8d317d1SMike Travis 642e56b3bc7SLinus Torvalds /* cpu_bit_bitmap[0] is empty - so we can back into it */ 6434d51985eSMichael Rodriguez #define MASK_DECLARE_1(x) [x+1][0] = (1UL << (x)) 644e56b3bc7SLinus Torvalds #define MASK_DECLARE_2(x) MASK_DECLARE_1(x), MASK_DECLARE_1(x+1) 645e56b3bc7SLinus Torvalds #define MASK_DECLARE_4(x) MASK_DECLARE_2(x), MASK_DECLARE_2(x+2) 646e56b3bc7SLinus Torvalds #define MASK_DECLARE_8(x) MASK_DECLARE_4(x), MASK_DECLARE_4(x+4) 647b8d317d1SMike Travis 648e56b3bc7SLinus Torvalds const unsigned long cpu_bit_bitmap[BITS_PER_LONG+1][BITS_TO_LONGS(NR_CPUS)] = { 649b8d317d1SMike Travis 650e56b3bc7SLinus Torvalds MASK_DECLARE_8(0), MASK_DECLARE_8(8), 651e56b3bc7SLinus Torvalds MASK_DECLARE_8(16), MASK_DECLARE_8(24), 652e56b3bc7SLinus Torvalds #if BITS_PER_LONG > 32 653e56b3bc7SLinus Torvalds MASK_DECLARE_8(32), MASK_DECLARE_8(40), 654e56b3bc7SLinus Torvalds MASK_DECLARE_8(48), MASK_DECLARE_8(56), 655b8d317d1SMike Travis #endif 656b8d317d1SMike Travis }; 657e56b3bc7SLinus Torvalds EXPORT_SYMBOL_GPL(cpu_bit_bitmap); 6582d3854a3SRusty Russell 6592d3854a3SRusty Russell const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL; 6602d3854a3SRusty Russell EXPORT_SYMBOL(cpu_all_bits); 661b3199c02SRusty Russell 662b3199c02SRusty Russell #ifdef CONFIG_INIT_ALL_POSSIBLE 663b3199c02SRusty Russell static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly 664b3199c02SRusty Russell = CPU_BITS_ALL; 665b3199c02SRusty Russell #else 666b3199c02SRusty Russell static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly; 667b3199c02SRusty Russell #endif 668b3199c02SRusty Russell const struct cpumask *const cpu_possible_mask = to_cpumask(cpu_possible_bits); 669b3199c02SRusty Russell EXPORT_SYMBOL(cpu_possible_mask); 670b3199c02SRusty Russell 671b3199c02SRusty Russell static DECLARE_BITMAP(cpu_online_bits, CONFIG_NR_CPUS) __read_mostly; 672b3199c02SRusty Russell const struct cpumask *const cpu_online_mask = to_cpumask(cpu_online_bits); 673b3199c02SRusty Russell EXPORT_SYMBOL(cpu_online_mask); 674b3199c02SRusty Russell 675b3199c02SRusty Russell static DECLARE_BITMAP(cpu_present_bits, CONFIG_NR_CPUS) __read_mostly; 676b3199c02SRusty Russell const struct cpumask *const cpu_present_mask = to_cpumask(cpu_present_bits); 677b3199c02SRusty Russell EXPORT_SYMBOL(cpu_present_mask); 678b3199c02SRusty Russell 679b3199c02SRusty Russell static DECLARE_BITMAP(cpu_active_bits, CONFIG_NR_CPUS) __read_mostly; 680b3199c02SRusty Russell const struct cpumask *const cpu_active_mask = to_cpumask(cpu_active_bits); 681b3199c02SRusty Russell EXPORT_SYMBOL(cpu_active_mask); 6823fa41520SRusty Russell 6833fa41520SRusty Russell void set_cpu_possible(unsigned int cpu, bool possible) 6843fa41520SRusty Russell { 6853fa41520SRusty Russell if (possible) 6863fa41520SRusty Russell cpumask_set_cpu(cpu, to_cpumask(cpu_possible_bits)); 6873fa41520SRusty Russell else 6883fa41520SRusty Russell cpumask_clear_cpu(cpu, to_cpumask(cpu_possible_bits)); 6893fa41520SRusty Russell } 6903fa41520SRusty Russell 6913fa41520SRusty Russell void set_cpu_present(unsigned int cpu, bool present) 6923fa41520SRusty Russell { 6933fa41520SRusty Russell if (present) 6943fa41520SRusty Russell cpumask_set_cpu(cpu, to_cpumask(cpu_present_bits)); 6953fa41520SRusty Russell else 6963fa41520SRusty Russell cpumask_clear_cpu(cpu, to_cpumask(cpu_present_bits)); 6973fa41520SRusty Russell } 6983fa41520SRusty Russell 6993fa41520SRusty Russell void set_cpu_online(unsigned int cpu, bool online) 7003fa41520SRusty Russell { 7013fa41520SRusty Russell if (online) 7023fa41520SRusty Russell cpumask_set_cpu(cpu, to_cpumask(cpu_online_bits)); 7033fa41520SRusty Russell else 7043fa41520SRusty Russell cpumask_clear_cpu(cpu, to_cpumask(cpu_online_bits)); 7053fa41520SRusty Russell } 7063fa41520SRusty Russell 7073fa41520SRusty Russell void set_cpu_active(unsigned int cpu, bool active) 7083fa41520SRusty Russell { 7093fa41520SRusty Russell if (active) 7103fa41520SRusty Russell cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits)); 7113fa41520SRusty Russell else 7123fa41520SRusty Russell cpumask_clear_cpu(cpu, to_cpumask(cpu_active_bits)); 7133fa41520SRusty Russell } 7143fa41520SRusty Russell 7153fa41520SRusty Russell void init_cpu_present(const struct cpumask *src) 7163fa41520SRusty Russell { 7173fa41520SRusty Russell cpumask_copy(to_cpumask(cpu_present_bits), src); 7183fa41520SRusty Russell } 7193fa41520SRusty Russell 7203fa41520SRusty Russell void init_cpu_possible(const struct cpumask *src) 7213fa41520SRusty Russell { 7223fa41520SRusty Russell cpumask_copy(to_cpumask(cpu_possible_bits), src); 7233fa41520SRusty Russell } 7243fa41520SRusty Russell 7253fa41520SRusty Russell void init_cpu_online(const struct cpumask *src) 7263fa41520SRusty Russell { 7273fa41520SRusty Russell cpumask_copy(to_cpumask(cpu_online_bits), src); 7283fa41520SRusty Russell } 729