cpumask.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <linux/kernel.h>
  2. #include <linux/bitops.h>
  3. #include <linux/cpumask.h>
  4. #include <linux/module.h>
  5. int __first_cpu(const cpumask_t *srcp)
  6. {
  7. return min_t(int, NR_CPUS, find_first_bit(srcp->bits, NR_CPUS));
  8. }
  9. EXPORT_SYMBOL(__first_cpu);
  10. int __next_cpu(int n, const cpumask_t *srcp)
  11. {
  12. return min_t(int, NR_CPUS, find_next_bit(srcp->bits, NR_CPUS, n+1));
  13. }
  14. EXPORT_SYMBOL(__next_cpu);
  15. /*
  16. * Find the highest possible smp_processor_id()
  17. *
  18. * Note: if we're prepared to assume that cpu_possible_map never changes
  19. * (reasonable) then this function should cache its return value.
  20. */
  21. int highest_possible_processor_id(void)
  22. {
  23. unsigned int cpu;
  24. unsigned highest = 0;
  25. for_each_cpu_mask(cpu, cpu_possible_map)
  26. highest = cpu;
  27. return highest;
  28. }
  29. EXPORT_SYMBOL(highest_possible_processor_id);
  30. int __any_online_cpu(const cpumask_t *mask)
  31. {
  32. int cpu;
  33. for_each_cpu_mask(cpu, *mask) {
  34. if (cpu_online(cpu))
  35. break;
  36. }
  37. return cpu;
  38. }
  39. EXPORT_SYMBOL(__any_online_cpu);
  40. #if MAX_NUMNODES > 1
  41. /*
  42. * Find the highest possible node id.
  43. */
  44. int highest_possible_node_id(void)
  45. {
  46. unsigned int node;
  47. unsigned int highest = 0;
  48. for_each_node_mask(node, node_possible_map)
  49. highest = node;
  50. return highest;
  51. }
  52. EXPORT_SYMBOL(highest_possible_node_id);
  53. #endif