Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make bitmask 'and' operators return a result code

When 'and'ing two bitmasks (where 'andnot' is a variation on it), some
cases want to know whether the result is the empty set or not. In
particular, the TLB IPI sending code wants to do cpumask operations and
determine if there are any CPU's left in the final set.

So this just makes the bitmask (and cpumask) functions return a boolean
for whether the result has any bits set.

Cc: stable@kernel.org (2.6.30, needed by TLB shootdown fix)
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+26 -24
+8 -10
include/linux/bitmap.h
··· 94 94 const unsigned long *src, int shift, int bits); 95 95 extern void __bitmap_shift_left(unsigned long *dst, 96 96 const unsigned long *src, int shift, int bits); 97 - extern void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 97 + extern int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 98 98 const unsigned long *bitmap2, int bits); 99 99 extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, 100 100 const unsigned long *bitmap2, int bits); 101 101 extern void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, 102 102 const unsigned long *bitmap2, int bits); 103 - extern void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 103 + extern int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 104 104 const unsigned long *bitmap2, int bits); 105 105 extern int __bitmap_intersects(const unsigned long *bitmap1, 106 106 const unsigned long *bitmap2, int bits); ··· 171 171 } 172 172 } 173 173 174 - static inline void bitmap_and(unsigned long *dst, const unsigned long *src1, 174 + static inline int bitmap_and(unsigned long *dst, const unsigned long *src1, 175 175 const unsigned long *src2, int nbits) 176 176 { 177 177 if (small_const_nbits(nbits)) 178 - *dst = *src1 & *src2; 179 - else 180 - __bitmap_and(dst, src1, src2, nbits); 178 + return (*dst = *src1 & *src2) != 0; 179 + return __bitmap_and(dst, src1, src2, nbits); 181 180 } 182 181 183 182 static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, ··· 197 198 __bitmap_xor(dst, src1, src2, nbits); 198 199 } 199 200 200 - static inline void bitmap_andnot(unsigned long *dst, const unsigned long *src1, 201 + static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1, 201 202 const unsigned long *src2, int nbits) 202 203 { 203 204 if (small_const_nbits(nbits)) 204 - *dst = *src1 & ~(*src2); 205 - else 206 - __bitmap_andnot(dst, src1, src2, nbits); 205 + return (*dst = *src1 & ~(*src2)) != 0; 206 + return __bitmap_andnot(dst, src1, src2, nbits); 207 207 } 208 208 209 209 static inline void bitmap_complement(unsigned long *dst, const unsigned long *src,
+10 -10
include/linux/cpumask.h
··· 43 43 * int cpu_isset(cpu, mask) true iff bit 'cpu' set in mask 44 44 * int cpu_test_and_set(cpu, mask) test and set bit 'cpu' in mask 45 45 * 46 - * void cpus_and(dst, src1, src2) dst = src1 & src2 [intersection] 46 + * int cpus_and(dst, src1, src2) dst = src1 & src2 [intersection] 47 47 * void cpus_or(dst, src1, src2) dst = src1 | src2 [union] 48 48 * void cpus_xor(dst, src1, src2) dst = src1 ^ src2 49 - * void cpus_andnot(dst, src1, src2) dst = src1 & ~src2 49 + * int cpus_andnot(dst, src1, src2) dst = src1 & ~src2 50 50 * void cpus_complement(dst, src) dst = ~src 51 51 * 52 52 * int cpus_equal(mask1, mask2) Does mask1 == mask2? ··· 179 179 } 180 180 181 181 #define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS) 182 - static inline void __cpus_and(cpumask_t *dstp, const cpumask_t *src1p, 182 + static inline int __cpus_and(cpumask_t *dstp, const cpumask_t *src1p, 183 183 const cpumask_t *src2p, int nbits) 184 184 { 185 - bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits); 185 + return bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits); 186 186 } 187 187 188 188 #define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS) ··· 201 201 202 202 #define cpus_andnot(dst, src1, src2) \ 203 203 __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS) 204 - static inline void __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p, 204 + static inline int __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p, 205 205 const cpumask_t *src2p, int nbits) 206 206 { 207 - bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits); 207 + return bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits); 208 208 } 209 209 210 210 #define cpus_complement(dst, src) __cpus_complement(&(dst), &(src), NR_CPUS) ··· 738 738 * @src1p: the first input 739 739 * @src2p: the second input 740 740 */ 741 - static inline void cpumask_and(struct cpumask *dstp, 741 + static inline int cpumask_and(struct cpumask *dstp, 742 742 const struct cpumask *src1p, 743 743 const struct cpumask *src2p) 744 744 { 745 - bitmap_and(cpumask_bits(dstp), cpumask_bits(src1p), 745 + return bitmap_and(cpumask_bits(dstp), cpumask_bits(src1p), 746 746 cpumask_bits(src2p), nr_cpumask_bits); 747 747 } 748 748 ··· 779 779 * @src1p: the first input 780 780 * @src2p: the second input 781 781 */ 782 - static inline void cpumask_andnot(struct cpumask *dstp, 782 + static inline int cpumask_andnot(struct cpumask *dstp, 783 783 const struct cpumask *src1p, 784 784 const struct cpumask *src2p) 785 785 { 786 - bitmap_andnot(cpumask_bits(dstp), cpumask_bits(src1p), 786 + return bitmap_andnot(cpumask_bits(dstp), cpumask_bits(src1p), 787 787 cpumask_bits(src2p), nr_cpumask_bits); 788 788 } 789 789
+8 -4
lib/bitmap.c
··· 179 179 } 180 180 EXPORT_SYMBOL(__bitmap_shift_left); 181 181 182 - void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 182 + int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 183 183 const unsigned long *bitmap2, int bits) 184 184 { 185 185 int k; 186 186 int nr = BITS_TO_LONGS(bits); 187 + unsigned long result = 0; 187 188 188 189 for (k = 0; k < nr; k++) 189 - dst[k] = bitmap1[k] & bitmap2[k]; 190 + result |= (dst[k] = bitmap1[k] & bitmap2[k]); 191 + return result != 0; 190 192 } 191 193 EXPORT_SYMBOL(__bitmap_and); 192 194 ··· 214 212 } 215 213 EXPORT_SYMBOL(__bitmap_xor); 216 214 217 - void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 215 + int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 218 216 const unsigned long *bitmap2, int bits) 219 217 { 220 218 int k; 221 219 int nr = BITS_TO_LONGS(bits); 220 + unsigned long result = 0; 222 221 223 222 for (k = 0; k < nr; k++) 224 - dst[k] = bitmap1[k] & ~bitmap2[k]; 223 + result |= (dst[k] = bitmap1[k] & ~bitmap2[k]); 224 + return result != 0; 225 225 } 226 226 EXPORT_SYMBOL(__bitmap_andnot); 227 227