Lines Matching +full:non +full:- +full:negative
1 /* SPDX-License-Identifier: GPL-2.0-only */
6 * Copyright (C) 2013-2014 Jens Axboe
27 * struct sbitmap_word - Word in a &struct sbitmap.
42 * struct sbitmap - Scalable bitmap.
44 * A &struct sbitmap is spread over multiple cachelines to avoid ping-pong. This
64 * @round_robin: Allocate bits in strict round-robin order.
76 * This is per-cpu, which allows multiple users to stick to different
86 * struct sbq_wait_state - Wait queue in a &struct sbitmap_queue.
101 * struct sbitmap_queue - Scalable bitmap with the added ability to wait on free
144 * sbitmap_init_node() - Initialize a &struct sbitmap on a specific memory node.
147 * @shift: Use 2^@shift bits per word in the bitmap; if a negative number if
157 * Return: Zero on success or negative errno on failure.
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()
171 * sbitmap_free() - Free memory used by a &struct sbitmap.
176 free_percpu(sb->alloc_hint); in sbitmap_free()
177 kvfree(sb->map); in sbitmap_free()
178 sb->map = NULL; in sbitmap_free()
182 * sbitmap_resize() - Resize a &struct sbitmap.
192 * sbitmap_get() - Try to allocate a free bit from a &struct sbitmap.
197 * Return: Non-negative allocated bit number if successful, -1 otherwise.
202 * sbitmap_get_shallow() - Try to allocate a free bit from a &struct sbitmap,
208 * different allocation limits. E.g., there can be a high-priority class that
209 * uses sbitmap_get() and a low-priority class that uses sbitmap_get_shallow()
210 * with a @shallow_depth of (1 << (@sb->shift - 1)). Then, the low-priority
212 * from starving out the high-priority class.
214 * Return: Non-negative allocated bit number if successful, -1 otherwise.
219 * sbitmap_any_bit_set() - Check for a set bit in a &struct sbitmap.
226 #define SB_NR_TO_INDEX(sb, bitnr) ((bitnr) >> (sb)->shift)
227 #define SB_NR_TO_BIT(sb, bitnr) ((bitnr) & ((1U << (sb)->shift) - 1U))
232 * __sbitmap_for_each_set() - Iterate over each set bit in a &struct sbitmap.
238 * This is inline even though it's non-trivial so that the function calls to the
249 if (start >= sb->depth) 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()
288 * sbitmap_for_each_set() - Iterate over each set bit in a &struct sbitmap.
302 return &sb->map[SB_NR_TO_INDEX(sb, bitnr)].word; in __sbitmap_word()
319 * sets the corresponding bit in the ->cleared mask instead. Paired with
321 * will clear the previously freed entries in the corresponding ->word.
325 unsigned long *addr = &sb->map[SB_NR_TO_INDEX(sb, bitnr)].cleared; in sbitmap_deferred_clear_bit()
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()
359 shift--; in sbitmap_calculate_shift()
366 * sbitmap_show() - Dump &struct sbitmap information to a &struct seq_file.
376 * sbitmap_weight() - Return how many set and not cleared bits in a &struct
385 * sbitmap_bitmap_show() - Write a hex dump of a &struct sbitmap to a &struct
396 * sbitmap_queue_init_node() - Initialize a &struct sbitmap_queue on a specific
405 * Return: Zero on success or negative errno on failure.
411 * sbitmap_queue_free() - Free memory used by a &struct sbitmap_queue.
417 kfree(sbq->ws); in sbitmap_queue_free()
418 sbitmap_free(&sbq->sb); in sbitmap_queue_free()
422 * sbitmap_queue_recalculate_wake_batch() - Recalculate wake batch
433 * sbitmap_queue_resize() - Resize a &struct sbitmap_queue.
444 * __sbitmap_queue_get() - Try to allocate a free bit from a &struct
448 * Return: Non-negative allocated bit number if successful, -1 otherwise.
453 * __sbitmap_queue_get_batch() - Try to allocate a batch of free bits
466 * sbitmap_queue_get_shallow() - Try to allocate a free bit from a &struct
476 * Return: Non-negative allocated bit number if successful, -1 otherwise.
482 * sbitmap_queue_get() - Try to allocate a free bit from a &struct
488 * Return: Non-negative allocated bit number if successful, -1 otherwise.
502 * sbitmap_queue_min_shallow_depth() - Inform a &struct sbitmap_queue of the
519 * sbitmap_queue_clear() - Free an allocated bit and wake up waiters on a
529 * sbitmap_queue_clear_batch() - Free a batch of allocated bits
541 return (index + 1) & (SBQ_WAIT_QUEUES - 1); in sbq_index_inc()
552 * sbq_wait_ptr() - Get the next wait queue to use for a &struct
562 ws = &sbq->ws[atomic_read(wait_index)]; in sbq_wait_ptr()
568 * sbitmap_queue_wake_all() - Wake up everything waiting on a &struct
575 * sbitmap_queue_wake_up() - Wake up some of waiters in one waitqueue
583 * sbitmap_queue_show() - Dump &struct sbitmap_queue information to a &struct