perf/core: Optimize perf_adjust_freq_unthr_context()
authorNamhyung Kim <namhyung@kernel.org>
Wed, 7 Feb 2024 05:05:44 +0000 (21:05 -0800)
committerIngo Molnar <mingo@kernel.org>
Wed, 10 Apr 2024 04:13:57 +0000 (06:13 +0200)
commit0259bf63f71e2accfeca4a4e346ede8edcc86aab
tree9af8bdbc67f072d870c7df0de5df98d654f3696b
parent9794563d4d053b1b46a0cc91901f0a11d8678c19
perf/core: Optimize perf_adjust_freq_unthr_context()

It was unnecessarily disabling and enabling PMUs for each event.  It
should be done at PMU level.  Add pmu_ctx->nr_freq counter to check it
at each PMU.  As PMU context has separate active lists for pinned group
and flexible group, factor out a new function to do the job.

Another minor optimization is that it can skip PMUs w/ CAP_NO_INTERRUPT
even if it needs to unthrottle sampling events.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Mingwei Zhang <mizhang@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/20240207050545.2727923-1-namhyung@kernel.org
include/linux/perf_event.h
kernel/events/core.c