----- On Feb 25, 2022, at 1:15 PM, Jonathan Corbet corbet@xxxxxxx wrote: > Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx> writes: > >> Some effective upper bounds for the number of vcpu ids observable in a process: >> >> - sysconf(3) _SC_NPROCESSORS_CONF, >> - the number of threads which exist concurrently in the process, >> - the number of cpus in the cpu affinity mask applied by sched_setaffinity, >> except in corner-case situations such as cpu hotplug removing all cpus from >> the affinity set, >> - cgroup cpuset "partition" limits, >> >> Note that AFAIR non-partition cgroup cpusets allow a cgroup to "borrow" >> additional cores from the rest of the system if they are idle, therefore >> allowing the number of concurrent threads to go beyond the specified limit. >> >> AFAIR the sched affinity mask is tweaked independently of the cgroup cpuset. >> Those are two mechanisms both affecting the scheduler task placement. >> >> I would expect the user-space code to use some sensible upper bound as a >> hint about how many per-vcpu data structure elements to expect (and how many >> to pre-allocate), but have a "lazy initialization" fall-back in case the >> vcpu id goes up to the number of configured processors - 1. And I suspect >> that even the number of configured processors may change with CRIU. >> >> If the above explanation makes sense (please let me know if I am wrong >> or missed something), I suspect I should add it to the commit message. > > That helps, thanks. I do think that something like this belongs in the > changelog - or, even better, in the upcoming restartable-sequences > section in the userspace-api documentation :) Just to confirm, when you say "userspace-api documentation" do you refer to man pages ? I did a few attempts at upstreaming a rseq.2 man page in 2020, but I have been stuck waiting for feedback from Michael Kerrisk since then. So for the moment I'm maintaining a rseq.2 man page here: https://git.kernel.org/pub/scm/libs/librseq/librseq.git/tree/doc/man/rseq.2 I'd gladly accept some help to improve the documentation of rseq. Thanks, Mathieu > > Thanks, > > jon -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com