cpumask.c 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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);