Commit 01bcb56f authored by Srinivas Pandruvada's avatar Srinivas Pandruvada

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: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
parent e67b6ed2
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment