1ccb46000SAndrew Morton #include <linux/kernel.h> 2ccb46000SAndrew Morton #include <linux/bitops.h> 3ccb46000SAndrew Morton #include <linux/cpumask.h> 4ccb46000SAndrew Morton #include <linux/module.h> 5ccb46000SAndrew Morton 6ccb46000SAndrew Morton int __first_cpu(const cpumask_t *srcp) 7ccb46000SAndrew Morton { 8ccb46000SAndrew Morton return min_t(int, NR_CPUS, find_first_bit(srcp->bits, NR_CPUS)); 9ccb46000SAndrew Morton } 10ccb46000SAndrew Morton EXPORT_SYMBOL(__first_cpu); 11ccb46000SAndrew Morton 123d18bd74SAndrew Morton int __next_cpu(int n, const cpumask_t *srcp) 133d18bd74SAndrew Morton { 143d18bd74SAndrew Morton return min_t(int, NR_CPUS, find_next_bit(srcp->bits, NR_CPUS, n+1)); 153d18bd74SAndrew Morton } 163d18bd74SAndrew Morton EXPORT_SYMBOL(__next_cpu); 1786302820SAndrew Morton 18*41df0d61SMike Travis #if NR_CPUS > 64 19*41df0d61SMike Travis int __next_cpu_nr(int n, const cpumask_t *srcp) 20*41df0d61SMike Travis { 21*41df0d61SMike Travis return min_t(int, nr_cpu_ids, 22*41df0d61SMike Travis find_next_bit(srcp->bits, nr_cpu_ids, n+1)); 23*41df0d61SMike Travis } 24*41df0d61SMike Travis EXPORT_SYMBOL(__next_cpu_nr); 25*41df0d61SMike Travis #endif 26*41df0d61SMike Travis 2796a9b4d3SAndrew Morton int __any_online_cpu(const cpumask_t *mask) 2896a9b4d3SAndrew Morton { 2996a9b4d3SAndrew Morton int cpu; 3096a9b4d3SAndrew Morton 3196a9b4d3SAndrew Morton for_each_cpu_mask(cpu, *mask) { 3296a9b4d3SAndrew Morton if (cpu_online(cpu)) 3396a9b4d3SAndrew Morton break; 3496a9b4d3SAndrew Morton } 3596a9b4d3SAndrew Morton return cpu; 3696a9b4d3SAndrew Morton } 3796a9b4d3SAndrew Morton EXPORT_SYMBOL(__any_online_cpu); 38