git: aa60a08f2a57 - main - amd64: replace tailq pointers with iterators
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Apr 2025 04:13:07 UTC
The branch main has been updated by dougm:
URL: https://cgit.FreeBSD.org/src/commit/?id=aa60a08f2a5737ef1fab34e539fb546871df2662
commit aa60a08f2a5737ef1fab34e539fb546871df2662
Author: Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2025-04-21 04:11:43 +0000
Commit: Doug Moore <dougm@FreeBSD.org>
CommitDate: 2025-04-21 04:11:43 +0000
amd64: replace tailq pointers with iterators
Change architecture-specific code to use iterators rather than tailq
pointers.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D49923
---
sys/amd64/amd64/efirt_machdep.c | 5 ++++-
sys/amd64/amd64/pmap.c | 25 ++++++++++++++-----------
sys/amd64/conf/PHO | 13 +++++++++++++
3 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/sys/amd64/amd64/efirt_machdep.c b/sys/amd64/amd64/efirt_machdep.c
index 2c00a16b1499..81a28ebe97ee 100644
--- a/sys/amd64/amd64/efirt_machdep.c
+++ b/sys/amd64/amd64/efirt_machdep.c
@@ -54,6 +54,7 @@
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_pager.h>
+#include <vm/vm_radix.h>
static pml5_entry_t *efi_pml5;
static pml4_entry_t *efi_pml4;
@@ -64,11 +65,13 @@ static vm_pindex_t efi_1t1_idx;
void
efi_destroy_1t1_map(void)
{
+ struct pctrie_iter pages;
vm_page_t m;
if (obj_1t1_pt != NULL) {
+ vm_page_iter_init(&pages, obj_1t1_pt);
VM_OBJECT_RLOCK(obj_1t1_pt);
- TAILQ_FOREACH(m, &obj_1t1_pt->memq, listq)
+ VM_RADIX_FOREACH(m, &pages)
m->ref_count = VPRC_OBJREF;
vm_wire_sub(obj_1t1_pt->resident_page_count);
VM_OBJECT_RUNLOCK(obj_1t1_pt);
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 5d31ad0dd495..9ff630de5b6e 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -7697,30 +7697,32 @@ void
pmap_enter_object(pmap_t pmap, vm_offset_t start, vm_offset_t end,
vm_page_t m_start, vm_prot_t prot)
{
+ struct pctrie_iter pages;
struct rwlock *lock;
vm_offset_t va;
vm_page_t m, mpte;
- vm_pindex_t diff, psize;
int rv;
VM_OBJECT_ASSERT_LOCKED(m_start->object);
- psize = atop(end - start);
mpte = NULL;
- m = m_start;
+ vm_page_iter_limit_init(&pages, m_start->object,
+ m_start->pindex + atop(end - start));
+ m = vm_radix_iter_lookup(&pages, m_start->pindex);
lock = NULL;
PMAP_LOCK(pmap);
- while (m != NULL && (diff = m->pindex - m_start->pindex) < psize) {
- va = start + ptoa(diff);
+ while (m != NULL) {
+ va = start + ptoa(m->pindex - m_start->pindex);
if ((va & PDRMASK) == 0 && va + NBPDR <= end &&
m->psind == 1 && pmap_ps_enabled(pmap) &&
((rv = pmap_enter_2mpage(pmap, va, m, prot, &lock)) ==
KERN_SUCCESS || rv == KERN_NO_SPACE))
- m = &m[NBPDR / PAGE_SIZE - 1];
- else
+ m = vm_radix_iter_jump(&pages, NBPDR / PAGE_SIZE);
+ else {
mpte = pmap_enter_quick_locked(pmap, va, m, prot,
mpte, &lock);
- m = TAILQ_NEXT(m, listq);
+ m = vm_radix_iter_step(&pages);
+ }
}
if (lock != NULL)
rw_wunlock(lock);
@@ -7894,6 +7896,7 @@ void
pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object,
vm_pindex_t pindex, vm_size_t size)
{
+ struct pctrie_iter pages;
pd_entry_t *pde;
pt_entry_t PG_A, PG_M, PG_RW, PG_V;
vm_paddr_t pa, ptepa;
@@ -7913,7 +7916,8 @@ pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object,
return;
if (!vm_object_populate(object, pindex, pindex + atop(size)))
return;
- p = vm_page_lookup(object, pindex);
+ vm_page_iter_init(&pages, object);
+ p = vm_radix_iter_lookup(&pages, pindex);
KASSERT(vm_page_all_valid(p),
("pmap_object_init_pt: invalid page %p", p));
pat_mode = p->md.pat_mode;
@@ -7931,15 +7935,14 @@ pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object,
* the pages are not physically contiguous or have differing
* memory attributes.
*/
- p = TAILQ_NEXT(p, listq);
for (pa = ptepa + PAGE_SIZE; pa < ptepa + size;
pa += PAGE_SIZE) {
+ p = vm_radix_iter_next(&pages);
KASSERT(vm_page_all_valid(p),
("pmap_object_init_pt: invalid page %p", p));
if (pa != VM_PAGE_TO_PHYS(p) ||
pat_mode != p->md.pat_mode)
return;
- p = TAILQ_NEXT(p, listq);
}
/*
diff --git a/sys/amd64/conf/PHO b/sys/amd64/conf/PHO
new file mode 100644
index 000000000000..7f0d3906ac64
--- /dev/null
+++ b/sys/amd64/conf/PHO
@@ -0,0 +1,13 @@
+include GENERIC
+ident PHO-GENERIC
+options ALT_BREAK_TO_DEBUGGER
+options SW_WATCHDOG
+options WITNESS
+options INVARIANTS # Enable calls of extra sanity checking
+options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
+options DEBUG_LOCKS
+options DEBUG_VFS_LOCKS
+options DIAGNOSTIC
+nooptions DEADLKRES # watchdogd handles this
+options UFS_EXTATTR
+options UFS_EXTATTR_AUTOSTART