Date: Tue, 14 Feb 2023 04:18:21 +0100 From: Mateusz Guzik <mjguzik@gmail.com> To: Jan Beich <jbeich@freebsd.org> Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 48bfd3597654 - main - Add nproc(1) Message-ID: <CAGudoHH=SoPrxk0p4A-heu7ckeKdVJ7viCMfzT=%2Bcg_1wJt7Nw@mail.gmail.com> In-Reply-To: <ttzp-3xme-wny@FreeBSD.org> References: <202302081947.318Jlbt6052826@gitrepo.freebsd.org> <20230208202736.L7hpB%steffen__28609.3347867549$1675888077$gmane$org@sdaoden.eu> <1qmt-6s1w-wny@FreeBSD.org> <CAGudoHForbPDR-vzXjKcDJTv=VTj-p=icbfZ2rogPy31r_jL4A@mail.gmail.com> <ttzp-3xme-wny@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2/14/23, Jan Beich <jbeich@freebsd.org> wrote: > Mateusz Guzik <mjguzik@gmail.com> writes: > >> On 2/14/23, Jan Beich <jbeich@freebsd.org> wrote: >> >>> Steffen Nurpmeso <steffen@sdaoden.eu> writes: >>> >>>> |+ if (all_flag) { >>>> |+ cpus = sysconf(_SC_NPROCESSORS_ONLN); >>>> >>>> is not compatible -- note i like the FreeBSD way better, and maybe >>>> someone should make a bug report even. >>>> >>>> #?0|kent:$ getconf -a|grep NPROC >>>> _NPROCESSORS_CONF 8 >>>> _NPROCESSORS_ONLN 4 >>> >>> See also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230330 >>> >>> $ cpuset -l 2-5 -- getconf -a | fgrep _NPROC >>> _NPROCESSORS_CONF: 8 >>> _NPROCESSORS_ONLN: 4 >>> >> >> As I mentioned previously in the thread, on linux these *don't* react >> to cpusets (or tasksets in linux parlance): >> >> $ getconf -a | grep _NPROC >> _NPROCESSORS_CONF 4 >> _NPROCESSORS_ONLN 4 >> $ taskset --cpu-list 0 getconf -a | grep _NPROC >> _NPROCESSORS_CONF 4 >> _NPROCESSORS_ONLN 4 >> >> consequently the patch proposed in the bz would introduce an >> incompatibility with linux > > I've used kern.smp.cpus in old patches but found musl more practical. > _SC_NPROCESSORS_ONLN is often used as a default number of jobs. > _SC_NPROCESSORS_ONLN is expected by real consumers to *not* be affected by cpuset et al. See below for musl. > glibc: > - /sys/devices/system/cpu/online > - /proc/stat Neither of these are affected by taskset/cpuset. > - sched_getaffinity where is this used? > > musl: > - sched_getaffinity > >From the commit I don't think the choice was thought out whatsoever. https://git.musl-libc.org/cgit/musl/commit/?id=9a7fac7934975338449b63eb4d0409b472251dfa the code went from returning -1 to glibc-incompatible taskset-affected count, and there are people complaining it breaks compat: https://marc.info/?l=musl&w=2&r=1&s=_SC_NPROCESSORS_ONLN&q=b > bionic: > - /sys/devices/system/cpu/online > - /proc/stat (Android < 7) > Neither of these are affected by taskset/cpuset. All in all, the *current* state is broadly linux+glibc-compatible. The one incompatibility concerns disabled HT, which on linux still reports those cpu threads, while they are completely absent from the count on freebsd. This is not taskset/cpuset-related. -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHH=SoPrxk0p4A-heu7ckeKdVJ7viCMfzT=%2Bcg_1wJt7Nw>