All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
@ 2022-07-04 19:10 ` Christophe JAILLET
  0 siblings, 0 replies; 9+ messages in thread
From: Christophe JAILLET @ 2022-07-04 19:10 UTC (permalink / raw)
  To: Marc Zyngier, James Morse, Alexandru Elisei, Suzuki K Poulose,
	Oliver Upton, Catalin Marinas, Will Deacon
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
	linux-arm-kernel, kvmarm

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/arm64/kvm/vmid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c
index d78ae63d7c15..f4612cdb60ff 100644
--- a/arch/arm64/kvm/vmid.c
+++ b/arch/arm64/kvm/vmid.c
@@ -47,7 +47,7 @@ static void flush_context(void)
 	int cpu;
 	u64 vmid;
 
-	bitmap_clear(vmid_map, 0, NUM_USER_VMIDS);
+	bitmap_zero(vmid_map, NUM_USER_VMIDS);
 
 	for_each_possible_cpu(cpu) {
 		vmid = atomic64_xchg_relaxed(&per_cpu(active_vmids, cpu), 0);
@@ -182,8 +182,7 @@ int kvm_arm_vmid_alloc_init(void)
 	 */
 	WARN_ON(NUM_USER_VMIDS - 1 <= num_possible_cpus());
 	atomic64_set(&vmid_generation, VMID_FIRST_VERSION);
-	vmid_map = kcalloc(BITS_TO_LONGS(NUM_USER_VMIDS),
-			   sizeof(*vmid_map), GFP_KERNEL);
+	vmid_map = bitmap_zalloc(NUM_USER_VMIDS, GFP_KERNEL);
 	if (!vmid_map)
 		return -ENOMEM;
 
@@ -192,5 +191,5 @@ int kvm_arm_vmid_alloc_init(void)
 
 void kvm_arm_vmid_alloc_free(void)
 {
-	kfree(vmid_map);
+	bitmap_free(vmid_map);
 }
-- 
2.34.1


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

* [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
@ 2022-07-04 19:10 ` Christophe JAILLET
  0 siblings, 0 replies; 9+ messages in thread
From: Christophe JAILLET @ 2022-07-04 19:10 UTC (permalink / raw)
  To: Marc Zyngier, James Morse, Alexandru Elisei, Suzuki K Poulose,
	Oliver Upton, Catalin Marinas, Will Deacon
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET,
	linux-arm-kernel, kvmarm

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/arm64/kvm/vmid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c
index d78ae63d7c15..f4612cdb60ff 100644
--- a/arch/arm64/kvm/vmid.c
+++ b/arch/arm64/kvm/vmid.c
@@ -47,7 +47,7 @@ static void flush_context(void)
 	int cpu;
 	u64 vmid;
 
