diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2023-08-08 14:12:01 -0700 |
---|---|---|
committer | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2023-08-08 15:16:40 -0700 |
commit | 01bcb56f059e1e9a56e1d121a0dc09df9e1714ff (patch) | |
tree | cbc3f1457e204db0a0562f8325c0f2c2686593f6 /tools/power | |
parent | e67b6ed2bbd1516f949202503207f44b3066bdec (diff) | |
download | linux-stable-01bcb56f059e1e9a56e1d121a0dc09df9e1714ff.tar.gz linux-stable-01bcb56f059e1e9a56e1d121a0dc09df9e1714ff.tar.bz2 linux-stable-01bcb56f059e1e9a56e1d121a0dc09df9e1714ff.zip |
tools/power/x86/intel-speed-select: Prevent CPU 0 offline
Kernel 6.5 version deprecated CPU 0 hotplug. This will cause all
requests to fail to offline CPU 0. Check version number of kernel
and ignore CPU 0 hotplug request with debug aid to use cgroup
isolation feature for CPU 0.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Diffstat (limited to 'tools/power')
-rw-r--r-- | tools/power/x86/intel-speed-select/isst-config.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c index b4864f3477da..bddc71f77308 100644 --- a/tools/power/x86/intel-speed-select/isst-config.c +++ b/tools/power/x86/intel-speed-select/isst-config.c @@ -5,6 +5,7 @@ */ #include <linux/isst_if.h> +#include <sys/utsname.h> #include "isst.h" @@ -473,11 +474,44 @@ static unsigned int is_cpu_online(int cpu) return online; } +static int get_kernel_version(int *major, int *minor) +{ + struct utsname buf; + int ret; + + ret = uname(&buf); + if (ret) + return ret; + + ret = sscanf(buf.release, "%d.%d", major, minor); + if (ret != 2) + return ret; + + return 0; +} + +#define CPU0_HOTPLUG_DEPRECATE_MAJOR_VER 6 +#define CPU0_HOTPLUG_DEPRECATE_MINOR_VER 5 + void set_cpu_online_offline(int cpu, int state) { char buffer[128]; int fd, ret; + if (!cpu) { + int major, minor; + + ret = get_kernel_version(&major, &minor); + if (!ret) { + if (major > CPU0_HOTPLUG_DEPRECATE_MAJOR_VER || (major == CPU0_HOTPLUG_DEPRECATE_MAJOR_VER && + minor >= CPU0_HOTPLUG_DEPRECATE_MINOR_VER)) { + debug_printf("Ignore CPU 0 offline/online for kernel version >= %d.%d\n", major, minor); + debug_printf("Use cgroups to isolate CPU 0\n"); + return; + } + } + } + snprintf(buffer, sizeof(buffer), "/sys/devices/system/cpu/cpu%d/online", cpu); |