]> www.infradead.org Git - users/dwmw2/linux.git/commit
x86/sched: Add basic support for CPU capacity scaling
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 28 Aug 2024 11:47:25 +0000 (13:47 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 4 Sep 2024 11:36:40 +0000 (13:36 +0200)
commit5a9d10145a54f7a3fb6297c0082bf030e04db3bc
treebb0fd666a1af2310d8f9e08f08b812244a3c88d8
parentc4a6c82c9e834e40cba258e1f5e46cebb5cd1c24
x86/sched: Add basic support for CPU capacity scaling

In order be able to compute the sizes of tasks consistently across all
CPUs in a hybrid system, it is necessary to provide CPU capacity scaling
information to the scheduler via arch_scale_cpu_capacity().  Moreover,
the value returned by arch_scale_freq_capacity() for the given CPU must
correspond to the arch_scale_cpu_capacity() return value for it, or
utilization computations will be inaccurate.

Add support for it through per-CPU variables holding the capacity and
maximum-to-base frequency ratio (times SCHED_CAPACITY_SCALE) that will
be returned by arch_scale_cpu_capacity() and used by scale_freq_tick()
to compute arch_freq_scale for the current CPU, respectively.

In order to avoid adding measurable overhead for non-hybrid x86 systems,
which are the vast majority in the field, whether or not the new hybrid
CPU capacity scaling will be in effect is controlled by a static key.
This static key is set by calling arch_enable_hybrid_capacity_scale()
which also allocates memory for the per-CPU data and initializes it.
Next, arch_set_cpu_capacity() is used to set the per-CPU variables
mentioned above for each CPU and arch_rebuild_sched_domains() needs
to be called for the scheduler to realize that capacity-aware
scheduling can be used going forward.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Tested-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> # scale invariance
Link: https://patch.msgid.link/10523497.nUPlyArG6x@rjwysocki.net
[ rjw: Added parens to function kerneldoc comments ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
arch/x86/include/asm/topology.h
arch/x86/kernel/cpu/aperfmperf.c