Online cpu numbers in /sys/devices/system/cpu/online and sched_getaffinity masks

my container has less cpus, i.e. processor entries in /proc/cpuinfo, also less entries in /sys/devices/system/cpu/ and because I’ve set limits.cpu to less, also all the various syscalls return less

# cat sysconf.c
#include <unistd.h>
#include <stdio.h>
#include <sys/sysinfo.h>

int main(int argc, char *argv[])
{

        printf ("sysconf(_SC_NPROCESSORS_CONF): %d\n", sysconf(_SC_NPROCESSORS_CONF));
        printf ("sysconf(_SC_NPROCESSORS_ONLN): %d\n", sysconf(_SC_NPROCESSORS_ONLN));
        printf ("get_nprocs_conf(): %d\n", get_nprocs_conf());
        printf ("get_nprocs(): %d\n", get_nprocs());
        return 0;
}
# ./sysconf
sysconf(_SC_NPROCESSORS_CONF): 8
sysconf(_SC_NPROCESSORS_ONLN): 8
get_nprocs_conf(): 8
get_nprocs(): 8

so if a legacy software wants to be smart and shuffle the thread/process affinities around itself, it will bomb like jvm8 does, as this is impossible situation on a physical machine or a full VM, to have a cpu core with an ID bigger than the total number of cores in the system.