From nobody Wed Dec 22 10:06:27 2021 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 BF3551906A89; Wed, 22 Dec 2021 10:06:34 +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 4JJprP3nTGz4Ygs; Wed, 22 Dec 2021 10:06:28 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D9D8B1B2D0; Wed, 22 Dec 2021 10:06:27 +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 1BMA6RZL092708; Wed, 22 Dec 2021 10:06:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BMA6Rok092707; Wed, 22 Dec 2021 10:06:27 GMT (envelope-from git) Date: Wed, 22 Dec 2021 10:06:27 GMT Message-Id: <202112221006.1BMA6Rok092707@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 9735d993c225 - stable/12 - Merge commit d989ffd10 from llvm git (by Dimitry Andric): 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: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9735d993c225faa0e1f96015a5b0edf9dc1c2c5b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640167591; 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=sBUHD5Ge8bj7tFYLaeu4fb7cNyVupZK1lyRzvs3N3jk=; b=IHyIpYHokdBhPSSY/uuR5dw7Qgk2j4zejQ026/nA1Wyt1Cjn6ekAo1XQPEdL86QirAv76v hNEo6sIOcAxe+kvWjX2lwD5BgeEOIkk9pQwUIofp+iLphNE+gfwv1QZ8uFoVEvYNcWW1hx hsn9Bgw0IcLYLwc4F2MydbIi7IGjzBZPw2p/yqHwv9B5iwO1qxkmMPzM6opDfTGOIadC5B +KBZTl+Pmwml/2vvd/lp7uyrwbUSJvvNGUSbvUeh7XERt+QZxOBaUa7YJ579SvCgByN+1K Nxfa6NzCvW8wFAnMXbtkZi+e+9Opi/rcDdWxuLelf+xcH7WeC954Fdyq+heOBA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640167591; a=rsa-sha256; cv=none; b=wfnfG9aVCryZZuMo4JmPNWge6Kctf+SEjeClVlkYo+FIWTZnUOWdBfBi7mGjuzeHbc6LQK clQ41KAyiL3EH0MRi0PVbejWcvb0dB+igb29TzC8hWCKsapMLkcAkFanImMPujLI4LQka0 h14WYMKMcZsWYEmy3hmFCWrBbRkV/W1a3hyr1PYEA5JLVLP2+kzFFyBY8n7nvXi0AOSZlU EYZ8xWtUz4R1bH1NSx7BHHRNkryKhnTzX1E7yPA12NDbehiL0e5lxf65ABNnsB4jDuwZvB LuroiWosLwc5ZJI2ycj7LSoMwMPVxVEsuBHK9qKJiRy8dbZePEmTq3SZN5vqxg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=9735d993c225faa0e1f96015a5b0edf9dc1c2c5b commit 9735d993c225faa0e1f96015a5b0edf9dc1c2c5b Author: Dimitry Andric AuthorDate: 2020-12-03 19:29:18 +0000 Commit: Dimitry Andric CommitDate: 2021-12-22 10:01:24 +0000 Merge commit d989ffd10 from llvm git (by Dimitry Andric): Implement computeHostNumHardwareThreads() for FreeBSD This retrieves CPU affinity via FreeBSD's cpuset(2) API, and makes LLVM respect affinity settings configured by the user via the cpuset(1) command. In particular, this allows to reduce the number of threads used on machines with high core counts, which can interact badly with parallelized build systems. This is particularly noticable with lld, which spawns lots of threads even for linking e.g. hello_world! This fix is related to PR48193, but does not adress the more fundamental problem, which is that LLVM by default grabs as many CPUs and/or threads as possible. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D92271 Originally by: mjg MFC after: 1 week (cherry picked from commit c3f7be36e8ad24c31a3c56851681803704a4b0b2) --- contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc b/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc index 2d0aacabf092..667d023fc134 100644 --- a/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc +++ b/contrib/llvm-project/llvm/lib/Support/Unix/Threading.inc @@ -28,6 +28,7 @@ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include +#include #include #include #include @@ -282,7 +283,13 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) { #include int computeHostNumHardwareThreads() { -#ifdef __linux__ +#if defined(__FreeBSD__) + cpuset_t mask; + CPU_ZERO(&mask); + if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(mask), + &mask) == 0) + return CPU_COUNT(&mask); +#elif defined(__linux__) cpu_set_t Set; if (sched_getaffinity(0, sizeof(Set), &Set) == 0) return CPU_COUNT(&Set);