up.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. WARN_ON(cpu != 0);
  12. local_irq_disable();
  13. (func)(info);
  14. local_irq_enable();
  15. return 0;
  16. }
  17. EXPORT_SYMBOL(smp_call_function_single);
  18. /*
  19. * Note we still need to test the mask even for UP
  20. * because we actually can get an empty mask from
  21. * code that on SMP might call us without the local
  22. * CPU in the mask.
  23. */
  24. void on_each_cpu_mask(const struct cpumask *mask,
  25. smp_call_func_t func, void *info, bool wait)
  26. {
  27. unsigned long flags;
  28. if (cpumask_test_cpu(0, mask)) {
  29. local_irq_save(flags);
  30. func(info);
  31. local_irq_restore(flags);
  32. }
  33. }
  34. EXPORT_SYMBOL(on_each_cpu_mask);
  35. /*
  36. * Preemption is disabled here to make sure the cond_func is called under the
  37. * same condtions in UP and SMP.
  38. */
  39. void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
  40. smp_call_func_t func, void *info, bool wait,
  41. gfp_t gfp_flags)
  42. {
  43. unsigned long flags;
  44. preempt_disable();
  45. if (cond_func(0, info)) {
  46. local_irq_save(flags);
  47. func(info);
  48. local_irq_restore(flags);
  49. }
  50. preempt_enable();
  51. }
  52. EXPORT_SYMBOL(on_each_cpu_cond);