Lines Matching refs:sb
113 struct sbitmap sb; member
170 int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
174 static inline unsigned int __map_depth(const struct sbitmap *sb, int index) in __map_depth() argument
176 if (index == sb->map_nr - 1) in __map_depth()
177 return sb->depth - (index << sb->shift); in __map_depth()
178 return 1U << sb->shift; in __map_depth()
185 static inline void sbitmap_free(struct sbitmap *sb) in sbitmap_free() argument
187 free_percpu(sb->alloc_hint); in sbitmap_free()
188 kvfree(sb->map); in sbitmap_free()
189 sb->map = NULL; in sbitmap_free()
200 void sbitmap_resize(struct sbitmap *sb, unsigned int depth);
210 int sbitmap_get(struct sbitmap *sb);
227 int sbitmap_get_shallow(struct sbitmap *sb, unsigned long shallow_depth);
235 bool sbitmap_any_bit_set(const struct sbitmap *sb);
237 #define SB_NR_TO_INDEX(sb, bitnr) ((bitnr) >> (sb)->shift) argument
238 #define SB_NR_TO_BIT(sb, bitnr) ((bitnr) & ((1U << (sb)->shift) - 1U)) argument
252 static inline void __sbitmap_for_each_set(struct sbitmap *sb, in __sbitmap_for_each_set() argument
260 if (start >= sb->depth) in __sbitmap_for_each_set()
262 index = SB_NR_TO_INDEX(sb, start); in __sbitmap_for_each_set()
263 nr = SB_NR_TO_BIT(sb, start); in __sbitmap_for_each_set()
265 while (scanned < sb->depth) { in __sbitmap_for_each_set()
268 __map_depth(sb, index) - nr, in __sbitmap_for_each_set()
269 sb->depth - scanned); in __sbitmap_for_each_set()
272 word = sb->map[index].word & ~sb->map[index].cleared; in __sbitmap_for_each_set()
286 if (!fn(sb, (index << sb->shift) + nr, data)) in __sbitmap_for_each_set()
293 if (++index >= sb->map_nr) in __sbitmap_for_each_set()
304 static inline void sbitmap_for_each_set(struct sbitmap *sb, sb_for_each_fn fn, in sbitmap_for_each_set() argument
307 __sbitmap_for_each_set(sb, 0, fn, data); in sbitmap_for_each_set()
310 static inline unsigned long *__sbitmap_word(struct sbitmap *sb, in __sbitmap_word() argument
313 return &sb->map[SB_NR_TO_INDEX(sb, bitnr)].word; in __sbitmap_word()
318 static inline void sbitmap_set_bit(struct sbitmap *sb, unsigned int bitnr) in sbitmap_set_bit() argument
320 set_bit(SB_NR_TO_BIT(sb, bitnr), __sbitmap_word(sb, bitnr)); in sbitmap_set_bit()
323 static inline void sbitmap_clear_bit(struct sbitmap *sb, unsigned int bitnr) in sbitmap_clear_bit() argument
325 clear_bit(SB_NR_TO_BIT(sb, bitnr), __sbitmap_word(sb, bitnr)); in sbitmap_clear_bit()
334 static inline void sbitmap_deferred_clear_bit(struct sbitmap *sb, unsigned int bitnr) in sbitmap_deferred_clear_bit() argument
336 unsigned long *addr = &sb->map[SB_NR_TO_INDEX(sb, bitnr)].cleared; in sbitmap_deferred_clear_bit()
338 set_bit(SB_NR_TO_BIT(sb, bitnr), addr); in sbitmap_deferred_clear_bit()
345 static inline void sbitmap_put(struct sbitmap *sb, unsigned int bitnr) in sbitmap_put() argument
347 sbitmap_deferred_clear_bit(sb, bitnr); in sbitmap_put()
349 if (likely(sb->alloc_hint && !sb->round_robin && bitnr < sb->depth)) in sbitmap_put()
350 *raw_cpu_ptr(sb->alloc_hint) = bitnr; in sbitmap_put()
353 static inline int sbitmap_test_bit(struct sbitmap *sb, unsigned int bitnr) in sbitmap_test_bit() argument
355 return test_bit(SB_NR_TO_BIT(sb, bitnr), __sbitmap_word(sb, bitnr)); in sbitmap_test_bit()
383 void sbitmap_show(struct sbitmap *sb, struct seq_file *m);
393 unsigned int sbitmap_weight(const struct sbitmap *sb);
404 void sbitmap_bitmap_show(struct sbitmap *sb, struct seq_file *m);
429 sbitmap_free(&sbq->sb); in sbitmap_queue_free()