@@ -307,7 +307,22 @@ static int __sbitmap_get_shallow(struct sbitmap *sb,
307
307
return sbitmap_find_bit (sb , shallow_depth , index , alloc_hint , true);
308
308
}
309
309
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 )
311
326
{
312
327
int nr ;
313
328
unsigned int hint , depth ;
@@ -322,7 +337,6 @@ int sbitmap_get_shallow(struct sbitmap *sb, unsigned long shallow_depth)
322
337
323
338
return nr ;
324
339
}
325
- EXPORT_SYMBOL_GPL (sbitmap_get_shallow );
326
340
327
341
bool sbitmap_any_bit_set (const struct sbitmap * sb )
328
342
{
0 commit comments