Skip to content

Commit 93ba139

Browse files
committed
cpumask: use find_first_and_bit()
Now we have an efficient implementation for find_first_and_bit(), so switch cpumask to use it where appropriate. Signed-off-by: Yury Norov <[email protected]> Tested-by: Wolfram Sang <[email protected]>
1 parent f68edc9 commit 93ba139

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

include/linux/cpumask.h

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
123123
return 0;
124124
}
125125

126+
static inline unsigned int cpumask_first_and(const struct cpumask *srcp1,
127+
const struct cpumask *srcp2)
128+
{
129+
return 0;
130+
}
131+
126132
static inline unsigned int cpumask_last(const struct cpumask *srcp)
127133
{
128134
return 0;
@@ -167,7 +173,7 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node)
167173

168174
static inline int cpumask_any_and_distribute(const struct cpumask *src1p,
169175
const struct cpumask *src2p) {
170-
return cpumask_next_and(-1, src1p, src2p);
176+
return cpumask_first_and(src1p, src2p);
171177
}
172178

173179
static inline int cpumask_any_distribute(const struct cpumask *srcp)
@@ -195,6 +201,19 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
195201
return find_first_bit(cpumask_bits(srcp), nr_cpumask_bits);
196202
}
197203

204+
/**
205+
* cpumask_first_and - return the first cpu from *srcp1 & *srcp2
206+
* @src1p: the first input
207+
* @src2p: the second input
208+
*
209+
* Returns >= nr_cpu_ids if no cpus set in both. See also cpumask_next_and().
210+
*/
211+
static inline
212+
unsigned int cpumask_first_and(const struct cpumask *srcp1, const struct cpumask *srcp2)
213+
{
214+
return find_first_and_bit(cpumask_bits(srcp1), cpumask_bits(srcp2), nr_cpumask_bits);
215+
}
216+
198217
/**
199218
* cpumask_last - get the last CPU in a cpumask
200219
* @srcp: - the cpumask pointer
@@ -585,15 +604,6 @@ static inline void cpumask_copy(struct cpumask *dstp,
585604
*/
586605
#define cpumask_any(srcp) cpumask_first(srcp)
587606

588-
/**
589-
* cpumask_first_and - return the first cpu from *srcp1 & *srcp2
590-
* @src1p: the first input
591-
* @src2p: the second input
592-
*
593-
* Returns >= nr_cpu_ids if no cpus set in both. See also cpumask_next_and().
594-
*/
595-
#define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p))
596-
597607
/**
598608
* cpumask_any_and - pick a "random" cpu from *mask1 & *mask2
599609
* @mask1: the first input cpumask

0 commit comments

Comments
 (0)