From nobody Wed Feb 15 20:44:12 2023 X-Original-To: dev-commits-src-main@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 4PH96P0ywbz3rKCW; Wed, 15 Feb 2023 20:44:13 +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 4PH96P0Sywz3GkR; Wed, 15 Feb 2023 20:44:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676493853; 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=9vny/ySr7G3LJXKzURhLbB7R8lez6wZ3qKv5i49ddkU=; b=sOpNAYnhTdr0SZXq64EkvU1TCGSGmo33UbqL6wF+g4IuoeH+TYxzwfWvTgcAXyu0ja/HIl YTbfsmKLouPfjdZ4sDQCrQtRwyK60Wee1u0xOBQevKoM4VXsx+ar6XCBWU/sIsZbQuD9FB pE2/O2Y6jnzZSx7yFHYYHSj/r4BRSq07MsWexxKVZ89G/YZF8gfhe4Pbje8mvqwxH9EHab zwnUF6mX5sw6VS20El/OUeL57dH/hygFx8mcwp18XlDEQEs76oQpbQZlN5GCaalEFuY+sl 3L3FuGK2m29L0v5MhqFBfSt+7adn9VadLslbQN4MyqqDtmOM8clBvTDgBhDkJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676493853; 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=9vny/ySr7G3LJXKzURhLbB7R8lez6wZ3qKv5i49ddkU=; b=pq59MOcBnhB/qSmX430Iwn2CkqhTYJDGZ46sLyOoG/9KTU5Jt9A/y+im+/Hnbi6nt344nY YsVAsPHoDHEnK9TdqICi39wZfEqEm45CdstJnfijleED+FO0fsFoisVfR2d2/kgqydwOUg dRsOLDHg5Amk7bkudDPbVD/Dn7a+Bi3cJdVV7DLQrS1jFpic+hDzPuNMHl2RSyWwc53c2K uJo05oCqxvs1/UT39kDSFJt7I1OCu7YNR3SkWdIPxo8ncws0RpKXSCsjpkDPHdy2rG4Wgo 5DySa+c4E8RzlhZogZ4K5EPSE34/bX4a28MIhSa1hFo3pdEgBjogh3KmzpOI3w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676493853; a=rsa-sha256; cv=none; b=Wvx/lu5i4n3Acr5AkOM/pby66NXcKm7J09RNtmt6LpYlCn7GDTx9NtIdZ6MjeX8EBqxM0Q X0U3Ld6BbeJawaNRPOq2OqwZwFAlUEl3s4qiS8pi2nUU7gXqQG2Ey/SbcsnUCnoAQOVHRb 0jFVyEyjNuak22qQ4qN5t4x60feMaNAtHc7SK1cco2kcXZMXhR6aJGa+x1dATU7JxufccX 44sVeyU72OC/I9wPMgvsWXakxvLLJSKy/O2hkJlNmEIFAyxMQWTFBq3+5xIU5k87EPVljN glLpiMEvZSS8EevXwbN1Gt2CHpSIAr6E9ULUg7odxBB8O2EG5L8Dpu2yAVaSaw== 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 4PH96N6dqnzdYt; Wed, 15 Feb 2023 20:44:12 +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 31FKiCbs047983; Wed, 15 Feb 2023 20:44:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31FKiCCa047982; Wed, 15 Feb 2023 20:44:12 GMT (envelope-from git) Date: Wed, 15 Feb 2023 20:44:12 GMT Message-Id: <202302152044.31FKiCCa047982@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 059320b8c8de - main - nproc: denote an incompatiblity with Linux List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 059320b8c8de73a90514879cd1e2da397584cfde Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=059320b8c8de73a90514879cd1e2da397584cfde commit 059320b8c8de73a90514879cd1e2da397584cfde Author: Mateusz Guzik AuthorDate: 2023-02-15 20:17:27 +0000 Commit: Mateusz Guzik CommitDate: 2023-02-15 20:43:46 +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. --- 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 91a87b1ca048..8ebe94a21049 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 @@ -40,6 +40,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 {