From nobody Thu Jun 13 18:52:48 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 4W0WkT1wMWz5P8wk; Thu, 13 Jun 2024 18:52:49 +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 4W0WkT0q8Dz4mwl; Thu, 13 Jun 2024 18:52:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718304769; 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=0dWE8kdb7tJ9de+EOK9KGl4XrRUI0MecbSh+Z6BOsf0=; b=FUrywa3JhFUK63HSpBiNBht0p+/7B6x5ou21fbq7KORqmkhnfAMCEck3Vfw7VM6DjrQgu7 sdXofDoLd/rO+9cuevnAOheq2LxBVEyuhzYAOQ0/kE6kkRcxN9BFoEL//nO++6oP6ajtSF DfWlvezRROVPCzK5Z3g3D2yDSG6z1E2S69tk4VdG1GRvLJEEjJJUuPSlNnnyeOlmT+AosZ mOy5aznk2QSIH452IHhKh0+rsRcPTwGTz/G2xSXgMWqvVm63FJFwFjP5ct4nz/nm6xg1jE SXB4y31DdhU6vN1EKYQTT+mH56+eBuqaXvQqzWp3tG7GYAErSnzmOAEm/lhFTg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718304769; a=rsa-sha256; cv=none; b=bZ81sLqZNuHbwo4zrYFRO1McONQNvfLBFcUIKflxlQNPssl88ymKbHsdPSszGdQUbkAnTB cGZkcvyenX97e4S1X8F4Ix8+t9TIRv5oKQqZ87vxf3XmVMhI7J8J41cLIgF2pJuRvtncpw aYGGHmg1iyyaglevDzZYqWQDkkxlSXG87klAva9QQgbl2tGTpcSKyrLhgjXToq284YfZ+p MDa2dEMiLhYFrJdcDbP4ic8MjiF7pKuR9L+ic6jBRQbJohWNqj4gxk3GIFpU00g/S2euZj uL3zv1gsMGy445w5UmVa3InWLD7y40Dcm43hjY380Gt841ccFEFWplnXsqVaiw== 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=1718304769; 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=0dWE8kdb7tJ9de+EOK9KGl4XrRUI0MecbSh+Z6BOsf0=; b=KumA8L+/vI1AKgnhTifKeor5J7esAVCV0hJXhb7g8d0I7vaSmj6JulxvJRxhk56212/vPp qRZLvSxBE5RUduZjI+oWNHx3Zd8zsU5r+AvFLYhYmDCtmCRGokMDF278FFLV2QbQkf3e19 gsa437ih2/fgSMXjQHSxaMv3N8E4UbUDQECvyQSH/Hupt2e8jZL714eUrET7LwMJBixzo/ a6hl6BVf807wUTWkLFGd5zdjbdTSA3o4y3dWojAWYJLXGz2e9Fkbq15Chg9gSUBH3ys/MW 4qsoTE/giHdFlQtHVJ83pSxWLEM9yDfU3QdAJU6urZvZrQkrV02qXa0AfDC9hg== 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 4W0WkT0PjJznqx; Thu, 13 Jun 2024 18:52:49 +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 45DIqmG5004506; Thu, 13 Jun 2024 18:52:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45DIqmxu004503; Thu, 13 Jun 2024 18:52:48 GMT (envelope-from git) Date: Thu, 13 Jun 2024 18:52:48 GMT Message-Id: <202406131852.45DIqmxu004503@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: a7f67ebd8275 - main - subr_rangeset: use pctrie_reclaim_cb in remove_all 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: a7f67ebd8275165b2f6099de20790e112f8b1433 Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=a7f67ebd8275165b2f6099de20790e112f8b1433 commit a7f67ebd8275165b2f6099de20790e112f8b1433 Author: Doug Moore AuthorDate: 2024-06-13 18:49:43 +0000 Commit: Doug Moore CommitDate: 2024-06-13 18:52:25 +0000 subr_rangeset: use pctrie_reclaim_cb in remove_all Replace the lookup-remove loop in rangeet_remove_all with a call to SWAP_PCTRIE_RECLAIM_CALLBACK, to eliminate repeated trie searches. Reviewed by: rlibby Differential Revision: https://reviews.freebsd.org/D45584 --- sys/kern/subr_rangeset.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sys/kern/subr_rangeset.c b/sys/kern/subr_rangeset.c index 0a675b4a2fce..94b77a449d22 100644 --- a/sys/kern/subr_rangeset.c +++ b/sys/kern/subr_rangeset.c @@ -232,18 +232,20 @@ rangeset_remove(struct rangeset *rs, uint64_t start, uint64_t end) return (rangeset_remove_pred(rs, start, end, rangeset_true_pred)); } +static void +rangeset_remove_leaf(void *rv, void *rsv) +{ + struct rs_el *r = rv; + struct rangeset *rs = rsv; + + rs->rs_free_data(rs->rs_data_ctx, r); +} + void rangeset_remove_all(struct rangeset *rs) { - struct rs_el *r; - - for (;;) { - r = RANGESET_PCTRIE_LOOKUP_GE(&rs->rs_trie, 0); - if (r == NULL) - break; - RANGESET_PCTRIE_REMOVE(&rs->rs_trie, r->re_start); - rs->rs_free_data(rs->rs_data_ctx, r); - } + RANGESET_PCTRIE_RECLAIM_CALLBACK(&rs->rs_trie, + rangeset_remove_leaf, rs); } void *