git: a7f67ebd8275 - main - subr_rangeset: use pctrie_reclaim_cb in remove_all
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 13 Jun 2024 18:52:48 UTC
The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=a7f67ebd8275165b2f6099de20790e112f8b1433 commit a7f67ebd8275165b2f6099de20790e112f8b1433 Author: Doug Moore <dougm@FreeBSD.org> AuthorDate: 2024-06-13 18:49:43 +0000 Commit: Doug Moore <dougm@FreeBSD.org> 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 *