From nobody Sun Jun 25 17:50:56 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 4Qpz6S6DNTz4hsZr; Sun, 25 Jun 2023 17:50:56 +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 4Qpz6S5p8dz3LBB; Sun, 25 Jun 2023 17:50:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687715456; 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=rvAkmfdioVJadSvPwJltPkJFK7xm5QRTGp+MyWYkJIA=; b=s3u4bX6TW1KqsPd63NqyXp0shoLDn+G4D0hvQQK6375zb24ho44VyP+yNESdhkc/5siQWx /MwdZQpiDM84VeQGIrHTTlpXQ7hbdJXRIhHXECC0sC7rrpfkxf94AaFZANaGYNWOUXfB5G oXAH5LL2oHsBy9K1LpCFiyCltW4VYbhpNF7JV0NLiPR3ll8kNeyJUQpRlW9vlGwbiTxvt7 kdSHpIr9pNDwzq8VWrjS8hgz/fPkupH/QbEFoUnMQgrGbLxoYYmn2ukTrUIApG5VDiIPEE oLWhteg7EE6zRrRPt3ZGkspybn6P/2hA6QiF3OHj+4Tvb+9eKNLMBdjINYnjBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687715456; 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=rvAkmfdioVJadSvPwJltPkJFK7xm5QRTGp+MyWYkJIA=; b=pnZxcQMkctQhWb7L9FBwLE7udALOfdrnfrHZFlReVJobD9FHiXGkvm3vCYK9VnrgNUAsfb QH5XcQfy2LzNugUNt+1mNdG0F+MTQr/85biudR7fQymITlCdGTMADk48XJtthD8MgZH5pu kTjmqeqI+Ela+QVx4plQgcrLYfr9yMdaIXu9psbpX8C/dUNYYcsVgr8Ku67o5rRh3Ba518 fwpSgiy64VUKTknsGshgyCN13YvEkr5pt3SqEXMtB67h99Gq6oP1PkE0sYEM8D/ht+hdQ9 USGdATMgYvfM6Lbk15WnE4PkBTsjbf6HAl9RdQtaUnhkvKyfrdzB9l4XCUCYGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687715456; a=rsa-sha256; cv=none; b=lmQJPfBZas6TrZM+ZkHKLDvk40/AO5AmpagFujqFPRJD8GEIlpWDS522yvx275XnQT5MwH 6ChMa1JyHnGGPfoR0kxbGkEfqopWJUBnpdpQwCYgXLLZ2Z4LCzw/V+EI6z+f+Xtf+nSNoH 2vXt6vm9+P2euPDuDTJ4vSzaP31FShqfL2tHsqeKR6ohkbnMXXog3Z8PuyOnEas84UBMqe FYQ3nlckcw+q5wEASfF5Gf4IG8qEA/gMW52Z52b3oAFRcLrqYef7t1ZLrrYuJU54A1xabs DmCIvUH4rG3Qa4ZbnVEsmjoka6fqAAsY81Ch4jG8nCsZwyvKY/YIKj9GqYv3xw== 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 4Qpz6S3SSczcWN; Sun, 25 Jun 2023 17:50:56 +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 35PHou7K066378; Sun, 25 Jun 2023 17:50:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35PHouZr066377; Sun, 25 Jun 2023 17:50:56 GMT (envelope-from git) Date: Sun, 25 Jun 2023 17:50:56 GMT Message-Id: <202306251750.35PHouZr066377@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: a42d8fe001b9 - main - radix_trie: simplify trimkey functions 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: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a42d8fe001b912a5e4efdd4020d9bfadc07f6c7f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=a42d8fe001b912a5e4efdd4020d9bfadc07f6c7f commit a42d8fe001b912a5e4efdd4020d9bfadc07f6c7f Author: Doug Moore AuthorDate: 2023-06-25 17:49:15 +0000 Commit: Doug Moore CommitDate: 2023-06-25 17:49:15 +0000 radix_trie: simplify trimkey functions Replacing a branch and two shifts with a single masking operation saves 64 bytes the pair of functions lookup_le and lookup_ge on amd64. Refresh the associated comments. Reviewed by: alc Differential Revision: https://reviews.freebsd.org/D40722 --- sys/kern/subr_pctrie.c | 11 ++--------- sys/vm/vm_radix.c | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c index 043c31ad9501..44a00a9eef77 100644 --- a/sys/kern/subr_pctrie.c +++ b/sys/kern/subr_pctrie.c @@ -156,18 +156,11 @@ pctrie_slot(uint64_t index, uint16_t level) return ((index >> (level * PCTRIE_WIDTH)) & PCTRIE_MASK); } -/* Trims the key after the specified level. */ +/* Computes the key (index) with the low-order 'level' radix-digits zeroed. */ static __inline uint64_t pctrie_trimkey(uint64_t index, uint16_t level) { - uint64_t ret; - - ret = index; - if (level > 0) { - ret >>= level * PCTRIE_WIDTH; - ret <<= level * PCTRIE_WIDTH; - } - return (ret); + return (index & -PCTRIE_UNITLEVEL(level)); } /* diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c index cc932a6cc80d..7d3408226be1 100644 --- a/sys/vm/vm_radix.c +++ b/sys/vm/vm_radix.c @@ -181,18 +181,11 @@ vm_radix_slot(vm_pindex_t index, uint16_t level) return ((index >> (level * VM_RADIX_WIDTH)) & VM_RADIX_MASK); } -/* Trims the key after the specified level. */ +/* Computes the key (index) with the low-order 'level' radix-digits zeroed. */ static __inline vm_pindex_t vm_radix_trimkey(vm_pindex_t index, uint16_t level) { - vm_pindex_t ret; - - ret = index; - if (level > 0) { - ret >>= level * VM_RADIX_WIDTH; - ret <<= level * VM_RADIX_WIDTH; - } - return (ret); + return (index & -VM_RADIX_UNITLEVEL(level)); } /*