Skip to contentSkip to conversation

bitmap: cleanup bitmap_*_region() implementation

PATCH Superseded Yury Norov 2 participants 19 messages Aug 15, 2023 – Aug 29, 2023

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Yury Norov

author maintainer
#0 lore raw

v3 cover bitmap: cleanup bitmap_*_region() implementation

bitmap_{allocate,find_free,release}_region() functions are implemented on top of _reg_op() machinery. It duplicates existing generic functionality with no benefits. In fact, generic alternatives may work even better because they optimized for small_const_nbits() case and overall very well optimized for performance and code generation.

This series drops _reg_op() entirely.

v2: https://lore.kernel.org/lkml/[email protected]/T/
v3:
- add test for the functions;
- fix bitmap_alloc_region();
- fix comments and wrappers style.

Yury Norov (8):
bitmap: align __reg_op() wrappers with modern coding style
bitmap: add test for bitmap_*_region() functions
bitmap: fix opencoded bitmap_allocate_region()
bitmap: replace _reg_op(REG_OP_ALLOC) with bitmap_set()
bitmap: replace _reg_op(REG_OP_RELEASE) with bitmap_clear()
bitmap: replace _reg_op(REG_OP_ISFREE) with find_next_bit()
bitmap: drop _reg_op() function
bitmap: move bitmap_*_region functions to bitmap.h

 include/linux/bitmap.h |  63 ++++++++++++++++++-
 lib/bitmap.c           | 140 -----------------------------------------
 lib/test_bitmap.c      |  24 +++++++
 3 files changed, 84 insertions(+), 143 deletions(-)
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH v3 1/8 bitmap: align __reg_op() wrappers with modern coding style

Fix comments so that scripts/kernel-doc doesn't warn, and fix for-loop style in bitmap_find_free_region().

---
 lib/bitmap.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
lib/bitmap.c +5 -7
index bf6b0eea1af8..76bf79261107 100644
@@ -1238,8 +1238,8 @@ void bitmap_fold(unsigned long *dst, const unsigned long *orig,
  * some size '1 << order' (a power of two), aligned to that same
  * '1 << order' power of two.
  *
- * Returns 1 if REG_OP_ISFREE succeeds (region is all zero bits).
- * Returns 0 in all other cases and reg_ops.
+ * Return: 1 if REG_OP_ISFREE succeeds (region is all zero bits).
+ *	   0 in all other cases and reg_ops.
  */
 
 enum {
@@ -1311,14 +1311,14 @@ static int __reg_op(unsigned long *bitmap, unsigned int pos, int order, int reg_
  * a power (@order) of two, aligned to that power of two, which
  * makes the search algorithm much faster.
  *
- * Return the bit offset in bitmap of the allocated region,
+ * Return: the bit offset in bitmap of the allocated region,
  * or -errno on failure.
  */
 int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order)
 {
 	unsigned int pos, end;		/* scans bitmap by regions of size order */
 
-	for (pos = 0 ; (end = pos + (1U << order)) <= bits; pos = end) {
+	for (pos = 0; (end = pos + BIT(order)) <= bits; pos = end) {
 		if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
 			continue;
 		__reg_op(bitmap, pos, order, REG_OP_ALLOC);
@@ -1336,8 +1336,6 @@ EXPORT_SYMBOL(bitmap_find_free_region);
  *
  * This is the complement to __bitmap_find_free_region() and releases
  * the found region (by clearing it in the bitmap).
- *
- * No return value.
  */
 void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order)
 {
@@ -1353,7 +1351,7 @@ EXPORT_SYMBOL(bitmap_release_region);
  *
  * Allocate (set bits in) a specified region of a bitmap.
  *
- * Return 0 on success, or %-EBUSY if specified region wasn't
+ * Return: 0 on success, or %-EBUSY if specified region wasn't
  * free (not all bits were zero).
  */
 int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order)
Signature · 1 line
2.39.2
Reviewed-by on v3 1/8
#2 lore raw

Re: [PATCH v3 1/8] bitmap: align __reg_op() wrappers with modern coding style

Quoted 2 lines · Yury Norov

Fix comments so that scripts/kernel-doc doesn't warn, and fix for-loop style in bitmap_find_free_region().

Suggested-by?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#3 lore raw

Re: [PATCH v3 1/8] bitmap: align __reg_op() wrappers with modern coding style

Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Yury Norov

Fix comments so that scripts/kernel-doc doesn't warn, and fix for-loop style in bitmap_find_free_region().

Suggested-by?

Can you send a full tag?

Quoted 6 lines
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Re: [PATCH v3 1/8] bitmap: align __reg_op() wrappers with modern coding style

Quoted 8 lines · Yury Norov
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Yury Norov

Fix comments so that scripts/kernel-doc doesn't warn, and fix for-loop style in bitmap_find_free_region().

Suggested-by?

Can you send a full tag?

I thought it's easy to get... Nevertheless it's here.

Quoted 1 line
Quoted 1 line

Btw, there are things needs to be fixed/improved as well:
1) bitmap_pos_to_ord(): reference to @nbits instead of @bits;
2) bitmap_parse(): wrong/confusing reference to a list, while should be better example for under 32-bit input and over it with spaces and/or commas;
3) style of the descriptions of the parameters:
* @param :
vs.
* @param: /// preferable
4) bitmap_cut(): make nbits a reference as @nbits in some cases;
5) empty line after the function summary (should be dropped), e.g. in bitmap_parse_user();
6) true and false can be referred )in bitmap_print_to_buf(), for example) as constants %true. %false (up to you).

