In _kvm_check_vmid(), you already have
+ if (migrated || (ver != old)) {
+ _kvm_update_vpid(vcpu, cpu);
+ trace_kvm_vpid_change(vcpu, vcpu->arch.vpid[cpu]);
+ }
so a vpid will never be recycled if a vCPU migrates from physical CPU A to B and back to A.
So please keep the current VPID in the per-cpu struct vmcs, and you can just copy it from there in _kvm_check_vmid().
Thanks, that is to say we should remove the vpid[NR_CPUS] array and it is enough to use only one vpid variable?