git: b7631876399c - main - vm _radix: define foreach macros for walking pages
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 18 Apr 2025 15:44:03 UTC
The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=b7631876399c1d3eff3553778964f141ad1a5e4d commit b7631876399c1d3eff3553778964f141ad1a5e4d Author: Doug Moore <dougm@FreeBSD.org> AuthorDate: 2025-04-18 15:42:35 +0000 Commit: Doug Moore <dougm@FreeBSD.org> CommitDate: 2025-04-18 15:42:35 +0000 vm _radix: define foreach macros for walking pages Define VM_RADIX_FOREACH to be TAILQ free equivalent of TAIL_FOREACH, and VM_RADIX_FORALL for walking consecutive pages. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D49881 --- sys/vm/vm_radix.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sys/vm/vm_radix.h b/sys/vm/vm_radix.h index e9ee3e7f3911..49ea16079d2b 100644 --- a/sys/vm/vm_radix.h +++ b/sys/vm/vm_radix.h @@ -257,6 +257,18 @@ vm_radix_iter_step(struct pctrie_iter *pages) return (VM_RADIX_PCTRIE_ITER_STEP_GE(pages)); } +/* + * Iterate over each non-NULL page from page 'start' to the end of the object. + */ +#define VM_RADIX_FOREACH_FROM(m, pages, start) \ + for (m = vm_radix_iter_lookup_ge(&pages, start); m != NULL; \ + m = vm_radix_iter_step(&pages)) + +/* + * Iterate over each non-NULL page from the beginning to the end of the object. + */ +#define VM_RADIX_FOREACH(m, pages) VM_RADIX_FOREACH_FROM(m, pages, 0) + /* * Initialize an iterator pointing to the page with the greatest pindex that is * less than or equal to the specified pindex, or NULL if there are no such @@ -295,6 +307,20 @@ vm_radix_iter_next(struct pctrie_iter *pages) return (VM_RADIX_PCTRIE_ITER_NEXT(pages)); } +/* + * Iterate over consecutive non-NULL pages from position 'start' to first NULL + * page. + */ +#define VM_RADIX_FORALL_FROM(m, pages, start) \ + for (m = vm_radix_iter_lookup(&pages, start); m != NULL; \ + m = vm_radix_iter_next(&pages)) + +/* + * Iterate over consecutive non-NULL pages from the beginning to first NULL + * page. + */ +#define VM_RADIX_FORALL(m, pages) VM_RADIX_FORALL_FROM(m, pages, 0) + /* * Update the iterator to point to the page with the pindex that is one less * than the current pindex, or NULL if there is no such page. Return the page.