-	bitmap_clear(vmid_map, 0, NUM_USER_VMIDS);
+	bitmap_zero(vmid_map, NUM_USER_VMIDS);
 
 	for_each_possible_cpu(cpu) {
 		vmid = atomic64_xchg_relaxed(&per_cpu(active_vmids, cpu), 0);
@@ -182,8 +182,7 @@ int kvm_arm_vmid_alloc_init(void)
 	 */
 	WARN_ON(NUM_USER_VMIDS - 1 <= num_possible_cpus());
 	atomic64_set(&vmid_generation, VMID_FIRST_VERSION);
-	vmid_map = kcalloc(BITS_TO_LONGS(NUM_USER_VMIDS),
-			   sizeof(*vmid_map), GFP_KERNEL);
+	vmid_map = bitmap_zalloc(NUM_USER_VMIDS, GFP_KERNEL);
 	if (!vmid_map)
 		return -ENOMEM;
 
@@ -192,5 +191,5 @@ int kvm_arm_vmid_alloc_init(void)
 
 void kvm_arm_vmid_alloc_free(void)
 {
-	kfree(vmid_map);
+	bitmap_free(vmid_map);
 }
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
@ 2022-07-04 19:10 ` Christophe JAILLET
  0 siblings, 0 replies; 9+ messages in thread
From: Christophe JAILLET @ 2022-07-04 19:10 UTC (permalink / raw)
  To: Marc Zyngier, James Morse, Alexandru Elisei, Suzuki K Poulose,
	Oliver Upton, Catalin Marinas, Will Deacon
  Cc: Christophe JAILLET, kernel-janitors, linux-kernel,
	linux-arm-kernel, kvmarm

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/arm64/kvm/vmid.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c
index d78ae63d7c15..f4612cdb60ff 100644
--- a/arch/arm64/kvm/vmid.c
+++ b/arch/arm64/kvm/vmid.c
@@ -47,7 +47,7 @@ static void flush_context(void)
 	int cpu;
 	u64 vmid;
 
-	bitmap_clear(vmid_map, 0, NUM_USER_VMIDS);
+	bitmap_zero(vmid_map, NUM_USER_VMIDS);
 
 	for_each_possible_cpu(cpu) {
 		vmid = atomic64_xchg_relaxed(&per_cpu(active_vmids, cpu), 0);
@@ -182,8 +182,7 @@ int kvm_arm_vmid_alloc_init(void)
 	 */
 	WARN_ON(NUM_USER_VMIDS - 1 <= num_possible_cpus());
 	atomic64_set(&vmid_generation, VMID_FIRST_VERSION);
-	vmid_map = kcalloc(BITS_TO_LONGS(NUM_USER_VMIDS),
-			   sizeof(*vmid_map), GFP_KERNEL);
+	vmid_map = bitmap_zalloc(NUM_USER_VMIDS, GFP_KERNEL);
 	if (!vmid_map)
 		return -ENOMEM;
 
@@ -192,5 +191,5 @@ int kvm_arm_vmid_alloc_init(void)
 
 void kvm_arm_vmid_alloc_free(void)
 {
-	kfree(vmid_map);
+	bitmap_free(vmid_map);
 }
-- 
2.34.1

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Re: [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
  2022-07-04 19:10 ` Christophe JAILLET
  (?)
@ 2022-07-06  9:20   ` Vladimir Murzin
  -1 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2022-07-06  9:20 UTC (permalink / raw)
  To: Christophe JAILLET, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, Oliver Upton, Catalin Marinas, Will Deacon
  Cc: linux-kernel, kernel-janitors, linux-arm-kernel, kvmarm

On 7/4/22 20:10, Christophe JAILLET 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/arm64/kvm/vmid.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c
> index d78ae63d7c15..f4612cdb60ff 100644
> --- a/arch/arm64/kvm/vmid.c
> +++ b/arch/arm64/kvm/vmid.c
> @@ -47,7 +47,7 @@ static void flush_context(void)
>  	int cpu;
>  	u64 vmid;
>  
> -	bitmap_clear(vmid_map, 0, NUM_USER_VMIDS);
> +	bitmap_zero(vmid_map, NUM_USER_VMIDS);
>  
>  	for_each_possible_cpu(cpu) {
>  		vmid = atomic64_xchg_relaxed(&per_cpu(active_vmids, cpu), 0);
> @@ -182,8 +182,7 @@ int kvm_arm_vmid_alloc_init(void)
>  	 */
>  	WARN_ON(NUM_USER_VMIDS - 1 <= num_possible_cpus());
>  	atomic64_set(&vmid_generation, VMID_FIRST_VERSION);
> -	vmid_map = kcalloc(BITS_TO_LONGS(NUM_USER_VMIDS),
> -			   sizeof(*vmid_map), GFP_KERNEL);
> +	vmid_map = bitmap_zalloc(NUM_USER_VMIDS, GFP_KERNEL);
>  	if (!vmid_map)
>  		return -ENOMEM;
>  
> @@ -192,5 +191,5 @@ int kvm_arm_vmid_alloc_init(void)
>  
>  void kvm_arm_vmid_alloc_free(void)
>  {
> -	kfree(vmid_map);
> +	bitmap_free(vmid_map);
>  }

FWIW

Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>

Cheers
Vladimir

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

* Re: [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
@ 2022-07-06  9:20   ` Vladimir Murzin
  0 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2022-07-06  9:20 UTC (permalink / raw)
  To: Christophe JAILLET, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, Oliver Upton, Catalin Marinas, Will Deacon
  Cc: kernel-janitors, linux-kernel, linux-arm-kernel, kvmarm

On 7/4/22 20:10, Christophe JAILLET 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/arm64/kvm/vmid.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c
> index d78ae63d7c15..f4612cdb60ff 100644
> --- a/arch/arm64/kvm/vmid.c
> +++ b/arch/arm64/kvm/vmid.c
> @@ -47,7 +47,7 @@ static void flush_context(void)
>  	int cpu;
>  	u64 vmid;
>  
> -	bitmap_clear(vmid_map, 0, NUM_USER_VMIDS);
> +	bitmap_zero(vmid_map, NUM_USER_VMIDS);
>  
>  	for_each_possible_cpu(cpu) {
>  		vmid = atomic64_xchg_relaxed(&per_cpu(active_vmids, cpu), 0);
> @@ -182,8 +182,7 @@ int kvm_arm_vmid_alloc_init(void)
>  	 */
>  	WARN_ON(NUM_USER_VMIDS - 1 <= num_possible_cpus());
>  	atomic64_set(&vmid_generation, VMID_FIRST_VERSION);
> -	vmid_map = kcalloc(BITS_TO_LONGS(NUM_USER_VMIDS),
> -			   sizeof(*vmid_map), GFP_KERNEL);
> +	vmid_map = bitmap_zalloc(NUM_USER_VMIDS, GFP_KERNEL);
>  	if (!vmid_map)
>  		return -ENOMEM;
>  
> @@ -192,5 +191,5 @@ int kvm_arm_vmid_alloc_init(void)
>  
>  void kvm_arm_vmid_alloc_free(void)
>  {
> -	kfree(vmid_map);
> +	bitmap_free(vmid_map);
>  }

FWIW

Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>

Cheers
Vladimir
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Re: [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
@ 2022-07-06  9:20   ` Vladimir Murzin
  0 siblings, 0 replies; 9+ messages in thread
From: Vladimir Murzin @ 2022-07-06  9:20 UTC (permalink / raw)
  To: Christophe JAILLET, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, Oliver Upton, Catalin Marinas, Will Deacon
  Cc: linux-kernel, kernel-janitors, linux-arm-kernel, kvmarm

On 7/4/22 20:10, Christophe JAILLET 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/arm64/kvm/vmid.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/kvm/vmid.c b/arch/arm64/kvm/vmid.c
> index d78ae63d7c15..f4612cdb60ff 100644
> --- a/arch/arm64/kvm/vmid.c
> +++ b/arch/arm64/kvm/vmid.c
> @@ -47,7 +47,7 @@ static void flush_context(void)
>  	int cpu;
>  	u64 vmid;
>  
> -	bitmap_clear(vmid_map, 0, NUM_USER_VMIDS);
> +	bitmap_zero(vmid_map, NUM_USER_VMIDS);
>  
>  	for_each_possible_cpu(cpu) {
>  		vmid = atomic64_xchg_relaxed(&per_cpu(active_vmids, cpu), 0);
> @@ -182,8 +182,7 @@ int kvm_arm_vmid_alloc_init(void)
>  	 */
>  	WARN_ON(NUM_USER_VMIDS - 1 <= num_possible_cpus());
>  	atomic64_set(&vmid_generation, VMID_FIRST_VERSION);
> -	vmid_map = kcalloc(BITS_TO_LONGS(NUM_USER_VMIDS),
> -			   sizeof(*vmid_map), GFP_KERNEL);
> +	vmid_map = bitmap_zalloc(NUM_USER_VMIDS, GFP_KERNEL);
>  	if (!vmid_map)
>  		return -ENOMEM;
>  
> @@ -192,5 +191,5 @@ int kvm_arm_vmid_alloc_init(void)
>  
>  void kvm_arm_vmid_alloc_free(void)
>  {
> -	kfree(vmid_map);
> +	bitmap_free(vmid_map);
>  }

FWIW

Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>

Cheers
Vladimir

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
  2022-07-04 19:10 ` Christophe JAILLET
  (?)
@ 2022-07-08 18:59   ` oliver.upton
  -1 siblings, 0 replies; 9+ messages in thread
From: oliver.upton @ 2022-07-08 18:59 UTC (permalink / raw)
  To: Christophe JAILLET, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, Catalin Marinas, Will Deacon
  Cc: linux-kernel, kernel-janitors, linux-arm-kernel, kvmarm

July 4, 2022 12:10 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.
> 
> 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>

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>

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

* Re: [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
@ 2022-07-08 18:59   ` oliver.upton
  0 siblings, 0 replies; 9+ messages in thread
From: oliver.upton @ 2022-07-08 18:59 UTC (permalink / raw)
  To: Christophe JAILLET, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, Catalin Marinas, Will Deacon
  Cc: linux-kernel, kernel-janitors, linux-arm-kernel, kvmarm

July 4, 2022 12:10 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.
> 
> 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>

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
@ 2022-07-08 18:59   ` oliver.upton
  0 siblings, 0 replies; 9+ messages in thread
From: oliver.upton @ 2022-07-08 18:59 UTC (permalink / raw)
  To: Christophe JAILLET, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, Catalin Marinas, Will Deacon
  Cc: kernel-janitors, linux-kernel, linux-arm-kernel, kvmarm

July 4, 2022 12:10 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.
> 
> 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>

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

end of thread, other threads:[~2022-07-11  9:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-04 19:10 [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-04 19:10 ` Christophe JAILLET
2022-07-04 19:10 ` Christophe JAILLET
2022-07-06  9:20 ` Vladimir Murzin
2022-07-06  9:20   ` Vladimir Murzin
2022-07-06  9:20   ` Vladimir Murzin
2022-07-08 18:59 ` oliver.upton
2022-07-08 18:59   ` oliver.upton
2022-07-08 18:59   ` oliver.upton

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.