Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Feb 2023 01:13:52 +0100
From:      Steffen Nurpmeso <steffen@sdaoden.eu>
To:        Mateusz Guzik <mjguzik@gmail.com>
Cc:        Mateusz Guzik <mjg@freebsd.org>, 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:  <20230210001352.DUAuj%steffen@sdaoden.eu>
In-Reply-To: <CAGudoHGUhRbn7tUgmrk4G0Bc0NhVHOdH82cyN77Rifpw9mExiA@mail.gmail.com>
References:  <202302081947.318Jlbt6052826@gitrepo.freebsd.org> <20230208202736.L7hpB%steffen@sdaoden.eu> <CAGudoHGUhRbn7tUgmrk4G0Bc0NhVHOdH82cyN77Rifpw9mExiA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Mateusz Guzik wrote in
 <CAGudoHGUhRbn7tUgmrk4G0Bc0NhVHOdH82cyN77Rifpw9mExiA@mail.gmail.com>:
 |On 2/8/23, Steffen Nurpmeso <steffen@sdaoden.eu> wrote:
 |> Mateusz Guzik wrote in
 |>  <202302081947.318Jlbt6052826@gitrepo.freebsd.org>:
 |>  ...
 |>|    Add nproc(1)
 ...
 |>|    It aims to be compatible with nproc as found in GNU coreutils.
 |>
 |> That, "however",
 |>
 |>   ...
 |>|+     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
 |>   #?0|kent:$ nproc
 |>   4
 |>   #?0|kent:$ nproc --all
 |>   8
 |>   #?0|kent:$
 |>
 |
 |Is this from disabling hyperthreading?

Yes (compilations ~30-40% slower when enabled; last i tried).
(Waiting for that tricky FINEIBT thing, maybe then again.  Not
that i really have an idea.)

 |I have a 40-way box, after doing it I see:
 |NPROCESSORS_CONF: 20
 |NPROCESSORS_ONLN: 20
 |_NPROCESSORS_CONF: 20
 |_NPROCESSORS_ONLN: 20
 |
 |iow it wont make a difference.

I only get that in boxes.  On bare metal i see the inactivated
ones.

By the way it was lscpu that requires /sys/ here, nproc works (i
said it does not for the cpuset --count commit).  And both
coreutils as well as busybox variants use sched_getaffinity,
indeed.

Ciao,

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20230210001352.DUAuj%steffen>