Commit 6cedcf0d authored by Dapeng Mi's avatar Dapeng Mi Committed by Yunying Sun
Browse files

perf/x86/intel: Correct incorrect 'or' operation for PMU capabilities

mainline inclusion
from mainline-v6.7-rc3
commit e8df9d9f4209c04161321d8c12640ae560f65939
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/IAGLFT
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e8df9d9f4209c04161321d8c12640ae560f65939



-------------------------------------

When running perf-stat command on Intel hybrid platform, perf-stat
reports the following errors:

  sudo taskset -c 7 ./perf stat -vvvv -e cpu_atom/instructions/ sleep 1

  Opening: cpu/cycles/:HG
  ------------------------------------------------------------
  perf_event_attr:
    type                             0 (PERF_TYPE_HARDWARE)
    config                           0xa00000000
    disabled                         1
  ------------------------------------------------------------
  sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8
  sys_perf_event_open failed, error -16

   Performance counter stats for 'sleep 1':

       <not counted>      cpu_atom/instructions/

It looks the cpu_atom/instructions/ event can't be enabled on atom PMU
even when the process is pinned on atom core. Investigation shows that
exclusive_event_init() helper always returns -EBUSY error in the perf
event creation. That's strange since the atom PMU should not be an
exclusive PMU.

Further investigation shows the issue was introduced by commit:

  97588df87b56 ("perf/x86/intel: Add common intel_pmu_init_hybrid()")

The commit originally intents to clear the bit PERF_PMU_CAP_AUX_OUTPUT
from PMU capabilities if intel_cap.pebs_output_pt_available is not set,
but it incorrectly uses 'or' operation and leads to all PMU capabilities
bits are set to 1 except bit PERF_PMU_CAP_AUX_OUTPUT.

Testing this fix on Intel hybrid platforms, the observed issues
disappear.

Intel-SIG: commit e8df9d9f4209 perf/x86/intel: Correct incorrect 'or' operation for PMU capabilities
Backport following hybrid pmu bugfixes for commit 97588df87b56

Fixes: 97588df87b56 ("perf/x86/intel: Add common intel_pmu_init_hybrid()")
Signed-off-by: default avatarDapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20231121014628.729989-1-dapeng1.mi@linux.intel.com


Signed-off-by: default avatarYunying Sun <yunying.sun@intel.com>
parent fc18a9b2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4731,7 +4731,7 @@ static void intel_pmu_check_hybrid_pmus(struct x86_hybrid_pmu *pmu)
	if (pmu->intel_cap.pebs_output_pt_available)
		pmu->pmu.capabilities |= PERF_PMU_CAP_AUX_OUTPUT;
	else
		pmu->pmu.capabilities |= ~PERF_PMU_CAP_AUX_OUTPUT;
		pmu->pmu.capabilities &= ~PERF_PMU_CAP_AUX_OUTPUT;

	intel_pmu_check_event_constraints(pmu->event_constraints,
					  pmu->num_counters,