platform/x86: Add support for Uncore frequency control
PATCH v2 1/2 platform/x86: Add support for Uncore frequency control
Some server users set limits on the uncore frequency using MSR 620H, while running latency sensitive workloads. Here uncore frequency controls RING/LLC(last-level cache) clocks.
But MSR control is not always possible from the user space, so this driver provides a sysfs interface to set max and min frequency limits. This MSR 620H is a die scoped in multi-die system or package scoped in non multi-die systems.
When this driver is loaded, a new directory is created under
/sys/devices/system/cpu.
For example on a two package Skylake server:
$cd /sys/devices/system/cpu/intel_uncore_frequency
$lspackage_00_die_00 package_01_die_00
$ls package_00_die_00max_freq_khz min_freq_khz initial_max_freq_khzinitial_min_freq_khz
$grep . *
max_freq_khz:2400000
min_freq_khz:1200000
initial_max_freq_khz:2400000
initial_min_freq_khz:1200000Here, initial_max_freq_khz and initial_min_freq_khz are read only attributes to show power up or initial values of max and min frequencies respectively. Other attributes are read-write, so that users can modify.
---
v2:
- Len Brown suggested to chnage "power_up" to "initial" in the name.
- Split the documentation patch to another patch to merge via different tree
drivers/platform/x86/Kconfig | 11 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/intel-uncore-frequency.c | 434 ++++++++++++++++++ 3 files changed, 446 insertions(+) create mode 100644 drivers/platform/x86/intel-uncore-frequency.c
drivers/platform/x86/Kconfig +11 -0
@@ -1337,6 +1337,17 @@ config PCENGINES_APU2 To compile this driver as a module, choose M here: the module will be called pcengines-apuv2. +config INTEL_UNCORE_FREQ_CONTROL + tristate "Intel Uncore frequency control driver" + depends on X86_64 + help + This driver allows control of uncore frequency limits on + supported server platforms. + Uncore frequency controls RING/LLC (last-level cache) clocks. + + To compile this driver as a module, choose M here: the module + will be called intel-uncore-frequency. + source "drivers/platform/x86/intel_speed_select_if/Kconfig" config SYSTEM76_ACPI
drivers/platform/x86/Makefile +1 -0
@@ -105,3 +105,4 @@ obj-$(CONFIG_INTEL_ATOMISP2_PM) += intel_atomisp2_pm.o obj-$(CONFIG_PCENGINES_APU2) += pcengines-apuv2.o obj-$(CONFIG_INTEL_SPEED_SELECT_INTERFACE) += intel_speed_select_if/ obj-$(CONFIG_SYSTEM76_ACPI) += system76_acpi.o +obj-$(CONFIG_INTEL_UNCORE_FREQ_CONTROL) += intel-uncore-frequency.o
drivers/platform/x86/intel-uncore-frequency.c new file +434 -0
434 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH v2 2/2 MAINTAINERS: Update for the intel uncore frequency control
Add an entry for drivers/platform/x86/intel-uncore-frequency.c.
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -8562,6 +8562,12 @@ S: Maintained F: arch/x86/include/asm/intel_telemetry.h F: drivers/platform/x86/intel_telemetry* +INTEL UNCORE FREQUENCY CONTROL +M: Srinivas Pandruvada <[email protected]> +L: [email protected] +S: Maintained +F: drivers/platform/x86/intel-uncore-frequency.c + INTEL VIRTUAL BUTTON DRIVER M: AceLan Kao <[email protected]> L: [email protected]
Signature · 1 line
2.24.1
Hi Srinivas,
Quoted 7 lines · Srinivas Pandruvada
drivers/platform/x86/intel-uncore-frequency.c new file +7
-0+ +/* Common function to set min/max ratios to be used by sysfs callbacks */ +static int uncore_write_ratio (struct uncore_data *data,unsigned int input, +int set_max) +{ +int ret; +u64 cap;
drivers/platform/x86/intel-uncore-frequency.c line 125
Quoted 10 lines
drivers/platform/x86/intel-uncore-frequency.c new file +10
-0+ +mutex_lock (&uncore_lock); + + input /=UNCORE_FREQ_KHZ_MULTIPLIER ; +if (!input || input >0x7F ) { + ret = -EINVAL ; + goto finish_write; + } + +rdmsrl (MSR_UNCORE_RATIO_LIMIT , cap);
Should it be rdmsrl_on_cpu()?
Thanks,
Chenyu
Hi Chenyu,
Thanks for the pointing.
Quoted 15 lines · Yu Chen
Hi Srinivas,
Quoted 12 lines · Srinivas Pandruvada
(quoted diff) +2
-0+ +/* Common function to set min/max ratios to be used by sysfscallbacks */
+static int uncore_write_ratio(structuncore_data*data, unsigned int input,drivers/platform/x86/intel-uncore-frequency.c new file +7
-0+ int set_max) +{ +int ret; +u64 cap; + +mutex_lock (&uncore_lock); +
Quoted 8 lines
drivers/platform/x86/intel-uncore-frequency.c line 125
Quoted 7 lines
drivers/platform/x86/intel-uncore-frequency.c new file +7
-0+ input /=UNCORE_FREQ_KHZ_MULTIPLIER ; +if (!input || input >0x7F ) { + ret = -EINVAL ; + goto finish_write; + } + +rdmsrl (MSR_UNCORE_RATIO_LIMIT , cap);Should it be
rdmsrl_on_cpu()?
Yes. Fixed and sent update.
Thanks,
Srinivas
Quoted 3 lines
Thanks,
Chenyu