Maybe something else... That said, the documentation should be revisited carefully.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#5 lore raw

PATCH v3 2/8 bitmap: add test for bitmap_*_region() functions

In reply to Yury Norov

Test basic functionality of bitmap_{allocate,release,find_free}_region() functions.

---
 lib/test_bitmap.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
lib/test_bitmap.c +24 -0
index f2ea9f30c7c5..def7d2f9bd14 100644
@@ -330,6 +330,29 @@ static void __init test_copy(void)
 	expect_eq_pbl("0-108,128-1023", bmap2, 1024);
 }
 
+static void __init test_bitmap_region(void)
+{
+	int pos, order;
+
+	DECLARE_BITMAP(bmap, 1000);
+
+	bitmap_zero(bmap, 1000);
+
+	for (order = 0; order < 10; order++) {
+		pos = bitmap_find_free_region(bmap, 1000, order);
+		if (order == 0)
+			expect_eq_uint(pos, 0);
+		else
+			expect_eq_uint(pos, BIT(order) < 512 ? BIT(order) : -ENOMEM);
+	}
+
+	bitmap_release_region(bmap, 0, 0);
+	for (order = 1; order < 9; order++)
+		bitmap_release_region(bmap, BIT(order), order);
+
+	expect_eq_uint(bitmap_weight(bmap, 1000), 0);
+}
+
 #define EXP2_IN_BITS	(sizeof(exp2) * 8)
 
 static void __init test_replace(void)
@@ -1227,6 +1250,7 @@ static void __init selftest(void)
 	test_zero_clear();
 	test_fill_set();
 	test_copy();
+	test_bitmap_region();
 	test_replace();
 	test_bitmap_arr32();
 	test_bitmap_arr64();
Signature · 1 line
2.39.2
#6 lore raw

Re: [PATCH v3 2/8] bitmap: add test for bitmap_*_region() functions

Quoted 2 lines · Yury Norov

Test basic functionality of bitmap_{allocate,release,find_free}_region() functions.

...

lib/test_bitmap.c static void __init test_copy(void) · line 346

Quoted 6 lines
lib/test_bitmap.c +6 -0
+	for (order = 0; order < 10; order++) {
+		pos = bitmap_find_free_region(bmap, 1000, order);
+		if (order == 0)
+			expect_eq_uint(pos, 0);
+		else
+			expect_eq_uint(pos, BIT(order) < 512 ? BIT(order) : -ENOMEM);
			expect_eq_uint(pos, order < 9 ? BIT(order) : -ENOMEM);

or if the intention to show the relation to 1000,

			expect_eq_uint(pos, order < ilog2(1000) ? BIT(order) : -ENOMEM);
Quoted 1 line
(quoted diff) +1 -0
+	}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#7 lore raw

PATCH v3 3/8 bitmap: fix opencoded bitmap_allocate_region()

In reply to Yury Norov

bitmap_find_region() opencodes bitmap_allocate_region(). Fix it.

---
 lib/bitmap.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
lib/bitmap.c +2 -4
index 76bf79261107..4c9f119240cc 100644
@@ -1319,10 +1319,8 @@ int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order)
 	unsigned int pos, end;		/* scans bitmap by regions of size order */
 
 	for (pos = 0; (end = pos + BIT(order)) <= bits; pos = end) {
-		if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
-			continue;
-		__reg_op(bitmap, pos, order, REG_OP_ALLOC);
-		return pos;
+		if (!bitmap_allocate_region(bitmap, pos, order))
+			return pos;
 	}
 	return -ENOMEM;
 }
