smp.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /*
  2. * Generic helpers for smp ipi calls
  3. *
  4. * (C) Jens Axboe <jens.axboe@oracle.com> 2008
  5. */
  6. #include <linux/rcupdate.h>
  7. #include <linux/rculist.h>
  8. #include <linux/kernel.h>
  9. #include <linux/export.h>
  10. #include <linux/percpu.h>
  11. #include <linux/init.h>
  12. #include <linux/gfp.h>
  13. #include <linux/smp.h>
  14. #include <linux/cpu.h>
  15. #include "smpboot.h"
  16. #ifdef CONFIG_USE_GENERIC_SMP_HELPERS
  17. enum {
  18. CSD_FLAG_LOCK = 0x01,
  19. };
  20. struct call_function_data {
  21. struct call_single_data __percpu *csd;
  22. cpumask_var_t cpumask;
  23. cpumask_var_t cpumask_ipi;
  24. };
  25. static DEFINE_PER_CPU_SHARED_ALIGNED(struct call_function_data, cfd_data);
  26. struct call_single_queue {
  27. struct list_head list;
  28. raw_spinlock_t lock;
  29. };
  30. static DEFINE_PER_CPU_SHARED_ALIGNED(struct call_single_queue, call_single_queue);
  31. static int
  32. hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
  33. {
  34. long cpu = (long)hcpu;
  35. struct call_function_data *cfd = &per_cpu(cfd_data, cpu);
  36. switch (action) {
  37. case CPU_UP_PREPARE:
  38. case CPU_UP_PREPARE_FROZEN:
  39. if (!zalloc_cpumask_var_node(&cfd->cpumask, GFP_KERNEL,
  40. cpu_to_node(cpu)))
  41. return notifier_from_errno(-ENOMEM);
  42. if (!zalloc_cpumask_var_node(&cfd->cpumask_ipi, GFP_KERNEL,
  43. cpu_to_node(cpu)))
  44. return notifier_from_errno(-ENOMEM);
  45. cfd->csd = alloc_percpu(struct call_single_data);
  46. if (!cfd->csd) {
  47. free_cpumask_var(cfd->cpumask);
  48. return notifier_from_errno(-ENOMEM);
  49. }
  50. break;
  51. #ifdef CONFIG_HOTPLUG_CPU
  52. case CPU_UP_CANCELED:
  53. case CPU_UP_CANCELED_FROZEN:
  54. case CPU_DEAD:
  55. case CPU_DEAD_FROZEN:
  56. free_cpumask_var(cfd->cpumask);
  57. free_cpumask_var(cfd->cpumask_ipi);
  58. free_percpu(cfd->csd);
  59. break;
  60. #endif
  61. };
  62. return NOTIFY_OK;
  63. }
  64. static struct notifier_block hotplug_cfd_notifier = {
  65. .notifier_call = hotplug_cfd,
  66. };
  67. void __init call_function_init(void)
  68. {
  69. void *cpu = (void *)(long)smp_processor_id();
  70. int i;
  71. for_each_possible_cpu(i) {
  72. struct call_single_queue *q = &per_cpu(call_single_queue, i);
  73. raw_spin_lock_init(&q->lock);
  74. INIT_LIST_HEAD(&q->list);
  75. }
  76. hotplug_cfd(&hotplug_cfd_notifier, CPU_UP_PREPARE, cpu);
  77. register_cpu_notifier(&hotplug_cfd_notifier);
  78. }
  79. /*
  80. * csd_lock/csd_unlock used to serialize access to per-cpu csd resources
  81. *
  82. * For non-synchronous ipi calls the csd can still be in use by the
  83. * previous function call. For multi-cpu calls its even more interesting
  84. * as we'll have to ensure no other cpu is observing our csd.
  85. */
  86. static void csd_lock_wait(struct call_single_data *csd)
  87. {
  88. while (csd->flags & CSD_FLAG_LOCK)
  89. cpu_relax();
  90. }
  91. static void csd_lock(struct call_single_data *csd)
  92. {
  93. csd_lock_wait(csd);
  94. csd->flags |= CSD_FLAG_LOCK;
  95. /*
  96. * prevent CPU from reordering the above assignment
  97. * to ->flags with any subsequent assignments to other
  98. * fields of the specified call_single_data structure:
  99. */
  100. smp_mb();
  101. }
  102. static void csd_unlock(struct call_single_data *csd)
  103. {
  104. WARN_ON(!(csd->flags & CSD_FLAG_LOCK));
  105. /*
  106. * ensure we're all done before releasing data:
  107. */
  108. smp_mb();
  109. csd->flags &= ~CSD_FLAG_LOCK;
  110. }
  111. /*
  112. * Insert a previously allocated call_single_data element
  113. * for execution on the given CPU. data must already have
  114. * ->func, ->info, and ->flags set.
  115. */
  116. static
  117. void generic_exec_single(int cpu, struct call_single_data *csd, int wait)
  118. {
  119. struct call_single_queue *dst = &per_cpu(call_single_queue, cpu);
  120. unsigned long flags;
  121. int ipi;
  122. raw_spin_lock_irqsave(&dst->lock, flags);
  123. ipi = list_empty(&dst->list);
  124. list_add_tail(&csd->list, &dst->list);
  125. raw_spin_unlock_irqrestore(&dst->lock, flags);
  126. /*
  127. * The list addition should be visible before sending the IPI
  128. * handler locks the list to pull the entry off it because of
  129. * normal cache coherency rules implied by spinlocks.
  130. *
  131. * If IPIs can go out of order to the cache coherency protocol
  132. * in an architecture, sufficient synchronisation should be added
  133. * to arch code to make it appear to obey cache coherency WRT
  134. * locking and barrier primitives. Generic code isn't really
  135. * equipped to do the right thing...
  136. */
  137. if (ipi)
  138. arch_send_call_function_single_ipi(cpu);
  139. if (wait)
  140. csd_lock_wait(csd);
  141. }
  142. /*
  143. * Invoked by arch to handle an IPI for call function single. Must be
  144. * called from the arch with interrupts disabled.
  145. */
  146. void generic_smp_call_function_single_interrupt(void)
  147. {
  148. struct call_single_queue *q = &__get_cpu_var(call_single_queue);
  149. LIST_HEAD(list);
  150. /*
  151. * Shouldn't receive this interrupt on a cpu that is not yet online.
  152. */
  153. WARN_ON_ONCE(!cpu_online(smp_processor_id()));
  154. raw_spin_lock(&q->lock);
  155. list_replace_init(&q->list, &list);
  156. raw_spin_unlock(&q->lock);
  157. while (!list_empty(&list)) {
  158. struct call_single_data *csd;
  159. csd = list_entry(list.next, struct call_single_data, list);
  160. list_del(&csd->list);
  161. csd->func(csd->info);
  162. csd_unlock(csd);
  163. }
  164. }
  165. static DEFINE_PER_CPU_SHARED_ALIGNED(struct call_single_data, csd_data);
  166. /*
  167. * smp_call_function_single - Run a function on a specific CPU
  168. * @func: The function to run. This must be fast and non-blocking.
  169. * @info: An arbitrary pointer to pass to the function.
  170. * @wait: If true, wait until function has completed on other CPUs.
  171. *
  172. * Returns 0 on success, else a negative status code.
  173. */
  174. int smp_call_function_single(int cpu, smp_call_func_t func, void *info,
  175. int wait)
  176. {
  177. struct call_single_data d = {
  178. .flags = 0,
  179. };
  180. unsigned long flags;
  181. int this_cpu;
  182. int err = 0;
  183. /*
  184. * prevent preemption and reschedule on another processor,
  185. * as well as CPU removal
  186. */
  187. this_cpu = get_cpu();
  188. /*
  189. * Can deadlock when called with interrupts disabled.
  190. * We allow cpu's that are not yet online though, as no one else can
  191. * send smp call function interrupt to this cpu and as such deadlocks
  192. * can't happen.
  193. */
  194. WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
  195. && !oops_in_progress);
  196. if (cpu == this_cpu) {
  197. local_irq_save(flags);
  198. func(info);
  199. local_irq_restore(flags);
  200. } else {
  201. if ((unsigned)cpu < nr_cpu_ids && cpu_online(cpu)) {
  202. struct call_single_data *csd = &d;
  203. if (!wait)
  204. csd = &__get_cpu_var(csd_data);
  205. csd_lock(csd);
  206. csd->func = func;
  207. csd->info = info;
  208. generic_exec_single(cpu, csd, wait);
  209. } else {
  210. err = -ENXIO; /* CPU not online */
  211. }
  212. }
  213. put_cpu();
  214. return err;
  215. }
  216. EXPORT_SYMBOL(smp_call_function_single);
  217. /*
  218. * smp_call_function_any - Run a function on any of the given cpus
  219. * @mask: The mask of cpus it can run on.
  220. * @func: The function to run. This must be fast and non-blocking.
  221. * @info: An arbitrary pointer to pass to the function.
  222. * @wait: If true, wait until function has completed.
  223. *
  224. * Returns 0 on success, else a negative status code (if no cpus were online).
  225. *
  226. * Selection preference:
  227. * 1) current cpu if in @mask
  228. * 2) any cpu of current node if in @mask
  229. * 3) any other online cpu in @mask
  230. */
  231. int smp_call_function_any(const struct cpumask *mask,
  232. smp_call_func_t func, void *info, int wait)
  233. {
  234. unsigned int cpu;
  235. const struct cpumask *nodemask;
  236. int ret;
  237. /* Try for same CPU (cheapest) */
  238. cpu = get_cpu();
  239. if (cpumask_test_cpu(cpu, mask))
  240. goto call;
  241. /* Try for same node. */
  242. nodemask = cpumask_of_node(cpu_to_node(cpu));
  243. for (cpu = cpumask_first_and(nodemask, mask); cpu < nr_cpu_ids;
  244. cpu = cpumask_next_and(cpu, nodemask, mask)) {
  245. if (cpu_online(cpu))
  246. goto call;
  247. }
  248. /* Any online will do: smp_call_function_single handles nr_cpu_ids. */
  249. cpu = cpumask_any_and(mask, cpu_online_mask);
  250. call:
  251. ret = smp_call_function_single(cpu, func, info, wait);
  252. put_cpu();
  253. return ret;
  254. }
  255. EXPORT_SYMBOL_GPL(smp_call_function_any);
  256. /**
  257. * __smp_call_function_single(): Run a function on a specific CPU
  258. * @cpu: The CPU to run on.
  259. * @data: Pre-allocated and setup data structure
  260. * @wait: If true, wait until function has completed on specified CPU.
  261. *
  262. * Like smp_call_function_single(), but allow caller to pass in a
  263. * pre-allocated data structure. Useful for embedding @data inside
  264. * other structures, for instance.
  265. */
  266. void __smp_call_function_single(int cpu, struct call_single_data *csd,
  267. int wait)
  268. {
  269. unsigned int this_cpu;
  270. unsigned long flags;
  271. this_cpu = get_cpu();
  272. /*
  273. * Can deadlock when called with interrupts disabled.
  274. * We allow cpu's that are not yet online though, as no one else can
  275. * send smp call function interrupt to this cpu and as such deadlocks
  276. * can't happen.
  277. */
  278. WARN_ON_ONCE(cpu_online(smp_processor_id()) && wait && irqs_disabled()
  279. && !oops_in_progress);
  280. if (cpu == this_cpu) {
  281. local_irq_save(flags);
  282. csd->func(csd->info);
  283. local_irq_restore(flags);
  284. } else {
  285. csd_lock(csd);
  286. generic_exec_single(cpu, csd, wait);
  287. }
  288. put_cpu();
  289. }
  290. /**
  291. * smp_call_function_many(): Run a function on a set of other CPUs.
  292. * @mask: The set of cpus to run on (only runs on online subset).
  293. * @func: The function to run. This must be fast and non-blocking.
  294. * @info: An arbitrary pointer to pass to the function.
  295. * @wait: If true, wait (atomically) until function has completed
  296. * on other CPUs.
  297. *
  298. * If @wait is true, then returns once @func has returned.
  299. *
  300. * You must not call this function with disabled interrupts or from a
  301. * hardware interrupt handler or from a bottom half handler. Preemption
  302. * must be disabled when calling this function.
  303. */
  304. void smp_call_function_many(const struct cpumask *mask,
  305. smp_call_func_t func, void *info, bool wait)
  306. {
  307. struct call_function_data *cfd;
  308. int cpu, next_cpu, this_cpu = smp_processor_id();
  309. /*
  310. * Can deadlock when called with interrupts disabled.
  311. * We allow cpu's that are not yet online though, as no one else can
  312. * send smp call function interrupt to this cpu and as such deadlocks
  313. * can't happen.
  314. */
  315. WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
  316. && !oops_in_progress && !early_boot_irqs_disabled);
  317. /* Try to fastpath. So, what's a CPU they want? Ignoring this one. */
  318. cpu = cpumask_first_and(mask, cpu_online_mask);
  319. if (cpu == this_cpu)
  320. cpu = cpumask_next_and(cpu, mask, cpu_online_mask);
  321. /* No online cpus? We're done. */
  322. if (cpu >= nr_cpu_ids)
  323. return;
  324. /* Do we have another CPU which isn't us? */
  325. next_cpu = cpumask_next_and(cpu, mask, cpu_online_mask);
  326. if (next_cpu == this_cpu)
  327. next_cpu = cpumask_next_and(next_cpu, mask, cpu_online_mask);
  328. /* Fastpath: do that cpu by itself. */
  329. if (next_cpu >= nr_cpu_ids) {
  330. smp_call_function_single(cpu, func, info, wait);
  331. return;
  332. }
  333. cfd = &__get_cpu_var(cfd_data);
  334. cpumask_and(cfd->cpumask, mask, cpu_online_mask);
  335. cpumask_clear_cpu(this_cpu, cfd->cpumask);
  336. /* Some callers race with other cpus changing the passed mask */
  337. if (unlikely(!cpumask_weight(cfd->cpumask)))
  338. return;
  339. /*
  340. * After we put an entry into the list, cfd->cpumask may be cleared
  341. * again when another CPU sends another IPI for a SMP function call, so
  342. * cfd->cpumask will be zero.
  343. */
  344. cpumask_copy(cfd->cpumask_ipi, cfd->cpumask);
  345. for_each_cpu(cpu, cfd->cpumask) {
  346. struct call_single_data *csd = per_cpu_ptr(cfd->csd, cpu);
  347. struct call_single_queue *dst =
  348. &per_cpu(call_single_queue, cpu);
  349. unsigned long flags;
  350. csd_lock(csd);
  351. csd->func = func;
  352. csd->info = info;
  353. raw_spin_lock_irqsave(&dst->lock, flags);
  354. list_add_tail(&csd->list, &dst->list);
  355. raw_spin_unlock_irqrestore(&dst->lock, flags);
  356. }
  357. /* Send a message to all CPUs in the map */
  358. arch_send_call_function_ipi_mask(cfd->cpumask_ipi);
  359. if (wait) {
  360. for_each_cpu(cpu, cfd->cpumask) {
  361. struct call_single_data *csd;
  362. csd = per_cpu_ptr(cfd->csd, cpu);
  363. csd_lock_wait(csd);
  364. }
  365. }
  366. }
  367. EXPORT_SYMBOL(smp_call_function_many);
  368. /**
  369. * smp_call_function(): Run a function on all other CPUs.
  370. * @func: The function to run. This must be fast and non-blocking.
  371. * @info: An arbitrary pointer to pass to the function.
  372. * @wait: If true, wait (atomically) until function has completed
  373. * on other CPUs.
  374. *
  375. * Returns 0.
  376. *
  377. * If @wait is true, then returns once @func has returned; otherwise
  378. * it returns just before the target cpu calls @func.
  379. *
  380. * You must not call this function with disabled interrupts or from a
  381. * hardware interrupt handler or from a bottom half handler.
  382. */
  383. int smp_call_function(smp_call_func_t func, void *info, int wait)
  384. {
  385. preempt_disable();
  386. smp_call_function_many(cpu_online_mask, func, info, wait);
  387. preempt_enable();
  388. return 0;
  389. }
  390. EXPORT_SYMBOL(smp_call_function);
  391. #endif /* USE_GENERIC_SMP_HELPERS */
  392. /* Setup configured maximum number of CPUs to activate */
  393. unsigned int setup_max_cpus = NR_CPUS;
  394. EXPORT_SYMBOL(setup_max_cpus);
  395. /*
  396. * Setup routine for controlling SMP activation
  397. *
  398. * Command-line option of "nosmp" or "maxcpus=0" will disable SMP
  399. * activation entirely (the MPS table probe still happens, though).
  400. *
  401. * Command-line option of "maxcpus=<NUM>", where <NUM> is an integer
  402. * greater than 0, limits the maximum number of CPUs activated in
  403. * SMP mode to <NUM>.
  404. */
  405. void __weak arch_disable_smp_support(void) { }
  406. static int __init nosmp(char *str)
  407. {
  408. setup_max_cpus = 0;
  409. arch_disable_smp_support();
  410. return 0;
  411. }
  412. early_param("nosmp", nosmp);
  413. /* this is hard limit */
  414. static int __init nrcpus(char *str)
  415. {
  416. int nr_cpus;
  417. get_option(&str, &nr_cpus);
  418. if (nr_cpus > 0 && nr_cpus < nr_cpu_ids)
  419. nr_cpu_ids = nr_cpus;
  420. return 0;
  421. }
  422. early_param("nr_cpus", nrcpus);
  423. static int __init maxcpus(char *str)
  424. {
  425. get_option(&str, &setup_max_cpus);
  426. if (setup_max_cpus == 0)
  427. arch_disable_smp_support();
  428. return 0;
  429. }
  430. early_param("maxcpus", maxcpus);
  431. /* Setup number of possible processor ids */
  432. int nr_cpu_ids __read_mostly = NR_CPUS;
  433. EXPORT_SYMBOL(nr_cpu_ids);
  434. /* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */
  435. void __init setup_nr_cpu_ids(void)
  436. {
  437. nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
  438. }
  439. /* Called by boot processor to activate the rest. */
  440. void __init smp_init(void)
  441. {
  442. unsigned int cpu;
  443. idle_threads_init();
  444. /* FIXME: This should be done in userspace --RR */
  445. for_each_present_cpu(cpu) {
  446. if (num_online_cpus() >= setup_max_cpus)
  447. break;
  448. if (!cpu_online(cpu))
  449. cpu_up(cpu);
  450. }
  451. /* Any cleanup work */
  452. printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
  453. smp_cpus_done(setup_max_cpus);
  454. }
  455. /*
  456. * Call a function on all processors. May be used during early boot while
  457. * early_boot_irqs_disabled is set. Use local_irq_save/restore() instead
  458. * of local_irq_disable/enable().
  459. */
  460. int on_each_cpu(void (*func) (void *info), void *info, int wait)
  461. {
  462. unsigned long flags;
  463. int ret = 0;
  464. preempt_disable();
  465. ret = smp_call_function(func, info, wait);
  466. local_irq_save(flags);
  467. func(info);
  468. local_irq_restore(flags);
  469. preempt_enable();
  470. return ret;
  471. }
  472. EXPORT_SYMBOL(on_each_cpu);
  473. /**
  474. * on_each_cpu_mask(): Run a function on processors specified by
  475. * cpumask, which may include the local processor.
  476. * @mask: The set of cpus to run on (only runs on online subset).
  477. * @func: The function to run. This must be fast and non-blocking.
  478. * @info: An arbitrary pointer to pass to the function.
  479. * @wait: If true, wait (atomically) until function has completed
  480. * on other CPUs.
  481. *
  482. * If @wait is true, then returns once @func has returned.
  483. *
  484. * You must not call this function with disabled interrupts or
  485. * from a hardware interrupt handler or from a bottom half handler.
  486. */
  487. void on_each_cpu_mask(const struct cpumask *mask, smp_call_func_t func,
  488. void *info, bool wait)
  489. {
  490. int cpu = get_cpu();
  491. smp_call_function_many(mask, func, info, wait);
  492. if (cpumask_test_cpu(cpu, mask)) {
  493. local_irq_disable();
  494. func(info);
  495. local_irq_enable();
  496. }
  497. put_cpu();
  498. }
  499. EXPORT_SYMBOL(on_each_cpu_mask);
  500. /*
  501. * on_each_cpu_cond(): Call a function on each processor for which
  502. * the supplied function cond_func returns true, optionally waiting
  503. * for all the required CPUs to finish. This may include the local
  504. * processor.
  505. * @cond_func: A callback function that is passed a cpu id and
  506. * the the info parameter. The function is called
  507. * with preemption disabled. The function should
  508. * return a blooean value indicating whether to IPI
  509. * the specified CPU.
  510. * @func: The function to run on all applicable CPUs.
  511. * This must be fast and non-blocking.
  512. * @info: An arbitrary pointer to pass to both functions.
  513. * @wait: If true, wait (atomically) until function has
  514. * completed on other CPUs.
  515. * @gfp_flags: GFP flags to use when allocating the cpumask
  516. * used internally by the function.
  517. *
  518. * The function might sleep if the GFP flags indicates a non
  519. * atomic allocation is allowed.
  520. *
  521. * Preemption is disabled to protect against CPUs going offline but not online.
  522. * CPUs going online during the call will not be seen or sent an IPI.
  523. *
  524. * You must not call this function with disabled interrupts or
  525. * from a hardware interrupt handler or from a bottom half handler.
  526. */
  527. void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
  528. smp_call_func_t func, void *info, bool wait,
  529. gfp_t gfp_flags)
  530. {
  531. cpumask_var_t cpus;
  532. int cpu, ret;
  533. might_sleep_if(gfp_flags & __GFP_WAIT);
  534. if (likely(zalloc_cpumask_var(&cpus, (gfp_flags|__GFP_NOWARN)))) {
  535. preempt_disable();
  536. for_each_online_cpu(cpu)
  537. if (cond_func(cpu, info))
  538. cpumask_set_cpu(cpu, cpus);
  539. on_each_cpu_mask(cpus, func, info, wait);
  540. preempt_enable();
  541. free_cpumask_var(cpus);
  542. } else {
  543. /*
  544. * No free cpumask, bother. No matter, we'll
  545. * just have to IPI them one by one.
  546. */
  547. preempt_disable();
  548. for_each_online_cpu(cpu)
  549. if (cond_func(cpu, info)) {
  550. ret = smp_call_function_single(cpu, func,
  551. info, wait);
  552. WARN_ON_ONCE(!ret);
  553. }
  554. preempt_enable();
  555. }
  556. }
  557. EXPORT_SYMBOL(on_each_cpu_cond);
  558. static void do_nothing(void *unused)
  559. {
  560. }
  561. /**
  562. * kick_all_cpus_sync - Force all cpus out of idle
  563. *
  564. * Used to synchronize the update of pm_idle function pointer. It's
  565. * called after the pointer is updated and returns after the dummy
  566. * callback function has been executed on all cpus. The execution of
  567. * the function can only happen on the remote cpus after they have
  568. * left the idle function which had been called via pm_idle function
  569. * pointer. So it's guaranteed that nothing uses the previous pointer
  570. * anymore.
  571. */
  572. void kick_all_cpus_sync(void)
  573. {
  574. /* Make sure the change is visible before we kick the cpus */
  575. smp_mb();
  576. smp_call_function(do_nothing, NULL, 1);
  577. }
  578. EXPORT_SYMBOL_GPL(kick_all_cpus_sync);