]> www.infradead.org Git - users/jedix/linux-maple.git/commit
perf/x86/intel: Use better start period for frequency mode
authorKan Liang <kan.liang@linux.intel.com>
Fri, 17 Jan 2025 15:19:13 +0000 (07:19 -0800)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Feb 2025 19:38:21 +0000 (20:38 +0100)
commita26b24b2e21f6222635a95426b9ef9eec63d69b1
treed77469a55767b0a1f4c39e1a30e88263443fbc8c
parent0d39844150546fa1415127c5fbae26db64070dd3
perf/x86/intel: Use better start period for frequency mode

Freqency mode is the current default mode of Linux perf. A period of 1 is
used as a starting period. The period is auto-adjusted on each tick or an
overflow, to meet the frequency target.

The start period of 1 is too low and may trigger some issues:

- Many HWs do not support period 1 well.
  https://lore.kernel.org/lkml/875xs2oh69.ffs@tglx/

- For an event that occurs frequently, period 1 is too far away from the
  real period. Lots of samples are generated at the beginning.
  The distribution of samples may not be even.

- A low starting period for frequently occurring events also challenges
  virtualization, which has a longer path to handle a PMI.

The limit_period value only checks the minimum acceptable value for HW.
It cannot be used to set the start period, because some events may
need a very low period. The limit_period cannot be set too high. It
doesn't help with the events that occur frequently.

It's hard to find a universal starting period for all events. The idea
implemented by this patch is to only give an estimate for the popular
HW and HW cache events. For the rest of the events, start from the lowest
possible recommended value.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250117151913.3043942-3-kan.liang@linux.intel.com
arch/x86/events/intel/core.c