Signature · 1 line
2.39.2
#8 lore raw

Re: [PATCH v3 3/8] bitmap: fix opencoded bitmap_allocate_region()

Quoted 1 line · Yury Norov

bitmap_find_region() opencodes bitmap_allocate_region(). Fix it.

...

lib/bitmap.c int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order) · line 1323

Quoted 7 lines
lib/bitmap.c +2 -4
 	for (pos = 0; (end = pos + BIT(order)) <= bits; pos = end) {
-		if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
-			continue;
-		__reg_op(bitmap, pos, order, REG_OP_ALLOC);
-		return pos;
+		if (!bitmap_allocate_region(bitmap, pos, order))
+			return pos;

You can also leave more code untouched, by replacing only first conditional with

		if (bitmap_allocate_region(bitmap, pos, order))
			continue;
		return pos;
Quoted 2 lines
lib/bitmap.c +0 -0
 	}
 	return -ENOMEM;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#9 lore raw

Re: [PATCH v3 3/8] bitmap: fix opencoded bitmap_allocate_region()

Quoted 16 lines · Andy Shevchenko
Quoted 1 line · Yury Norov

bitmap_find_region() opencodes bitmap_allocate_region(). Fix it.

...

lib/bitmap.c int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order) · line 1323

Quoted 7 lines
lib/bitmap.c +2 -4
 	for (pos = 0; (end = pos + BIT(order)) <= bits; pos = end) {
-		if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
-			continue;
-		__reg_op(bitmap, pos, order, REG_OP_ALLOC);
-		return pos;
+		if (!bitmap_allocate_region(bitmap, pos, order))
+			return pos;

You can also leave more code untouched, by replacing only first conditional with

Quoted 3 lines
		if (bitmap_allocate_region(bitmap, pos, order))
			continue;
		return pos;

This looks weird, and doesn't help preserving history because the following patch moves everything from c-file to the header. I'd prefer to keep this as is.

Quoted 8 lines
Quoted 3 lines
lib/bitmap.c +0 -0
 	}
 	return -ENOMEM;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#10 lore raw

PATCH v3 4/8 bitmap: replace _reg_op(REG_OP_ALLOC) with bitmap_set()

In reply to Yury Norov

_reg_op(REG_OP_ALLOC) duplicates bitmap_set(). Fix it.

---
 lib/bitmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/bitmap.c +4 -1
index 4c9f119240cc..b7ea47b9f09d 100644
@@ -1354,9 +1354,12 @@ EXPORT_SYMBOL(bitmap_release_region);
  */
 int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order)
 {
+	unsigned int len = BIT(order);
+
 	if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
 		return -EBUSY;
-	return __reg_op(bitmap, pos, order, REG_OP_ALLOC);
+	bitmap_set(bitmap, pos, len);
+	return 0;
 }
 EXPORT_SYMBOL(bitmap_allocate_region);
 
Signature · 1 line
2.39.2
#11 lore raw

Re: [PATCH v3 4/8] bitmap: replace _reg_op(REG_OP_ALLOC) with bitmap_set()

Quoted 1 line · Yury Norov

_reg_op(REG_OP_ALLOC) duplicates bitmap_set(). Fix it.

This is not a fix.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#12 lore raw

PATCH v3 5/8 bitmap: replace _reg_op(REG_OP_RELEASE) with bitmap_clear()

In reply to Yury Norov

_reg_op(REG_OP_RELEASE) duplicates bitmap_clear(). Fix it.

---
 lib/bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bitmap.c +1 -1
index b7ea47b9f09d..2898ec2bdef1 100644
@@ -1337,7 +1337,7 @@ EXPORT_SYMBOL(bitmap_find_free_region);
  */
 void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order)
 {
-	__reg_op(bitmap, pos, order, REG_OP_RELEASE);
+	bitmap_clear(bitmap, pos, BIT(order));
 }
 EXPORT_SYMBOL(bitmap_release_region);
 
Signature · 1 line
2.39.2
#13 lore raw

Re: [PATCH v3 5/8] bitmap: replace _reg_op(REG_OP_RELEASE) with bitmap_clear()

Quoted 1 line · Yury Norov

_reg_op(REG_OP_RELEASE) duplicates bitmap_clear(). Fix it.

Ditto, it's not a fix per se.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#14 lore raw

PATCH v3 6/8 bitmap: replace _reg_op(REG_OP_ISFREE) with find_next_bit()

In reply to Yury Norov

_reg_op(REG_OP_ISFREE) can be trivially replaced with find_next_bit(). Doing that opens room for potential small_const_nbits() optimization.

