Re: [RFC PATCH v6 05/35] KVM: arm64: Add KVM_CAP_ARM_SPE capability

Alexandru Elisei
2025-12-15T11:46:43Z

Hi Leo,

On Sun, Dec 14, 2025 at 08:18:42PM +0800, Leo Yan wrote:
> On Fri, Nov 14, 2025 at 04:06:46PM +0000, Alexandru Elisei wrote:
>
> [...]
>
> > +void kvm_host_spe_init(struct arm_spe_pmu *arm_spu)
> > +{
> > + struct arm_spu_entry *entry;
> > +
> > + guard(mutex)(&arm_spus_lock);
> > +
> > + entry = kmalloc(sizeof(*entry), GFP_KERNEL);
> > + if (!entry)
> > + return;
> > +
> > + entry->arm_spu = arm_spu;
> > + list_add_tail(&entry->link, &arm_spus);
> > +
> > + if (list_is_singular(&arm_spus))
> > + static_branch_enable(&kvm_spe_available);
>
> We can simply check if list_empty(&arm_spus) in kvm_supports_spe(), thus
> the static key kvm_spe_available is not needed. Another benefit is this
> is consistent with CPU PMU's virt implementation.

Sure, that makes sense. I think I added a static key because I was thinking
about performance on hot paths, but looking at the series I forgot to actually
make use of it.

Thanks,
Alex