From nobody Tue Jun 27 05:44:53 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 4Qqtvp0VBRz4k9JT; Tue, 27 Jun 2023 05:44:54 +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 4Qqtvn6X5Zz3MDk; Tue, 27 Jun 2023 05:44:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687844694; 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=juqNReqlMh+28m/RAAHYWrlIlI6ewwAl/mIQ2YHD4YU=; b=KJWxFk+ow9ZabrT5oVWWTNHkWJxU1XoAv6n7tJvTxM110gJ5XxXB1dAxqxqgO9YLlmWnDe xE3rDJuWa29PEsqcIwW/SMmn2lvINKDX/m0/2dKfI9qrWX7v7SlsY1CFHqgHgjY8r8LKlq LNvNCuT1cOQ3pTfbJNzqh/MKJAumj99YzhhKzDiyui9FbxEv2xPdF0TipmOYu93/Ig3Xdm qIe+OAwd9molJkGQ68KmIERN5B3uXcjsE8C5jdRPUvCTiIf1lg9ZSG20qjsR/H+WN5gyks ffCmaKSURsmoK8OwGb+tsf6kCdyU1JZ9M37Xy2Umvt4wLEh0n0b5w/kl7Eon5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687844694; 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=juqNReqlMh+28m/RAAHYWrlIlI6ewwAl/mIQ2YHD4YU=; b=epV20OPlWysv9ZR8tZDrC1Bh29ASW7Ug1wViLTDKeze6elTS7Ne7CQilOQ2+CyUFj9z/2k 08gqRnpTw5Oe4DriJaUZduG05lqaZEAKOJYRq0BHMNAV4VQNHJEApp1FKOKzQYAgelp+nR Nv2F/HZY75FMrEbmne0vwwKAVkzSyA/qhtjva1xw6kCAmkpV7bmcOVkMPrqs33z8loHs2o GecGcGc4Hu9vroMjIh3f3xHxUKtbEQnVNX+zPOcC+fRw7zTHk31CPvtPxWcp3CI65xytkq K91fz/wEqFS6xmpHtujiZaUuU/3deed5jL+/vAqKq73kV+RXYUrU4v6uFg+G0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687844694; a=rsa-sha256; cv=none; b=INd9ZLqtcbrqVBNJhCrpFZyYDM75rJLcI3KNv9Ik8odMJRk2BWnTdUjcaDVWBtKVBbNtnp ZF8vFXUUEeZ3tpOJYCQn87pMgFpTjPjdxYgmIBF60bjUBXUVGh3qB5Y0iJn4B/azTCweFE RrW3HNBryBGLAvrrGHWG5pywF+F7oZDim39lVB64snMZPahpBDfrtyuWpoEDvuyJdsVoXn c/ruWdLJp70ScYYDv+f3VDiCCSgcTuGPgNHnrxwM8kSNQYgH7+dVNdRfx2MCKZmXk3MQOq Mj+XMGmCMOcTjaa8WlIQRUeyJrAyy8+doO+LOdbieiKF4GOS314pLFN+rVVJrQ== 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 4Qqtvn51PSzgJb; Tue, 27 Jun 2023 05:44:53 +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 35R5ir9Y050908; Tue, 27 Jun 2023 05:44:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35R5iraT050907; Tue, 27 Jun 2023 05:44:53 GMT (envelope-from git) Date: Tue, 27 Jun 2023 05:44:53 GMT Message-Id: <202306270544.35R5iraT050907@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: 72c3a43b16b2 - main - radix_trie: skip compare in lookup_le, lookup_ge 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: 72c3a43b16b20cdc86508e58f61c2e0e28e65549 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=72c3a43b16b20cdc86508e58f61c2e0e28e65549 commit 72c3a43b16b20cdc86508e58f61c2e0e28e65549 Author: Doug Moore AuthorDate: 2023-06-27 05:42:41 +0000 Commit: Doug Moore CommitDate: 2023-06-27 05:42:41 +0000 radix_trie: skip compare in lookup_le, lookup_ge In _lookup_ge, where a loop "looks for an available edge or val within the current bisection node" (to quote the code comment), the value of index has already been modified to guarantee that it is the least value than can be found in the non-NULL child node being examined. Therefore, if the non-NULL child is a leaf, there's no need to compare 'index' to anything, and the value can just be returned. The same is true for _lookup_le with 'most' replacing 'least'. Reviewed by: alc Tested by: pho Differential Revision: https://reviews.freebsd.org/D40746 --- sys/kern/subr_pctrie.c | 10 ++++++---- sys/vm/vm_radix.c | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c index 44a00a9eef77..d9269bfb3885 100644 --- a/sys/kern/subr_pctrie.c +++ b/sys/kern/subr_pctrie.c @@ -560,8 +560,9 @@ ascend: NULL, PCTRIE_LOCKED); if (pctrie_isleaf(child)) { m = pctrie_toval(child); - if (*m >= index) - return (m); + KASSERT(*m >= index, + ("pctrie_lookup_ge: leaf < index")); + return (m); } else if (child != NULL) goto descend; } while (slot < (PCTRIE_COUNT - 1)); @@ -677,8 +678,9 @@ ascend: NULL, PCTRIE_LOCKED); if (pctrie_isleaf(child)) { m = pctrie_toval(child); - if (*m <= index) - return (m); + KASSERT(*m <= index, + ("pctrie_lookup_le: leaf > index")); + return (m); } else if (child != NULL) goto descend; } while (slot > 0); diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c index 7d3408226be1..9c8ba5287d4e 100644 --- a/sys/vm/vm_radix.c +++ b/sys/vm/vm_radix.c @@ -595,8 +595,9 @@ ascend: LOCKED); if (vm_radix_isleaf(child)) { m = vm_radix_topage(child); - if (m->pindex >= index) - return (m); + KASSERT(m->pindex >= index, + ("vm_radix_lookup_ge: leafpindex <= index) - return (m); + KASSERT(m->pindex <= index, + ("vm_radix_lookup_le: leaf>index")); + return (m); } else if (child != NULL) goto descend; } while (slot > 0);