---
 lib/bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bitmap.c +1 -1
index 2898ec2bdef1..c29140e27d20 100644
@@ -1356,7 +1356,7 @@ int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order)
 {
 	unsigned int len = BIT(order);
 
-	if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
+	if (find_next_bit(bitmap, pos + len, pos) < pos + len)
 		return -EBUSY;
 	bitmap_set(bitmap, pos, len);
 	return 0;
Signature · 1 line
2.39.2
author maintainer
#15 lore raw

PATCH v3 7/8 bitmap: drop _reg_op() function

In reply to Yury Norov

Now that all _reg_op() users are switched to alternative functions, _reg_op() machinery is not needed anymore.

---
 lib/bitmap.c | 76 ----------------------------------------------------
 1 file changed, 76 deletions(-)
lib/bitmap.c +0 -76
index c29140e27d20..ffbd400605ac 100644
@@ -1224,82 +1224,6 @@ void bitmap_fold(unsigned long *dst, const unsigned long *orig,
 }
 #endif /* CONFIG_NUMA */
 
-/*
- * Common code for bitmap_*_region() routines.
- *	bitmap: array of unsigned longs corresponding to the bitmap
- *	pos: the beginning of the region
- *	order: region size (log base 2 of number of bits)
- *	reg_op: operation(s) to perform on that region of bitmap
- *
- * Can set, verify and/or release a region of bits in a bitmap,
- * depending on which combination of REG_OP_* flag bits is set.
- *
- * A region of a bitmap is a sequence of bits in the bitmap, of
- * some size '1 << order' (a power of two), aligned to that same
- * '1 << order' power of two.
- *
- * Return: 1 if REG_OP_ISFREE succeeds (region is all zero bits).
- *	   0 in all other cases and reg_ops.
- */
-
-enum {
-	REG_OP_ISFREE,		/* true if region is all zero bits */
-	REG_OP_ALLOC,		/* set all bits in region */
-	REG_OP_RELEASE,		/* clear all bits in region */
-};
-
-static int __reg_op(unsigned long *bitmap, unsigned int pos, int order, int reg_op)
-{
-	int nbits_reg;		/* number of bits in region */
-	int index;		/* index first long of region in bitmap */
-	int offset;		/* bit offset region in bitmap[index] */
-	int nlongs_reg;		/* num longs spanned by region in bitmap */
-	int nbitsinlong;	/* num bits of region in each spanned long */
-	unsigned long mask;	/* bitmask for one long of region */
-	int i;			/* scans bitmap by longs */
-	int ret = 0;		/* return value */
-
-	/*
-	 * Either nlongs_reg == 1 (for small orders that fit in one long)
-	 * or (offset == 0 && mask == ~0UL) (for larger multiword orders.)
-	 */
-	nbits_reg = 1 << order;
-	index = pos / BITS_PER_LONG;
-	offset = pos - (index * BITS_PER_LONG);
-	nlongs_reg = BITS_TO_LONGS(nbits_reg);
-	nbitsinlong = min(nbits_reg,  BITS_PER_LONG);
-
-	/*
-	 * Can't do "mask = (1UL << nbitsinlong) - 1", as that
-	 * overflows if nbitsinlong == BITS_PER_LONG.
-	 */
-	mask = (1UL << (nbitsinlong - 1));
-	mask += mask - 1;
-	mask <<= offset;
-
-	switch (reg_op) {
-	case REG_OP_ISFREE:
-		for (i = 0; i < nlongs_reg; i++) {
-			if (bitmap[index + i] & mask)
-				goto done;
-		}
-		ret = 1;	/* all bits in region free (zero) */
-		break;
-
-	case REG_OP_ALLOC:
-		for (i = 0; i < nlongs_reg; i++)
-			bitmap[index + i] |= mask;
-		break;
-
-	case REG_OP_RELEASE:
-		for (i = 0; i < nlongs_reg; i++)
-			bitmap[index + i] &= ~mask;
-		break;
-	}
-done:
-	return ret;
-}
-
 /**
  * bitmap_find_free_region - find a contiguous aligned mem region
  *	@bitmap: array of unsigned longs corresponding to the bitmap
Signature · 1 line
2.39.2
#16 lore raw

Re: [PATCH v3 7/8] bitmap: drop _reg_op() function

Quoted 2 lines · Yury Norov

Now that all _reg_op() users are switched to alternative functions, _reg_op() machinery is not needed anymore.

...

Quoted 6 lines

- * Can set, verify and/or release a region of bits in a bitmap,
- * depending on which combination of REG_OP_* flag bits is set.
- *
- * A region of a bitmap is a sequence of bits in the bitmap, of
- * some size '1 << order' (a power of two), aligned to that same
- * '1 << order' power of two.

Just wondering if we have some equivalent to the above doc in the existing kernel doc of users of this.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#17 lore raw

Re: [PATCH v3 7/8] bitmap: drop _reg_op() function

Quoted 13 lines · Andy Shevchenko
Quoted 2 lines · Yury Norov

Now that all _reg_op() users are switched to alternative functions, _reg_op() machinery is not needed anymore.

...

Quoted 6 lines

- * Can set, verify and/or release a region of bits in a bitmap,
- * depending on which combination of REG_OP_* flag bits is set.
- *
- * A region of a bitmap is a sequence of bits in the bitmap, of
- * some size '1 << order' (a power of two), aligned to that same
- * '1 << order' power of two.

Quoted 2 lines

Just wondering if we have some equivalent to the above doc in the existing kernel doc of users of this.

This comment is not fully correct because the code doesn't enforce alignment of the region. Let's drop this part just as well.

author maintainer
#18 lore raw

PATCH v3 8/8 bitmap: move bitmap_*_region functions to bitmap.h

In reply to Yury Norov

Now that bitmap_*_region() functions are implemented as thin wrappers around others, it's worth to move them to the header, as it opens room for compile-time optimizations.

---
 include/linux/bitmap.h | 63 ++++++++++++++++++++++++++++++++++++++++--
 lib/bitmap.c           | 63 ------------------------------------------
 2 files changed, 60 insertions(+), 66 deletions(-)
include/linux/bitmap.h +60 -3
index 03644237e1ef..cadb1113ae09 100644
@@ -216,9 +216,6 @@ void bitmap_onto(unsigned long *dst, const unsigned long *orig,
 		const unsigned long *relmap, unsigned int bits);
 void bitmap_fold(unsigned long *dst, const unsigned long *orig,
 		unsigned int sz, unsigned int nbits);
-int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order);
-void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order);
-int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order);
 
 #ifdef __BIG_ENDIAN
 void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int nbits);
@@ -599,6 +596,66 @@ static inline void bitmap_set_value8(unsigned long *map, unsigned long value,
 	map[index] |= value << offset;
 }
 
+/**
+ * bitmap_release_region - release allocated bitmap region
+ *	@bitmap: array of unsigned longs corresponding to the bitmap
+ *	@pos: beginning of bit region to release
+ *	@order: region size (log base 2 of number of bits) to release
+ *
+ * This is the complement to __bitmap_find_free_region() and releases
+ * the found region (by clearing it in the bitmap).
+ */
+static inline void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order)
+{
+	bitmap_clear(bitmap, pos, BIT(order));
+}
+
+/**
+ * bitmap_allocate_region - allocate bitmap region
+ *	@bitmap: array of unsigned longs corresponding to the bitmap
+ *	@pos: beginning of bit region to allocate
+ *	@order: region size (log base 2 of number of bits) to allocate
+ *
+ * Allocate (set bits in) a specified region of a bitmap.
+ *
+ * Return: 0 on success, or %-EBUSY if specified region wasn't
+ * free (not all bits were zero).
+ */
+static inline int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order)
+{
+	unsigned int len = BIT(order);
+
+	if (find_next_bit(bitmap, pos + len, pos) < pos + len)
+		return -EBUSY;
+	bitmap_set(bitmap, pos, len);
+	return 0;
+}
+
+/*
+ * bitmap_find_free_region - find a contiguous aligned mem region
+ *	@bitmap: array of unsigned longs corresponding to the bitmap
+ *	@bits: number of bits in the bitmap
+ *	@order: region size (log base 2 of number of bits) to find
+ *
+ * Find a region of free (zero) bits in a @bitmap of @bits bits and
+ * allocate them (set them to one).  Only consider regions of length
+ * a power (@order) of two, aligned to that power of two, which
+ * makes the search algorithm much faster.
+ *
+ * Return: the bit offset in bitmap of the allocated region,
+ * or -errno on failure.
+ */
+static inline int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order)
+{
+	unsigned int pos, end;		/* scans bitmap by regions of size order */
+
+	for (pos = 0; (end = pos + BIT(order)) <= bits; pos = end) {
+		if (!bitmap_allocate_region(bitmap, pos, order))
+			return pos;
+	}
+	return -ENOMEM;
+}
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __LINUX_BITMAP_H */
lib/bitmap.c +0 -63

69 lines not on this page · raw message

Signature · 1 line
2.39.2