@@ -307,7 +307,22 @@ static int __sbitmap_get_shallow(struct sbitmap *sb,
307307 return sbitmap_find_bit (sb , shallow_depth , index , alloc_hint , true);
308308}
309309
310- int sbitmap_get_shallow (struct sbitmap * sb , unsigned long shallow_depth )
310+ /**
311+ * sbitmap_get_shallow() - Try to allocate a free bit from a &struct sbitmap,
312+ * limiting the depth used from each word.
313+ * @sb: Bitmap to allocate from.
314+ * @shallow_depth: The maximum number of bits to allocate from the bitmap.
315+ *
316+ * This rather specific operation allows for having multiple users with
317+ * different allocation limits. E.g., there can be a high-priority class that
318+ * uses sbitmap_get() and a low-priority class that uses sbitmap_get_shallow()
319+ * with a @shallow_depth of (sb->depth >> 1). Then, the low-priority
320+ * class can only allocate half of the total bits in the bitmap, preventing it
321+ * from starving out the high-priority class.
322+ *
323+ * Return: Non-negative allocated bit number if successful, -1 otherwise.
324+ */
325+ static int sbitmap_get_shallow (struct sbitmap * sb , unsigned long shallow_depth )
311326{
312327 int nr ;
313328 unsigned int hint , depth ;
@@ -322,7 +337,6 @@ int sbitmap_get_shallow(struct sbitmap *sb, unsigned long shallow_depth)
322337
323338 return nr ;
324339}
325- EXPORT_SYMBOL_GPL (sbitmap_get_shallow );
326340
327341bool sbitmap_any_bit_set (const struct sbitmap * sb )
328342{
0 commit comments