* [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps
@ 2022-07-08 16:47 Christophe JAILLET
2022-07-08 16:47 ` [PATCH 2/2] RDMA/rtrs-clt: Use bitmap_empty() Christophe JAILLET
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Christophe JAILLET @ 2022-07-08 16:47 UTC (permalink / raw)
To: Md. Haris Iqbal, Jack Wang, Jason Gunthorpe, Leon Romanovsky
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-rdma
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>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 9809c3883979..06c27a3d83f5 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -1403,8 +1403,7 @@ static int alloc_permits(struct rtrs_clt_sess *clt)
unsigned int chunk_bits;
int err, i;
- clt->permits_map = kcalloc(BITS_TO_LONGS(clt->queue_depth),
- sizeof(long), GFP_KERNEL);
+ clt->permits_map = bitmap_zalloc(clt->queue_depth, GFP_KERNEL);
if (!clt->permits_map) {
err = -ENOMEM;
goto out_err;
@@ -1426,7 +1425,7 @@ static int alloc_permits(struct rtrs_clt_sess *clt)
return 0;
err_map:
- kfree(clt->permits_map);
+ bitmap_free(clt->permits_map);
clt->permits_map = NULL;
out_err:
return err;
@@ -1440,7 +1439,7 @@ static void free_permits(struct rtrs_clt_sess *clt)
wait_event(clt->permits_wait,
find_first_bit(clt->permits_map, sz) >= sz);
}
- kfree(clt->permits_map);
+ bitmap_free(clt->permits_map);
clt->permits_map = NULL;
kfree(clt->permits);
clt->permits = NULL;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] RDMA/rtrs-clt: Use bitmap_empty()
2022-07-08 16:47 [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps Christophe JAILLET
@ 2022-07-08 16:47 ` Christophe JAILLET
2022-07-11 12:51 ` Jinpu Wang
2022-07-11 10:01 ` [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps Jinpu Wang
2022-07-18 9:04 ` Leon Romanovsky
2 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2022-07-08 16:47 UTC (permalink / raw)
To: Md. Haris Iqbal, Jack Wang, Jason Gunthorpe, Leon Romanovsky
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-rdma
Use bitmap_empty() instead of hand-writing them.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 06c27a3d83f5..8441f0965b56 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -1433,12 +1433,10 @@ static int alloc_permits(struct rtrs_clt_sess *clt)
static void free_permits(struct rtrs_clt_sess *clt)
{
- if (clt->permits_map) {
- size_t sz = clt->queue_depth;
-
+ if (clt->permits_map)
wait_event(clt->permits_wait,
- find_first_bit(clt->permits_map, sz) >= sz);
- }
+ bitmap_empty(clt->permits_map, clt->queue_depth));
+
bitmap_free(clt->permits_map);
clt->permits_map = NULL;
kfree(clt->permits);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps
2022-07-08 16:47 [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-08 16:47 ` [PATCH 2/2] RDMA/rtrs-clt: Use bitmap_empty() Christophe JAILLET
@ 2022-07-11 10:01 ` Jinpu Wang
2022-07-18 9:04 ` Leon Romanovsky
2 siblings, 0 replies; 5+ messages in thread
From: Jinpu Wang @ 2022-07-11 10:01 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Md. Haris Iqbal, Jason Gunthorpe, Leon Romanovsky, linux-kernel,
kernel-janitors, linux-rdma
On Fri, Jul 8, 2022 at 6:47 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> 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>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Thx!
> ---
> drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index 9809c3883979..06c27a3d83f5 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> @@ -1403,8 +1403,7 @@ static int alloc_permits(struct rtrs_clt_sess *clt)
> unsigned int chunk_bits;
> int err, i;
>
> - clt->permits_map = kcalloc(BITS_TO_LONGS(clt->queue_depth),
> - sizeof(long), GFP_KERNEL);
> + clt->permits_map = bitmap_zalloc(clt->queue_depth, GFP_KERNEL);
> if (!clt->permits_map) {
> err = -ENOMEM;
> goto out_err;
> @@ -1426,7 +1425,7 @@ static int alloc_permits(struct rtrs_clt_sess *clt)
> return 0;
>
> err_map:
> - kfree(clt->permits_map);
> + bitmap_free(clt->permits_map);
> clt->permits_map = NULL;
> out_err:
> return err;
> @@ -1440,7 +1439,7 @@ static void free_permits(struct rtrs_clt_sess *clt)
> wait_event(clt->permits_wait,
> find_first_bit(clt->permits_map, sz) >= sz);
> }
> - kfree(clt->permits_map);
> + bitmap_free(clt->permits_map);
> clt->permits_map = NULL;
> kfree(clt->permits);
> clt->permits = NULL;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] RDMA/rtrs-clt: Use bitmap_empty()
2022-07-08 16:47 ` [PATCH 2/2] RDMA/rtrs-clt: Use bitmap_empty() Christophe JAILLET
@ 2022-07-11 12:51 ` Jinpu Wang
0 siblings, 0 replies; 5+ messages in thread
From: Jinpu Wang @ 2022-07-11 12:51 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Md. Haris Iqbal, Jason Gunthorpe, Leon Romanovsky, linux-kernel,
kernel-janitors, linux-rdma
On Fri, Jul 8, 2022 at 6:47 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Use bitmap_empty() instead of hand-writing them.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Thx!
> ---
> drivers/infiniband/ulp/rtrs/rtrs-clt.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index 06c27a3d83f5..8441f0965b56 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> @@ -1433,12 +1433,10 @@ static int alloc_permits(struct rtrs_clt_sess *clt)
>
> static void free_permits(struct rtrs_clt_sess *clt)
> {
> - if (clt->permits_map) {
> - size_t sz = clt->queue_depth;
> -
> + if (clt->permits_map)
> wait_event(clt->permits_wait,
> - find_first_bit(clt->permits_map, sz) >= sz);
> - }
> + bitmap_empty(clt->permits_map, clt->queue_depth));
> +
> bitmap_free(clt->permits_map);
> clt->permits_map = NULL;
> kfree(clt->permits);
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps
2022-07-08 16:47 [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-08 16:47 ` [PATCH 2/2] RDMA/rtrs-clt: Use bitmap_empty() Christophe JAILLET
2022-07-11 10:01 ` [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps Jinpu Wang
@ 2022-07-18 9:04 ` Leon Romanovsky
2 siblings, 0 replies; 5+ messages in thread
From: Leon Romanovsky @ 2022-07-18 9:04 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Md. Haris Iqbal, Jack Wang, Jason Gunthorpe, linux-kernel,
kernel-janitors, linux-rdma
On Fri, Jul 08, 2022 at 06:47:27PM +0200, Christophe JAILLET wrote:
> 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>
> ---
> drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
Thanks, applied
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-18 9:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 16:47 [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-08 16:47 ` [PATCH 2/2] RDMA/rtrs-clt: Use bitmap_empty() Christophe JAILLET
2022-07-11 12:51 ` Jinpu Wang
2022-07-11 10:01 ` [PATCH 1/2] RDMA/rtrs-clt: Use the bitmap API to allocate bitmaps Jinpu Wang
2022-07-18 9:04 ` Leon Romanovsky
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.