up.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Uniprocessor-only support functions. The counterpart to kernel/smp.c
  3. */
  4. #include <linux/interrupt.h>
  5. #include <linux/kernel.h>
  6. #include <linux/export.h>
  7. #include <linux/smp.h>
  8. int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
  9. int wait)
  10. {
  11. unsigned long flags;
  12. WARN_ON(cpu != 0);
  13. local_irq_save(flags);
  14. func(info);
  15. local_irq_restore(flags);
  16. return 0;
  17. }
  18. EXPORT_SYMBOL(smp_call_function_single);
  19. /*
  20. * Note we still need to test the mask even for UP
  21. * because we actually can get an empty mask from
  22. * code that on SMP might call us without the local
  23. * CPU in the mask.
  24. */
  25. void on_each_cpu_mask(const struct cpumask *mask,
  26. smp_call_func_t func, void *info, bool wait)
  27. {
  28. unsigned long flags;
  29. if (cpumask_test_cpu(0, mask)) {
  30. local_irq_save(flags);
  31. func(info);
  32. local_irq_restore(flags);
  33. }
  34. }
  35. EXPORT_SYMBOL(on_each_cpu_mask);
  36. /*
  37. * Preemption is disabled here to make sure the cond_func is called under the
  38. * same condtions in UP and SMP.
  39. */
  40. void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
  41. smp_call_func_t func, void *info, bool wait,
  42. gfp_t gfp_flags)
  43. {
  44. unsigned long flags;
  45. preempt_disable();
  46. if (cond_func(0, info)) {
  47. local_irq_save(flags);
  48. func(info);
  49. local_irq_restore(flags);
  50. }
  51. preempt_enable();
  52. }
  53. EXPORT_SYMBOL(on_each_cpu_cond);