Lines Matching +full:wait +full:- +full:queue

1 /* SPDX-License-Identifier: GPL-2.0-only */
6 * Copyright (C) 2013-2014 Jens Axboe
22 #include <linux/wait.h>
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.
90 * @wait: Wait queue.
92 wait_queue_head_t wait; member
96 * struct sbitmap_queue - Scalable bitmap with the added ability to wait on free
99 * A &struct sbitmap_queue uses multiple wait queues and rolling wakeups to
100 * avoid contention on the wait queue spinlock. This ensures that we don't hit a
117 * @wake_index: Next wait queue in @ws to wake up.
122 * @ws: Wait queues.
150 * sbitmap_init_node() - Initialize a &struct sbitmap on a specific memory node.
171 if (index == sb->map_nr - 1) in __map_depth()
172 return sb->depth - (index << sb->shift); in __map_depth()
173 return 1U << sb->shift; in __map_depth()
177 * sbitmap_free() - Free memory used by a &struct sbitmap.
182 free_percpu(sb->alloc_hint); in sbitmap_free()
183 kvfree(sb->map); in sbitmap_free()
184 sb->map = NULL; in sbitmap_free()
188 * sbitmap_resize() - Resize a &struct sbitmap.
198 * sbitmap_get() - Try to allocate a free bit from a &struct sbitmap.
203 * Return: Non-negative allocated bit number if successful, -1 otherwise.
208 * sbitmap_get_shallow() - Try to allocate a free bit from a &struct sbitmap,
214 * different allocation limits. E.g., there can be a high-priority class that
215 * uses sbitmap_get() and a low-priority class that uses sbitmap_get_shallow()
216 * with a @shallow_depth of (1 << (@sb->shift - 1)). Then, the low-priority
218 * from starving out the high-priority class.
220 * Return: Non-negative allocated bit number if successful, -1 otherwise.
225 * sbitmap_any_bit_set() - Check for a set bit in a &struct sbitmap.
232 #define SB_NR_TO_INDEX(sb, bitnr) ((bitnr) >> (sb)->shift)
233 #define SB_NR_TO_BIT(sb, bitnr) ((bitnr) & ((1U << (sb)->shift) - 1U))
238 * __sbitmap_for_each_set() - Iterate over each set bit in a &struct sbitmap.
244 * This is inline even though it's non-trivial so that the function calls to the
255 if (start >= sb->depth) in __sbitmap_for_each_set()
260 while (scanned < sb->depth) { in __sbitmap_for_each_set()
263 __map_depth(sb, index) - nr, in __sbitmap_for_each_set()
264 sb->depth - scanned); in __sbitmap_for_each_set()
267 word = sb->map[index].word & ~sb->map[index].cleared; in __sbitmap_for_each_set()
281 if (!fn(sb, (index << sb->shift) + nr, data)) in __sbitmap_for_each_set()
288 if (++index >= sb->map_nr) in __sbitmap_for_each_set()
294 * sbitmap_for_each_set() - Iterate over each set bit in a &struct sbitmap.
308 return &sb->map[SB_NR_TO_INDEX(sb, bitnr)].word; in __sbitmap_word()
325 * sets the corresponding bit in the ->cleared mask instead. Paired with
327 * will clear the previously freed entries in the corresponding ->word.
331 unsigned long *addr = &sb->map[SB_NR_TO_INDEX(sb, bitnr)].cleared; in sbitmap_deferred_clear_bit()
344 if (likely(sb->alloc_hint && !sb->round_robin && bitnr < sb->depth)) in sbitmap_put()
345 *raw_cpu_ptr(sb->alloc_hint) = bitnr; in sbitmap_put()
365 shift--; in sbitmap_calculate_shift()
372 * sbitmap_show() - Dump &struct sbitmap information to a &struct seq_file.
382 * sbitmap_weight() - Return how many set and not cleared bits in a &struct
391 * sbitmap_bitmap_show() - Write a hex dump of a &struct sbitmap to a &struct
402 * sbitmap_queue_init_node() - Initialize a &struct sbitmap_queue on a specific
404 * @sbq: Bitmap queue to initialize.
417 * sbitmap_queue_free() - Free memory used by a &struct sbitmap_queue.
419 * @sbq: Bitmap queue to free.
423 kfree(sbq->ws); in sbitmap_queue_free()
424 sbitmap_free(&sbq->sb); in sbitmap_queue_free()
428 * sbitmap_queue_recalculate_wake_batch() - Recalculate wake batch
429 * @sbq: Bitmap queue to recalculate wake batch.
433 * by depth. This interface is for HCTX shared tags or queue shared tags.
439 * sbitmap_queue_resize() - Resize a &struct sbitmap_queue.
440 * @sbq: Bitmap queue to resize.
450 * __sbitmap_queue_get() - Try to allocate a free bit from a &struct
452 * @sbq: Bitmap queue to allocate from.
454 * Return: Non-negative allocated bit number if successful, -1 otherwise.
459 * __sbitmap_queue_get_batch() - Try to allocate a batch of free bits
460 * @sbq: Bitmap queue to allocate from.
472 * sbitmap_queue_get_shallow() - Try to allocate a free bit from a &struct
475 * @sbq: Bitmap queue to allocate from.
482 * Return: Non-negative allocated bit number if successful, -1 otherwise.
488 * sbitmap_queue_get() - Try to allocate a free bit from a &struct
490 * @sbq: Bitmap queue to allocate from.
494 * Return: Non-negative allocated bit number if successful, -1 otherwise.
508 * sbitmap_queue_min_shallow_depth() - Inform a &struct sbitmap_queue of the
510 * @sbq: Bitmap queue in question.
525 * sbitmap_queue_clear() - Free an allocated bit and wake up waiters on a
535 * sbitmap_queue_clear_batch() - Free a batch of allocated bits
547 return (index + 1) & (SBQ_WAIT_QUEUES - 1); in sbq_index_inc()
558 * sbq_wait_ptr() - Get the next wait queue to use for a &struct
560 * @sbq: Bitmap queue to wait on.
568 ws = &sbq->ws[atomic_read(wait_index)]; in sbq_wait_ptr()
574 * sbitmap_queue_wake_all() - Wake up everything waiting on a &struct
576 * @sbq: Bitmap queue to wake up.
581 * sbitmap_queue_wake_up() - Wake up some of waiters in one waitqueue
583 * @sbq: Bitmap queue to wake up.
589 * sbitmap_queue_show() - Dump &struct sbitmap_queue information to a &struct
591 * @sbq: Bitmap queue to show.
600 struct wait_queue_entry wait; member
606 .wait = { \
609 .entry = LIST_HEAD_INIT((name).wait.entry), \