On Mon, Mar 29, 2021 at 01:41:30PM +0800, Like Xu wrote: > @@ -3863,6 +3864,12 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) > arr[2].host = (unsigned long)ds; > arr[2].guest = pmu->ds_area; *nr = 3; > > + if (baseline) { > + arr[3].msr = MSR_PEBS_DATA_CFG; > + arr[3].host = cpuc->pebs_data_cfg; > + arr[3].guest = pmu->pebs_data_cfg; *nr = 4; > + } > + > /* > * If PMU counter has PEBS enabled it is not enough to > * disable counter on a guest entry since PEBS memory > @@ -3879,9 +3886,11 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) > else { > arr[1].guest = arr[1].host; > arr[2].guest = arr[2].host; > + if (baseline) > + arr[3].guest = arr[3].host; > } > > - *nr = 3; > + *nr = baseline ? 4 : 3; And you don't need yet another branch to determine a value you already know. > }