Skip to contentSkip to conversation

lib/test_printf: Switch to bitmap_zalloc()

PATCH In review Andy Shevchenko 2 participants 5 messages Mar 4, 2019 – Mar 20, 2019 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/test_printf: Switch to bitmap_zalloc()

Switch to bitmap_zalloc() to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *.

---
 lib/test_printf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/test_printf.c +2 -2
index 659b6cc0d483..e8206d8d2d08 100644
@@ -481,14 +481,14 @@ static void __init
 large_bitmap(void)
 {
 	const int nbits = 1 << 16;
-	unsigned long *bits = kcalloc(BITS_TO_LONGS(nbits), sizeof(long), GFP_KERNEL);
+	unsigned long *bits = bitmap_zalloc(nbits, GFP_KERNEL);
 	if (!bits)
 		return;
 
 	bitmap_set(bits, 1, 20);
 	bitmap_set(bits, 60000, 15);
 	test("1-20,60000-60014", "%*pbl", nbits, bits);
-	kfree(bits);
+	bitmap_free(bits);
 }
 
 static void __init
Signature · 1 line
2.20.1
#1 lore raw

+Cc: Petr

Quoted 32 lines · Andy Shevchenko

Switch to bitmap_zalloc() to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *.

---
 lib/test_printf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/test_printf.c +2 -2
index 659b6cc0d483..e8206d8d2d08 100644
@@ -481,14 +481,14 @@ static void __init
 large_bitmap(void)
 {
 	const int nbits = 1 << 16;
-	unsigned long *bits = kcalloc(BITS_TO_LONGS(nbits), sizeof(long), GFP_KERNEL);
+	unsigned long *bits = bitmap_zalloc(nbits, GFP_KERNEL);
 	if (!bits)
 		return;
 
 	bitmap_set(bits, 1, 20);
 	bitmap_set(bits, 60000, 15);
 	test("1-20,60000-60014", "%*pbl", nbits, bits);
-	kfree(bits);
+	bitmap_free(bits);
 }
 
 static void __init
Signature · 1 line
2.20.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by on v1 1/1
#2 lore raw
In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

Switch to bitmap_zalloc() to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *.

I have already sent pull request for 5.1. I could put it into printk.git, for-5.2 branch.

Andrew, feel free to take it, especially if you are still going to pull request for 5.1.

Best Regards,
Petr

#3 lore raw
Quoted 5 lines · Petr Mladek
Quoted 2 lines · Andy Shevchenko

Switch to bitmap_zalloc() to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *.

Thanks!

Quoted 2 lines

I have already sent pull request for 5.1. I could put it into printk.git, for-5.2 branch.

It's not in v5.1-rc1, so, feel free to proceed as usual thru your tree.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Petr Mladek
Quoted 2 lines · Andy Shevchenko

Switch to bitmap_zalloc() to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *.

Quoted 8 lines
Quoted 1 line

Thanks!

Quoted 2 lines

I have already sent pull request for 5.1. I could put it into printk.git, for-5.2 branch.

It's not in v5.1-rc1, so, feel free to proceed as usual thru your tree.

I have commited the patch into printk.git, branch for-5.2.

Best Regards,
Petr