linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] s390/pci: Use the bitmap API to allocate bitmaps
@ 2022-07-09 16:11 Christophe JAILLET
  2022-07-14  5:22 ` Alexander Gordeev
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2022-07-09 16:11 UTC (permalink / raw)
  To: Niklas Schnelle, Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-s390

Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
I don't know why commit c506fff3d3a8 ("s390/pci: resize iomap") has turned
this bitmap from a statically defined bitmap to a runtime-allocated one.

Going back to a:
	static DECLARE_BITMAP(zpci_iomap_bitmap, ZPCI_IOMAP_ENTRIES);
would slightly simply code.
---
 arch/s390/pci/pci.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index bc980fd313d5..b965553de143 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -1059,8 +1059,7 @@ static int zpci_mem_init(void)
 	if (!zpci_iomap_start)
 		goto error_iomap;
 
-	zpci_iomap_bitmap = kcalloc(BITS_TO_LONGS(ZPCI_IOMAP_ENTRIES),
-				    sizeof(*zpci_iomap_bitmap), GFP_KERNEL);
+	zpci_iomap_bitmap = bitmap_zalloc(ZPCI_IOMAP_ENTRIES, GFP_KERNEL);
 	if (!zpci_iomap_bitmap)
 		goto error_iomap_bitmap;
 
@@ -1078,7 +1077,7 @@ static int zpci_mem_init(void)
 
 static void zpci_mem_exit(void)
 {
-	kfree(zpci_iomap_bitmap);
+	bitmap_free(zpci_iomap_bitmap);
 	kfree(zpci_iomap_start);
 	kmem_cache_destroy(zdev_fmb_cache);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] s390/pci: Use the bitmap API to allocate bitmaps
  2022-07-09 16:11 [PATCH] s390/pci: Use the bitmap API to allocate bitmaps Christophe JAILLET
@ 2022-07-14  5:22 ` Alexander Gordeev
  2022-07-19  5:52   ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Gordeev @ 2022-07-14  5:22 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Niklas Schnelle, Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, Sven Schnelle, linux-kernel,
	kernel-janitors, linux-s390

On Sat, Jul 09, 2022 at 06:11:28PM +0200, Christophe JAILLET wrote:
> I don't know why commit c506fff3d3a8 ("s390/pci: resize iomap") has turned
> this bitmap from a statically defined bitmap to a runtime-allocated one.

c506fff3d3a8 commit message:

    This reduces the size of the iomap from 256K to less than 4K
    (using the defconfig).

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] s390/pci: Use the bitmap API to allocate bitmaps
  2022-07-14  5:22 ` Alexander Gordeev
@ 2022-07-19  5:52   ` Christophe JAILLET
  0 siblings, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2022-07-19  5:52 UTC (permalink / raw)
  To: Alexander Gordeev
  Cc: Niklas Schnelle, Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Christian Borntraeger, Sven Schnelle, linux-kernel,
	kernel-janitors, linux-s390

Le 14/07/2022 à 07:22, Alexander Gordeev a écrit :
> On Sat, Jul 09, 2022 at 06:11:28PM +0200, Christophe JAILLET wrote:
>> I don't know why commit c506fff3d3a8 ("s390/pci: resize iomap") has turned
>> this bitmap from a statically defined bitmap to a runtime-allocated one.
> 
> c506fff3d3a8 commit message:
> 
>      This reduces the size of the iomap from 256K to less than 4K
>      (using the defconfig).
> 

Hi,

IIUC, going from ZPCI_IOMAP_MAX_ENTRIES to ZPCI_IOMAP_ENTRIES reduced 
the size, not going from DECLARE_BITMAP() to kcalloc().

CJ

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-19  5:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-09 16:11 [PATCH] s390/pci: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-14  5:22 ` Alexander Gordeev
2022-07-19  5:52   ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).