* [PATCH] KVM: arm64: Convert kvm_mpidr_index() to bitmap_gather()
@ 2024-05-02 15:42 Marc Zyngier
2024-05-02 17:06 ` Oliver Upton
2024-05-03 13:35 ` Marc Zyngier
0 siblings, 2 replies; 3+ messages in thread
From: Marc Zyngier @ 2024-05-02 15:42 UTC (permalink / raw)
To: kvmarm, kvm, linux-arm-kernel
Cc: James Morse, Suzuki K Poulose, Oliver Upton, Zenghui Yu
Linux 6.9 has introduced new bitmap manipulation helpers, with
bitmap_gather() being of special interest, as it does exactly
what kvm_mpidr_index() is already doing.
Make the latter a wrapper around the former.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
arch/arm64/include/asm/kvm_host.h | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 23a117cb3e50..fe94e96dced8 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -221,20 +221,10 @@ struct kvm_mpidr_data {
static inline u16 kvm_mpidr_index(struct kvm_mpidr_data *data, u64 mpidr)
{
- unsigned long mask = data->mpidr_mask;
- u64 aff = mpidr & MPIDR_HWID_BITMASK;
- int nbits, bit, bit_idx = 0;
- u16 index = 0;
+ unsigned long index = 0, mask = data->mpidr_mask;
+ unsigned long aff = mpidr & MPIDR_HWID_BITMASK;
- /*
- * If this looks like RISC-V's BEXT or x86's PEXT
- * instructions, it isn't by accident.
- */
- nbits = fls(mask);
- for_each_set_bit(bit, &mask, nbits) {
- index |= (aff & BIT(bit)) >> (bit - bit_idx);
- bit_idx++;
- }
+ bitmap_gather(&index, &aff, &mask, fls(mask));
return index;
}
--
2.39.2
_______________________________________________
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] 3+ messages in thread
* Re: [PATCH] KVM: arm64: Convert kvm_mpidr_index() to bitmap_gather()
2024-05-02 15:42 [PATCH] KVM: arm64: Convert kvm_mpidr_index() to bitmap_gather() Marc Zyngier
@ 2024-05-02 17:06 ` Oliver Upton
2024-05-03 13:35 ` Marc Zyngier
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Upton @ 2024-05-02 17:06 UTC (permalink / raw)
To: Marc Zyngier
Cc: kvmarm, kvm, linux-arm-kernel, James Morse, Suzuki K Poulose,
Zenghui Yu
On Thu, May 02, 2024 at 04:42:47PM +0100, Marc Zyngier wrote:
> Linux 6.9 has introduced new bitmap manipulation helpers, with
> bitmap_gather() being of special interest, as it does exactly
> what kvm_mpidr_index() is already doing.
Ooo, that's a handy one!
> Make the latter a wrapper around the former.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
--
Thanks,
Oliver
_______________________________________________
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] 3+ messages in thread
* Re: [PATCH] KVM: arm64: Convert kvm_mpidr_index() to bitmap_gather()
2024-05-02 15:42 [PATCH] KVM: arm64: Convert kvm_mpidr_index() to bitmap_gather() Marc Zyngier
2024-05-02 17:06 ` Oliver Upton
@ 2024-05-03 13:35 ` Marc Zyngier
1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2024-05-03 13:35 UTC (permalink / raw)
To: kvmarm, kvm, linux-arm-kernel, Marc Zyngier
Cc: James Morse, Suzuki K Poulose, Oliver Upton, Zenghui Yu
On Thu, 02 May 2024 16:42:47 +0100, Marc Zyngier wrote:
> Linux 6.9 has introduced new bitmap manipulation helpers, with
> bitmap_gather() being of special interest, as it does exactly
> what kvm_mpidr_index() is already doing.
>
> Make the latter a wrapper around the former.
>
>
> [...]
Applied to next, thanks!
[1/1] KVM: arm64: Convert kvm_mpidr_index() to bitmap_gather()
commit: 838d992b84486311e6039170d28b79a7a0633f06
Cheers,
M.
--
Without deviation from the norm, progress is not possible.
_______________________________________________
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] 3+ messages in thread
end of thread, other threads:[~2024-05-03 13:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-02 15:42 [PATCH] KVM: arm64: Convert kvm_mpidr_index() to bitmap_gather() Marc Zyngier
2024-05-02 17:06 ` Oliver Upton
2024-05-03 13:35 ` Marc Zyngier
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).