Skip to content

Commit 2665784

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
perf/core: Verify we have a single perf_hw_context PMU
There should (and can) only be a single PMU for perf_hw_context events. This is because of how we schedule events: once a hardware event fails to schedule (the PMU is 'full') we stop trying to add more. The trivial 'fix' would break the Round-Robin scheduling we do. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 07dc900 commit 2665784

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

kernel/events/core.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7693,6 +7693,15 @@ int perf_pmu_register(struct pmu *pmu, const char *name, int type)
76937693
}
76947694

76957695
skip_type:
7696+
if (pmu->task_ctx_nr == perf_hw_context) {
7697+
static int hw_context_taken = 0;
7698+
7699+
if (WARN_ON_ONCE(hw_context_taken))
7700+
pmu->task_ctx_nr = perf_invalid_context;
7701+
7702+
hw_context_taken = 1;
7703+
}
7704+
76967705
pmu->pmu_cpu_context = find_pmu_context(pmu->task_ctx_nr);
76977706
if (pmu->pmu_cpu_context)
76987707
goto got_cpu_context;

0 commit comments

Comments
 (0)