1) vCPU context switching and guest side task switching are not identical.guest task lifetime has nothing to do with this. It's completely independent
That is, when the vCPU is scheduled out, the guest task on the vCPU may not
of what you do here on the VCPU level.
run out its time slice yet, so the task will continue to run when the vCPUSure it may use the LBR, and the normal perf context switch
is
scheduled in by the host (lbr wasn't save by the guest task when the vCPU is
scheduled out in this case).
It is possible to have the vCPU which runs the guest task (in use of lbr)
scheduled
out, followed by a new host task being scheduled in on the pCPU to run.
It is not guaranteed that the new host task does not use the LBR feature on
the
pCPU.
will switch it and everything works fine.
It's like any other per-task LBR user.