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>
This commit is contained in:
parent
e67b6ed2bb
commit
01bcb56f05
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user