From nobody Wed Feb 18 09:41:08 2026 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 4fGBN94v3dz6RrfS for ; Wed, 18 Feb 2026 09:41: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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fGBN91sLcz3HK2 for ; Wed, 18 Feb 2026 09:41:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1771407673; 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=Tq5BN+agT5vEnoyu7e8eUVpqS8PISlL/a5MjuHCk+0A=; b=b0rZHTgEbK6k0rr8pQ5QSCh2EKr0YsuMG88BaMBGr1lCOYZe2MLA6e6WJchaqzxr8Mt9X0 5QZfUvvLvCyArk9QJg3HVwgYsafj2pL5pZAIUvpb74g7lI8Peb12Fm1Tg6wf1w28YUiuzN i+HPgMRTH2gJczttvP0rO8K7xqP7OPRKgx/goFH8Xpd09cTgmUerjLCqbciLewqsjDVRgd by5B66bEe7PAyDMSLaXU6iFWsSnmRbm3bw+swHTIycpfAwEEsCExdpGQK7iTiYLpUyMuH+ dIkanbcQvDKA8GrmIBNfSeT/cLMtRi6uTDW3LOsEIl58IG5d1VhXQR9C3n1U+A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1771407673; a=rsa-sha256; cv=none; b=UgNhiiOkBy3wb/M3BLWgPdv8cjrrryeRk1R+MCO7ADaaVDSBwzAH+hbbhs09UKW229g6Ca jt7QeL479ldyHCTK2CoJ56+kWh0CN/M7FkeCVTZyOKFXid19WDFAcJSKw4K9RcNXW2Wf55 nVRIAQlPSt+Hq6ZNeCeQK66AMBcnXTTVCg658WJXGTPpYqIdnsrSbQAuwNtNYHTIQTfhta jzP6x0MiJDUcuR1uuwP126Q+f9ESfenVvNABYw8UNAM5xE9r6kEl9qV5vZcEFRzZHH01YB JhvkEUYp1B9NkYeJZP9f52QY6y9YNDyKg9vLQM6fRWRcfhgQXdHa7dxla50Z3g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1771407673; 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=Tq5BN+agT5vEnoyu7e8eUVpqS8PISlL/a5MjuHCk+0A=; b=C+yUa/0owfluq3t8MkUIx6j8A+6TRk1dMg+sgLnkXRpQE1Z2qOH1VvOX6e7cAnbmor3FGc 84T+lTEBAGyaDcRu7bBO2gLzrHQWSSGomxhY9tw3p96oZ5OyQ3GDrKRj1bBsudEClbh8Wj FJ1Rgomy8mcjt1htsa2HbIACT72P1gp2aY87WOBFoMqsxceZqyZxV3lwoxgs9Dic0Gvtog +aMu+ce/RZAeYdWlUeR5PkaBStQ8KVIvZleVzjCac5Se2JdNnSmlpb8iAIHQZwRCophf34 UaqH5k3j/xUjt1oKWMSTMLtCTCpbj27REhLGMkE7IcmWZsr2PtLph0XY8Dt0xQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fGBN91SFLzqbr for ; Wed, 18 Feb 2026 09:41:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 21605 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 18 Feb 2026 09:41:08 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: e387d9438ba0 - main - smp: Use bitwise operation to count cpu number 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: aokblast X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e387d9438ba0258b88ebe03ef139bc6fd70b5a46 Auto-Submitted: auto-generated Date: Wed, 18 Feb 2026 09:41:08 +0000 Message-Id: <69958934.21605.2d0ec77a@gitrepo.freebsd.org> The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=e387d9438ba0258b88ebe03ef139bc6fd70b5a46 commit e387d9438ba0258b88ebe03ef139bc6fd70b5a46 Author: ShengYi Hung AuthorDate: 2026-01-03 16:32:50 +0000 Commit: ShengYi Hung CommitDate: 2026-02-18 09:40:54 +0000 smp: Use bitwise operation to count cpu number Previously, we iterated over all CPUs using CPU_FOREACH and checked individual bits to count valid CPUs. Refactor this to use a bitwise AND and popcount to count the number of enabled bits directly. Approved by: markj (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D54474 --- sys/kern/subr_smp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 2256ba648e4d..148b366e7435 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -588,7 +588,7 @@ smp_rendezvous_cpus(cpuset_t map, void (* teardown_func)(void *), void *arg) { - int curcpumap, i, ncpus = 0; + int curcpumap, ncpus = 0; /* See comments in the !SMP case. */ if (!smp_started) { @@ -609,10 +609,8 @@ smp_rendezvous_cpus(cpuset_t map, */ MPASS(curthread->td_md.md_spinlock_count == 0); - CPU_FOREACH(i) { - if (CPU_ISSET(i, &map)) - ncpus++; - } + CPU_AND(&map, &map, &all_cpus); + ncpus = CPU_COUNT(&map); if (ncpus == 0) panic("ncpus is 0 with non-zero map");