Skip to content

Special Files

  • /sys/devices/system/<name>

Many applications use /sys/devices/system/cpu/online to get the number of available CPUs. And it’s hard to change this behavior because it’s usually encoded inside glibc. Thus, if you want to “hide” certain CPUs from applications for some reason, you can write a kernel module that use set_cpu_active(cpu, false), and then use the following small patch. (Note that using set_cpu_online(cpu, false) will confuse CPU idle routine and panic.) ```diff diff –git a/drivers/base/cpu.c b/drivers/base/cpu.c — a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -220,7 +220,8 @@ static ssize_t show_cpus_attr(struct device *dev,

/* Keep in sync with cpu_subsys_attrs */ static struct cpu_attr cpu_attrs[] = { - _CPU_ATTR(online, &__cpu_online_mask), + _CPU_ATTR(online, &__cpu_active_mask), _CPU_ATTR(possible, &__cpu_possible_mask), _CPU_ATTR(present, &__cpu_present_mask), }; ```

Yizhou Shan
Created: Jul 26, 2019
Last Updated: Aug 03, 2019

Last update: August 4, 2019


Back to top