From nobody Fri Oct 25 22:01:57 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 4XZxZt0k1Hz5bBgn; Fri, 25 Oct 2024 22:01:58 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XZxZs75X7z417N; Fri, 25 Oct 2024 22:01:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729893718; 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=640lr0RLezKduWAtOu6DVbHYdbXWxu6TXIqWa4ViPtA=; b=YYMhxHX3QIh3VW4U64Vkrkxln8YPkwq6/K8GNmz3SSaHMSaYf4bwCG89Fs/1NqdgQSMtZX kxi28OsPonJdFheeuPBwTKGw7bkpek0O2osuu1UZyPbLzl4if2OLjxTRibYESLA2gcnj4z 4QoYFRxA97tLl8zr6M2WNmK5kvnU+fBjJt8XG1UExdNCc58f1s+5QGbPwpEnO47BPah5qt L17Pbr7JaagLnWDB4i1jyJzVyf8q0wmAoqVIjVBhYTDtJ8dqrtfa6biUa14rPy45q33dkg RZpaariRpU5ByVj3LqBTmF6KEBUo7Uv+ZdShju+PyRNJlL4j7C943/gmJJut4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729893718; 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=640lr0RLezKduWAtOu6DVbHYdbXWxu6TXIqWa4ViPtA=; b=THYFp2AIRwF0sl1EfHQ4qr7YcXvoWJX/4KNsojLXISLiDDir1IfYpsjlMpJB5n4PtOOACc /9lrrFRdgrjoWL4Jr7XRCW8ORMcRUm2WV1W7dhBt/+nLJQo7B09BP/uJs/9A0NMASJGsSh PY2gnZvnh0XiIHN/7zLpKnUoUVuXFN3j3AyEfy2Ga0EUsLOnXi4kum1xWMgYdoWIUPqd6d IjY+5At6qCFADeqcwmCI5vtvIlO9l2S8HeZilh1eT1a4PX36rbHNvhWUD2PkCzA4M4CJ2M eEN4Xp8q3FQevxDpnEzJmLkIdD52CGcR+Xa74qEMYmL2VlgRAxFIlWu5wVGYCA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729893718; a=rsa-sha256; cv=none; b=WF79GZNk+kWEZSZlzMFdZsrWlPqwiRNjVag4H4UoznvaOup64sp+Gu9ibSSYDhttzxJTtb zAuyLs9NeWH0BIAM4ABMyuo3TBb0VonwIJSfqrTikQZW0LYPeOeI39wDY/9/AmEAYfaCeq cdL28T/WO1O81SAuOP6XrOkgoNrEU0eYaB6cX2T7FiecfMe4ZStO3fjSZrb+cPpjGzUQDJ UlOuNluc1D51i3Za2mmQ87xhScFIMWxunaJnC492mHmaoInZm12LCWw1qk6Q5ZH9buC6/5 Xm1Mgu/+0um+ykHcxCBhCbL6MUtpIyiURerKcrocWterEh0q7MhVTt7BaagSsw== 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 4XZxZs6j3Jzk9l; Fri, 25 Oct 2024 22:01:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49PM1vRP004894; Fri, 25 Oct 2024 22:01:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49PM1vv4004891; Fri, 25 Oct 2024 22:01:57 GMT (envelope-from git) Date: Fri, 25 Oct 2024 22:01:57 GMT Message-Id: <202410252201.49PM1vv4004891@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: 0d965bc03428 - main - subr_pctrie: improve iter nbr search 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: 0d965bc03428b66689d311fa4275868dfe27c82e Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=0d965bc03428b66689d311fa4275868dfe27c82e commit 0d965bc03428b66689d311fa4275868dfe27c82e Author: Doug Moore AuthorDate: 2024-10-25 22:00:31 +0000 Commit: Doug Moore CommitDate: 2024-10-25 22:00:31 +0000 subr_pctrie: improve iter nbr search pctrie_toval(node) can be applied to either a leaf or an internal node; in the latter case it provides the address of the pn_owner field. In a couple of places where a neighbor search is about to begin for an iterator, the current code distinguishes the leaf and non-leaf cases in a way that isn't really necessary. This change shrinks each function by 16 bytes, and by a branch instruction. Reviewed by: bnovkov Differential Revision: https://reviews.freebsd.org/D47207 --- sys/kern/subr_pctrie.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c index ea1c1cf881d2..e4865c602ce4 100644 --- a/sys/kern/subr_pctrie.c +++ b/sys/kern/subr_pctrie.c @@ -801,9 +801,7 @@ pctrie_iter_lookup_ge(struct pctrie_iter *it, uint64_t index) * If no such node was found, and instead this path leads only to nodes * < index, back up to find a subtrie with the least value > index. */ - if (pctrie_isleaf(node) ? - (m = pctrie_toval(node)) == NULL || *m < index : - node->pn_owner < index) { + if (node == PCTRIE_NULL || *pctrie_toval(node) < index) { /* Climb the path to find a node with a descendant > index. */ while (it->top != 0) { node = it->path[it->top - 1]; @@ -960,9 +958,7 @@ pctrie_iter_lookup_le(struct pctrie_iter *it, uint64_t index) * If no such node was found, and instead this path leads only to nodes * > index, back up to find a subtrie with the greatest value < index. */ - if (pctrie_isleaf(node) ? - (m = pctrie_toval(node)) == NULL || *m > index : - node->pn_owner > index) { + if (node == PCTRIE_NULL || *pctrie_toval(node) > index) { /* Climb the path to find a node with a descendant < index. */ while (it->top != 0) { node = it->path[it->top - 1];