linux/arch/x86/events/intel
Namhyung Kim 27c68c216e perf/x86: Fix lockdep warning in for_each_sibling_event() on SPR
On SPR, the load latency event needs an auxiliary event in the same
group to work properly.  There's a check in intel_pmu_hw_config()
for this to iterate sibling events and find a mem-loads-aux event.

The for_each_sibling_event() has a lockdep assert to make sure if it
disabled hardirq or hold leader->ctx->mutex.  This works well if the
given event has a separate leader event since perf_try_init_event()
grabs the leader->ctx->mutex to protect the sibling list.  But it can
cause a problem when the event itself is a leader since the event is
not initialized yet and there's no ctx for the event.

Actually I got a lockdep warning when I run the below command on SPR,
but I guess it could be a NULL pointer dereference.

  $ perf record -d -e cpu/mem-loads/uP true

The code path to the warning is:

  sys_perf_event_open()
    perf_event_alloc()
      perf_init_event()
        perf_try_init_event()
          x86_pmu_event_init()
            hsw_hw_config()
              intel_pmu_hw_config()
                for_each_sibling_event()
                  lockdep_assert_event_ctx()

We don't need for_each_sibling_event() when it's a standalone event.
Let's return the error code directly.

Fixes: f3c0eba287 ("perf: Add a few assertions")
Reported-by: Greg Thelen <gthelen@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20230704181516.3293665-1-namhyung@kernel.org
2023-07-10 09:52:20 +02:00
..
bts.c perf/x86: Add compiler barrier after updating BTS 2021-09-17 15:08:38 +02:00
core.c perf/x86: Fix lockdep warning in for_each_sibling_event() on SPR 2023-07-10 09:52:20 +02:00
cstate.c perf/x86/cstate: Add Granite Rapids support 2023-03-21 14:43:08 +01:00
ds.c perf/x86/intel/ds: Flush PEBS DS when changing PEBS_DATA_CFG 2023-05-08 10:58:27 +02:00
knc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lbr.c perf/x86/lbr: Simplify the exposure check for the LBR_INFO registers 2022-12-27 12:52:07 +01:00
Makefile perf/x86/intel/uncore: Parse uncore discovery tables 2021-04-02 10:04:54 +02:00
p4.c perf/x86: Make struct p4_event_bind::cntr signed array 2022-11-19 00:56:15 +01:00
p6.c x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-15 01:15:52 +01:00
pt.c perf/x86/intel/pt: Fix sampling using single range output 2022-11-16 10:12:59 +01:00
pt.h perf/x86/intel/pt: Prevent redundant WRMSRs 2019-11-13 11:06:18 +01:00
uncore.c perf/x86/intel/uncore: Add Meteor Lake support 2023-02-11 12:39:03 +01:00
uncore.h perf/x86/intel/uncore: Add Meteor Lake support 2023-02-11 12:39:03 +01:00
uncore_discovery.c perf/x86/uncore: Don't WARN_ON_ONCE() for a broken discovery table 2023-01-21 00:06:13 +01:00
uncore_discovery.h perf/x86/uncore: Add a quirk for UPI on SPR 2023-01-21 00:06:13 +01:00
uncore_nhmex.c perf/x86/intel/uncore: Correct fixed counter index check for NHM 2018-05-31 12:36:28 +02:00
uncore_snb.c perf/x86/intel/uncore: Add Meteor Lake support 2023-02-11 12:39:03 +01:00
uncore_snbep.c perf/x86/uncore: Correct the number of CHAs on SPR 2023-05-24 22:19:41 +02:00