Re: [PATCH v1 4/4] KVM/vmx: enable lbr for the guest

From: Wei Wang
Date: Tue Sep 26 2017 - 21:24:43 EST


On 09/27/2017 12:41 AM, Andi Kleen wrote:
1) vCPU context switching and guest side task switching are not identical.
That is, when the vCPU is scheduled out, the guest task on the vCPU may not
guest task lifetime has nothing to do with this. It's completely independent
of what you do here on the VCPU level.

run out its time slice yet, so the task will continue to run when the vCPU
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.
Sure it may use the LBR, and the normal perf context switch
will switch it and everything works fine.

It's like any other per-task LBR user.

OK, I see the point, thanks.

Why couldn't we save the LBR_SELECT via task switching too?


Best,
Wei