linux-csky.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] csky: Use the bitmap API to allocate bitmaps
@ 2022-07-04 19:06 Christophe JAILLET
  2022-07-04 23:47 ` Guo Ren
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2022-07-04 19:06 UTC (permalink / raw)
  To: Guo Ren; +Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-csky

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

It is less verbose and it improves the semantic.

While at it, turn a bitmap_clear() into an equivalent bitmap_zero(). It is
also less verbose.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 arch/csky/mm/asid.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/csky/mm/asid.c b/arch/csky/mm/asid.c
index b2e914745c1d..7fb6c417bbac 100644
--- a/arch/csky/mm/asid.c
+++ b/arch/csky/mm/asid.c
@@ -27,7 +27,7 @@ static void flush_context(struct asid_info *info)
 	u64 asid;
 
 	/* Update the list of reserved ASIDs and the ASID bitmap. */
-	bitmap_clear(info->map, 0, NUM_CTXT_ASIDS(info));
+	bitmap_zero(info->map, NUM_CTXT_ASIDS(info));
 
 	for_each_possible_cpu(i) {
 		asid = atomic64_xchg_relaxed(&active_asid(info, i), 0);
@@ -178,8 +178,7 @@ int asid_allocator_init(struct asid_info *info,
 	 */
 	WARN_ON(NUM_CTXT_ASIDS(info) - 1 <= num_possible_cpus());
 	atomic64_set(&info->generation, ASID_FIRST_VERSION(info));
-	info->map = kcalloc(BITS_TO_LONGS(NUM_CTXT_ASIDS(info)),
-			    sizeof(*info->map), GFP_KERNEL);
+	info->map = bitmap_zalloc(NUM_CTXT_ASIDS(info), GFP_KERNEL);
 	if (!info->map)
 		return -ENOMEM;
 
-- 
2.34.1


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

* Re: [PATCH] csky: Use the bitmap API to allocate bitmaps
  2022-07-04 19:06 [PATCH] csky: Use the bitmap API to allocate bitmaps Christophe JAILLET
@ 2022-07-04 23:47 ` Guo Ren
  0 siblings, 0 replies; 2+ messages in thread
From: Guo Ren @ 2022-07-04 23:47 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: Linux Kernel Mailing List, kernel-janitors, linux-csky

Thx and looks good to me.

On Tue, Jul 5, 2022 at 3:08 AM 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.
>
> While at it, turn a bitmap_clear() into an equivalent bitmap_zero(). It is
> also less verbose.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  arch/csky/mm/asid.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/csky/mm/asid.c b/arch/csky/mm/asid.c
> index b2e914745c1d..7fb6c417bbac 100644
> --- a/arch/csky/mm/asid.c
> +++ b/arch/csky/mm/asid.c
> @@ -27,7 +27,7 @@ static void flush_context(struct asid_info *info)
>         u64 asid;
>
>         /* Update the list of reserved ASIDs and the ASID bitmap. */
> -       bitmap_clear(info->map, 0, NUM_CTXT_ASIDS(info));
> +       bitmap_zero(info->map, NUM_CTXT_ASIDS(info));
>
>         for_each_possible_cpu(i) {
>                 asid = atomic64_xchg_relaxed(&active_asid(info, i), 0);
> @@ -178,8 +178,7 @@ int asid_allocator_init(struct asid_info *info,
>          */
>         WARN_ON(NUM_CTXT_ASIDS(info) - 1 <= num_possible_cpus());
>         atomic64_set(&info->generation, ASID_FIRST_VERSION(info));
> -       info->map = kcalloc(BITS_TO_LONGS(NUM_CTXT_ASIDS(info)),
> -                           sizeof(*info->map), GFP_KERNEL);
> +       info->map = bitmap_zalloc(NUM_CTXT_ASIDS(info), GFP_KERNEL);
>         if (!info->map)
>                 return -ENOMEM;
>
> --
> 2.34.1
>


-- 
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/

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

end of thread, other threads:[~2022-07-04 23:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 19:06 [PATCH] csky: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-04 23:47 ` Guo Ren

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).