From: Vladimir Murzin <vladimir.murzin@arm.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Marc Zyngier <maz@kernel.org>, James Morse <james.morse@arm.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH] KVM: arm64: Use the bitmap API to allocate bitmaps
Date: Wed, 6 Jul 2022 10:20:05 +0100 [thread overview]
Message-ID: <33aafc05-daa1-50e0-00ab-dab97bb8a879@arm.com> (raw)
In-Reply-To: <a93d3e94be2003922c7e9652b57e96261cc47641.1656961792.git.christophe.jaillet@wanadoo.fr>
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
next prev parent reply other threads:[~2022-07-06 9:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 19:10 Christophe JAILLET
2022-07-06 9:20 ` Vladimir Murzin [this message]
2022-07-08 18:59 ` oliver.upton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=33aafc05-daa1-50e0-00ab-dab97bb8a879@arm.com \
--to=vladimir.murzin@arm.com \
--cc=alexandru.elisei@arm.com \
--cc=catalin.marinas@arm.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=james.morse@arm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®