4

I have two boards with different ARM CPUs, one 2x core - running Linux kernel 4.1.x, the other 4x core - running 3.10. On those Linux installations I'm always logged in as root. From my program, I set the CPU affinity for the calling process, just like here, via sched_setaffinity(0, ... ), just that I always set it to cpu 1 only. On the Linux 4.1, it works as expected. The Linux 3.1 gives me a negative return value, and on perror(..): "Invalid argument".

Why would that be? A quad core surely has cpu 1?

4
  • EINVAL is returned if the affinity bit mask mask contains no processors that are currently physically on the system and permitted to the thread according to any restrictions that may be imposed by cpuset cgroups or the "cpuset" mechanism described in cpuset.
    – P.W
    Commented Dec 21, 2018 at 9:06
  • Oh, from what I read here, linux.die.net/man/7/cpuset, there should be a "nodev cpuset" in /proc/filesystems if it is supported - on the offending system it isn't. I.e. the board vendor chose to put together a Linux image for a quad core system that can't set CPU affinity? Why would anyone do that... So that means I'll have to build a custom Linux image, or can this be enabled somehow? (the board has some closed drivers, I can't just isntall any distro image)
    – sktpin
    Commented Dec 21, 2018 at 9:37
  • Now I'm really confused - the board where setting cpu affinity clearly works, also does not have the /proc/filesystems entry of "nodev cpuset" as described in the manpages.
    – sktpin
    Commented Dec 21, 2018 at 11:18
  • To add to the confusion: in the /proc/config.gz of both systems I find: "#CONFIG_CPUSETS is not set". Why does it work on the 4.1 system then? I get no error, and lots of CPU activity is clearly shoved to the other core.
    – sktpin
    Commented Dec 21, 2018 at 11:56

1 Answer 1

2

The other CPU cores were not enabled by default.

If they are enabled like described here (but writing 1 instead of 0), it works.

#echo 1 > /sys/devices/system/cpu/cpu1/online

Not the answer you're looking for? Browse other questions tagged or ask your own question.