On Mon, Jul 08, 2019 at 09:23:15AM +0800, Wei Wang wrote: > From: Like Xu <like.xu@xxxxxxxxx> > > This patch adds support to enable/disable the host side save/restore This patch should be disqualified on Changelog alone... Documentation/process/submitting-patches.rst:instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy > for the guest lbr stack on vCPU switching. To enable that, the host > creates a perf event for the vCPU, and the event attributes are set > to the user callstack mode lbr so that all the conditions are meet in > the host perf subsystem to save the lbr stack on task switching. > > The host side lbr perf event are created only for the purpose of saving > and restoring the lbr stack. There is no need to enable the lbr > functionality for this perf event, because the feature is essentially > used in the vCPU. So perf_event_create is invoked with need_counter=false > to get no counter assigned for the perf event. > > The vcpu_lbr field is added to cpuc, to indicate if the lbr perf event is > used by the vCPU only for context switching. When the perf subsystem > handles this event (e.g. lbr enable or read lbr stack on PMI) and finds > it's non-zero, it simply returns. *WHY* does the host need to save/restore? Why not make VMENTER/VMEXIT do this? Many of these patches don't explain why things are done; that's a problem.