Lines Matching refs:sb

113 	struct sbitmap sb;  member
159 int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
163 static inline unsigned int __map_depth(const struct sbitmap *sb, int index) in __map_depth() argument
165 if (index == sb->map_nr - 1) in __map_depth()
166 return sb->depth - (index << sb->shift); in __map_depth()
167 return 1U << sb->shift; in __map_depth()
174 static inline void sbitmap_free(struct sbitmap *sb) in sbitmap_free() argument
176 free_percpu(sb->alloc_hint); in sbitmap_free()
177 kvfree(sb->map); in sbitmap_free()
178 sb->map = NULL; in sbitmap_free()
189 void sbitmap_resize(struct sbitmap *sb, unsigned int depth);
199 int sbitmap_get(struct sbitmap *sb);
216 int sbitmap_get_shallow(struct sbitmap *sb, unsigned long shallow_depth);
224 bool sbitmap_any_bit_set(const struct sbitmap *sb);
226 #define SB_NR_TO_INDEX(sb, bitnr) ((bitnr) >> (sb)->shift) argument
227 #define SB_NR_TO_BIT(sb, bitnr) ((bitnr) & ((1U << (sb)->shift) - 1U)) argument
241 static inline void __sbitmap_for_each_set(struct sbitmap *sb, in __sbitmap_for_each_set() argument
249 if (start >= sb->depth) in __sbitmap_for_each_set()
251 index = SB_NR_TO_INDEX(sb, start); in __sbitmap_for_each_set()
252 nr = SB_NR_TO_BIT(sb, start); in __sbitmap_for_each_set()
254 while (scanned < sb->depth) { in __sbitmap_for_each_set()
257 __map_depth(sb, index) - nr, in __sbitmap_for_each_set()
258 sb->depth - scanned); in __sbitmap_for_each_set()
261 word = sb->map[index].word & ~sb->map[index].cleared; in __sbitmap_for_each_set()
275 if (!fn(sb, (index << sb->shift) + nr, data)) in __sbitmap_for_each_set()
282 if (++index >= sb->map_nr) in __sbitmap_for_each_set()
293 static inline void sbitmap_for_each_set(struct sbitmap *sb, sb_for_each_fn fn, in sbitmap_for_each_set() argument
296 __sbitmap_for_each_set(sb, 0, fn, data); in sbitmap_for_each_set()
299 static inline unsigned long *__sbitmap_word(struct sbitmap *sb, in __sbitmap_word() argument
302 return &sb->map[SB_NR_TO_INDEX(sb, bitnr)].word; in __sbitmap_word()
307 static inline void sbitmap_set_bit(struct sbitmap *sb, unsigned int bitnr) in sbitmap_set_bit() argument
309 set_bit(SB_NR_TO_BIT(sb, bitnr), __sbitmap_word(sb, bitnr)); in sbitmap_set_bit()
312 static inline void sbitmap_clear_bit(struct sbitmap *sb, unsigned int bitnr) in sbitmap_clear_bit() argument
314 clear_bit(SB_NR_TO_BIT(sb, bitnr), __sbitmap_word(sb, bitnr)); in sbitmap_clear_bit()
323 static inline void sbitmap_deferred_clear_bit(struct sbitmap *sb, unsigned int bitnr) in sbitmap_deferred_clear_bit() argument
325 unsigned long *addr = &sb->map[SB_NR_TO_INDEX(sb, bitnr)].cleared; in sbitmap_deferred_clear_bit()
327 set_bit(SB_NR_TO_BIT(sb, bitnr), addr); in sbitmap_deferred_clear_bit()
334 static inline void sbitmap_put(struct sbitmap *sb, unsigned int bitnr) in sbitmap_put() argument
336 sbitmap_deferred_clear_bit(sb, bitnr); in sbitmap_put()
338 if (likely(sb->alloc_hint && !sb->round_robin && bitnr < sb->depth)) in sbitmap_put()
339 *raw_cpu_ptr(sb->alloc_hint) = bitnr; in sbitmap_put()
342 static inline int sbitmap_test_bit(struct sbitmap *sb, unsigned int bitnr) in sbitmap_test_bit() argument
344 return test_bit(SB_NR_TO_BIT(sb, bitnr), __sbitmap_word(sb, bitnr)); in sbitmap_test_bit()
372 void sbitmap_show(struct sbitmap *sb, struct seq_file *m);
382 unsigned int sbitmap_weight(const struct sbitmap *sb);
393 void sbitmap_bitmap_show(struct sbitmap *sb, struct seq_file *m);
418 sbitmap_free(&sbq->sb); in sbitmap_queue_free()