From nobody Tue Jun 04 18:08:37 2024 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 4Vtz9d5sxLz5MM2j; Tue, 04 Jun 2024 18:08:37 +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 4Vtz9d5KYYz4P1h; Tue, 4 Jun 2024 18:08:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717524517; 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=24afK4efuJ+k2wFWX7FJBtmypjT8cIqN/Dbl8em61iA=; b=UeUxcscLV7yAs9pRbXPO+IIpdSlIHgdatG61QGlKG3pcAgxunLvPGlwQu4GvYMxKqG7/FW QEy+JhbXcn7B5QvlSd5vrs/iwDozO3EX/ulrFh29Ccs8yZz8nkpsogxszkRpbAJYIEDIU5 vrlBBCJukJHaeuneGGYq72gG37TiAhjSSKZNbgo2spdbH5EpOlcZL8RY4xgY8SjUuLITVB +bchpd7FSoDgolhfp88ePHIXm2T7SQYOQhpDeH1f8zC2r+ey8KB7OHd5nqz1Bti7PmIUQ9 KvdfB0Ta27RYAhZLfq3UhITkpudSqS91q97IHYanrQF7J7L960C+ca5NF1xLcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717524517; a=rsa-sha256; cv=none; b=N6uOjAgcKZiZZwe/26aSQx3u/CnyJf4yLB5tvXCLmhiulBV/PqWtH6gNmco23XyUykxkL0 8ni5mIvk6jSQmHYhT6ItDLoMURAA3LViT+k2VjsMJbA9aZnDqBgoBTnz9D6Kt5wM1Loqcq yQq5AkYBNklQ6BkB1SYbHjRrGYFL4kHh0jf4FNTdOoZBA72J2igLVtpBnfyxU6DjAjZdBI wzDHAFqsE05+9mVKmZFqjiSIRfpPLeJUXGK0rTHYvsDwfisIEwsK7VNjjxZiEN6o25Or34 j5iCt7zgS+PWTkZ29AWdjJlIxWeAQxf8p/k2V9hoNYZKGpdf9qtLjkmHd8O78w== 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=1717524517; 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=24afK4efuJ+k2wFWX7FJBtmypjT8cIqN/Dbl8em61iA=; b=C4xpdZouLmCea/gHvU5Y7nL3qR2prbPccOml9qw5jUnkzbpJXG1U1OEnoNSw6JkpFrXFIE mh4xU70DSUrWNLzr2GFHd1gCqTpTB6GxXkowjixcCxw/mgf5Tgk5WOL/TeJgr7FxIijQhB CPGFGm7SKtG6FsbQS25D/2rggZ88w13r0z1VW8mgefQvFH/gpovn7S60vYfrkrffAr2vPb fXyyh+Qz+w0HaM3D+ihleGjEamUmp43BMhMiYsF/V+L8r0SPALSM0LiUjz43pvfWnYpCSn JB8EKODMgxLEYnj9g8w5ojC0FgDX/c395uSwB5aipcUD7zfMtg4A2TJ6M6Kjpw== 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 4Vtz9d4VbbzTL1; Tue, 4 Jun 2024 18:08:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 454I8bwL072913; Tue, 4 Jun 2024 18:08:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 454I8buP072910; Tue, 4 Jun 2024 18:08:37 GMT (envelope-from git) Date: Tue, 4 Jun 2024 18:08:37 GMT Message-Id: <202406041808.454I8buP072910@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: 543d55d79109 - main - vm_phys: use ilog2(x) instead of fls(x)-1 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 543d55d79109ce47e43a98af16232aa86d0e02ec Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=543d55d79109ce47e43a98af16232aa86d0e02ec commit 543d55d79109ce47e43a98af16232aa86d0e02ec Author: Doug Moore AuthorDate: 2024-06-04 18:07:07 +0000 Commit: Doug Moore CommitDate: 2024-06-04 18:07:07 +0000 vm_phys: use ilog2(x) instead of fls(x)-1 One of these changes saves two instructions on an amd64 GENERIC-NODEBUG build. The rest are entirely cosmetic, because the compiler can deduce that x is nonzero, and avoid the needless test. Reviewed by: alc Differential Revision: https://reviews.freebsd.org/D45331 --- sys/vm/vm_phys.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c index 66ad9c13dceb..62e84a5b52bd 100644 --- a/sys/vm/vm_phys.c +++ b/sys/vm/vm_phys.c @@ -699,14 +699,14 @@ vm_phys_enq_beg(vm_page_t m, u_int npages, struct vm_freelist *fl, int tail) KASSERT(npages == 0 || (VM_PAGE_TO_PHYS(m) & - ((PAGE_SIZE << (fls(npages) - 1)) - 1)) == 0, + ((PAGE_SIZE << ilog2(npages)) - 1)) == 0, ("%s: page %p and npages %u are misaligned", __func__, m, npages)); while (npages > 0) { KASSERT(m->order == VM_NFREEORDER, ("%s: page %p has unexpected order %d", __func__, m, m->order)); - order = fls(npages) - 1; + order = ilog2(npages); KASSERT(order < VM_NFREEORDER, ("%s: order %d is out of range", __func__, order)); vm_freelist_add(fl, m, order, tail); @@ -735,7 +735,7 @@ vm_phys_enq_range(vm_page_t m, u_int npages, struct vm_freelist *fl, int tail) KASSERT(npages == 0 || ((VM_PAGE_TO_PHYS(m) + npages * PAGE_SIZE) & - ((PAGE_SIZE << (fls(npages) - 1)) - 1)) == 0, + ((PAGE_SIZE << ilog2(npages)) - 1)) == 0, ("vm_phys_enq_range: page %p and npages %u are misaligned", m, npages)); while (npages > 0) { @@ -1193,7 +1193,7 @@ vm_phys_enqueue_contig(vm_page_t m, u_long npages) lo = atop(VM_PAGE_TO_PHYS(m)); if (m < m_end && (diff = lo ^ (lo + npages - 1)) != 0) { - order = min(flsll(diff) - 1, VM_NFREEORDER - 1); + order = min(ilog2(diff), VM_NFREEORDER - 1); m = vm_phys_enq_range(m, roundup2(lo, 1 << order) - lo, fl, 1); } @@ -1225,7 +1225,7 @@ vm_phys_free_contig(vm_page_t m, u_long npages) vm_domain_free_assert_locked(vm_pagequeue_domain(m)); lo = atop(VM_PAGE_TO_PHYS(m)); - max_order = min(flsll(lo ^ (lo + npages)) - 1, VM_NFREEORDER - 1); + max_order = min(ilog2(lo ^ (lo + npages)), VM_NFREEORDER - 1); m_start = m; order_start = ffsll(lo) - 1;