On Linux, go uses sched_getaffinity to know how many cpu core it is allowed to run on:
https://cs.opensource.google/go/go/+/master:src/runtime/os_l...
https://cs.opensource.google/go/go/+/master:src/runtime/os_l...
> On Linux, go uses sched_getaffinity …
Since cgroups are a Linux-only feature, OP must be running Linux. I wonder if his experience pre-dates Go’s usage of sched_getaffinity.
edit: I realised that he references cgroups so must be on Linux.
I may have misunderstood the rationale here, but I think the discussion about cgroup support is not about limiting the number of Ps
However, as far as I can tell, there's no clear way to figure out what M is, in the general case.