From nobody Thu Feb 23 17:07:00 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PMzw51hqtz3sDqq; Thu, 23 Feb 2023 17:07:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PMzw50zZLz3kLt; Thu, 23 Feb 2023 17:07:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677172021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0kQNCTBe4H7Z1Sk2YiHhN+oxBZhuzhxc0cICGzgcgxw=; b=HvUe7m7Nouu3ZqR+6HSX4IN3uA6AFr+HuhRT6x0M964ywI1jt/8IS3QSxR3wWGDsvrFWV5 36Zrbf6zOq8i4mAJwRRFCg5ge5bBVF6tz8tMDFZcBdBc18jC9L/OLFt5bphijTufi7/aoP 21fNdcbcyD1EzUfunoGo/r1xCpfezRsicLeFzgKc24n/i3k4ATdgZ6W8HLZzarBB4y54GO mNFOZ0vwgCVd3qL4/z1F41UuwJwvqHHePRBhtS73SqHiuPWvRkJbUzYhyJwKAjMniP6q7x 2wZ2iXk/qaON2bc+xNOn3CApHPths20pzaNXev5uRF8EBucjALWafu7qkNgikA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677172021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0kQNCTBe4H7Z1Sk2YiHhN+oxBZhuzhxc0cICGzgcgxw=; b=FjDSWD8xgm7NRVKwe6ju8XO/XPorLpfmTELbV/GUvo3e48rDJOdhEUBO+B5Rn+5CyctQyp qDzyExO7oXlmpuPAcx3xHDyGIWWmXH8kWEly/t45kSfEqfc47zk3yTXWNA2WAiReHB8/ZB vSenYP0FpiI3c/KUs9ltfirb/ex/zZDffnaeXWSIDy7WkCNox0qlnEnR3pBYTnAhFkQBg9 6g6iKW7nZiizna5lTyv1giB5x20s8JrMRxUYYFK6UnqRMmykWlep0dvepgz4/q8BikuX7F O+Hx/krgAqfjiDAzSrVg/GYUaxQ1+UgXPHC1fQx/3hszqJfYMdXCIG/CSksGhw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677172021; a=rsa-sha256; cv=none; b=n5c+lU7S7lTu3gV62LL+QdbShTMUJ+AUhJyza0lBl/qN0549gxi+eBfH+jJAAYSv4s9FYa OslIAFRWeydxN+1vn45zBwu6Xqtdvty3JrwzrDaADqvOdlhW57OZaft1q8vAlpGNpgj7ue wEzYTeMkAvdXOWCRq/O13jfD2aI82HyoR48q/u59DSn6Yf2tqTNtn8+y7+EQjHPlYVtdTV XhEQWf3Qrrc8kRicP2gApoaann1aCaKh25gUe6Ip0sn4t1JJJ1TgDJbzcv5VfoNva1RY4H wNfwvxttdvlZubiidUXhvItykNcvIpMXSkC+RZk1vn4iu3dDNSo0Y236QJF0Rg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PMzw474JrzqMc; Thu, 23 Feb 2023 17:07:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31NH70d0005417; Thu, 23 Feb 2023 17:07:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31NH70RH005416; Thu, 23 Feb 2023 17:07:00 GMT (envelope-from git) Date: Thu, 23 Feb 2023 17:07:00 GMT Message-Id: <202302231707.31NH70RH005416@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 117d4cafdcb8 - stable/13 - nproc: denote an incompatiblity with Linux List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 117d4cafdcb806407e38266de44aebe0b4e62b6f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=117d4cafdcb806407e38266de44aebe0b4e62b6f commit 117d4cafdcb806407e38266de44aebe0b4e62b6f Author: Mateusz Guzik AuthorDate: 2023-02-15 20:17:27 +0000 Commit: Mateusz Guzik CommitDate: 2023-02-23 17:06:41 +0000 nproc: denote an incompatiblity with Linux On Linux _NPROCESSORS_CONF reports CPU threads disabled by the kernel, while it does not on FreeBSD. Flip _NPROCESSORS_ONLN to _NPROCESSORS_CONF. While it keeps reporting the same value, it will automagically unbreak should someone change the above. (cherry picked from commit 059320b8c8de73a90514879cd1e2da397584cfde) --- bin/nproc/nproc.1 | 7 ++++++- bin/nproc/nproc.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/nproc/nproc.1 b/bin/nproc/nproc.1 index ae252fe0f50c..d4d97ccbb5be 100644 --- a/bin/nproc/nproc.1 +++ b/bin/nproc/nproc.1 @@ -3,7 +3,7 @@ .\" .\" * SPDX-License-Identifier: BSD-2-Clause .\" -.Dd February 5, 2023 +.Dd February 15, 2023 .Dt NPROC 1 .Os .Sh NAME @@ -39,6 +39,11 @@ Print usage information and exit. .El .Sh COMPATIBILITY This program is intended to be compatible with nproc as found in GNU coreutils. +.Sh BUGS +If HyperThreading is enabled in BIOS and disabled in the kernel, the +.Fl -all +option on Linux will still report all possible CPU threads. +On FreeBSD only active threads will be reported. .Sh SEE ALSO .Xr cpuset 1 .Sh HISTORY diff --git a/bin/nproc/nproc.c b/bin/nproc/nproc.c index 9037c74dbfff..c2ab75826ce1 100644 --- a/bin/nproc/nproc.c +++ b/bin/nproc/nproc.c @@ -110,7 +110,7 @@ main(int argc, char *argv[]) usage(); if (all_flag) { - cpus = sysconf(_SC_NPROCESSORS_ONLN); + cpus = sysconf(_SC_NPROCESSORS_CONF); if (cpus == -1) err(1, "sysconf"); } else {