Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115897280
D45910.id140869.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D45910.id140869.diff
View Options
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -947,6 +947,17 @@
return (queue == PQ_LAUNDRY || queue == PQ_UNSWAPPABLE);
}
+static inline void
+vm_page_clearref(vm_page_t m)
+{
+ u_int r;
+
+ r = m->ref_count;
+ while (atomic_fcmpset_int(&m->ref_count, &r, r & (VPRC_BLOCKED |
+ VPRC_OBJREF)) == 0)
+ ;
+}
+
/*
* vm_page_drop:
*
diff --git a/sys/x86/iommu/intel_idpgtbl.c b/sys/x86/iommu/intel_idpgtbl.c
--- a/sys/x86/iommu/intel_idpgtbl.c
+++ b/sys/x86/iommu/intel_idpgtbl.c
@@ -47,6 +47,7 @@
#include <sys/tree.h>
#include <sys/uio.h>
#include <sys/vmem.h>
+#include <sys/vmmeter.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/vm_kern.h>
@@ -390,7 +391,7 @@
* pte write and clean while the lock is
* dropped.
*/
- m->ref_count++;
+ vm_page_wire(m);
sfp = NULL;
ptep = domain_pgtbl_map_pte(domain, base, lvl - 1,
@@ -398,7 +399,7 @@
if (ptep == NULL) {
KASSERT(m->pindex != 0,
("loosing root page %p", domain));
- m->ref_count--;
+ vm_page_unwire_noq(m);
iommu_pgfree(domain->pgtbl_obj, m->pindex,
flags);
return (NULL);
@@ -406,8 +407,8 @@
dmar_pte_store(&ptep->pte, DMAR_PTE_R | DMAR_PTE_W |
VM_PAGE_TO_PHYS(m));
dmar_flush_pte_to_ram(domain->dmar, ptep);
- sf_buf_page(sfp)->ref_count += 1;
- m->ref_count--;
+ vm_page_wire(sf_buf_page(sfp));
+ vm_page_unwire_noq(m);
iommu_unmap_pgtbl(sfp);
/* Only executed once. */
goto retry;
@@ -486,7 +487,7 @@
dmar_pte_store(&pte->pte, VM_PAGE_TO_PHYS(ma[pi]) | pflags |
(superpage ? DMAR_PTE_SP : 0));
dmar_flush_pte_to_ram(domain->dmar, pte);
- sf_buf_page(sf)->ref_count += 1;
+ vm_page_wire(sf_buf_page(sf));
}
if (sf != NULL)
iommu_unmap_pgtbl(sf);
@@ -592,8 +593,7 @@
iommu_unmap_pgtbl(*sf);
*sf = NULL;
}
- m->ref_count--;
- if (m->ref_count != 0)
+ if (!vm_page_unwire_noq(m))
return;
KASSERT(lvl != 0,
("lost reference (lvl) on root pg domain %p base %jx lvl %d",
@@ -709,7 +709,7 @@
m = iommu_pgalloc(domain->pgtbl_obj, 0, IOMMU_PGF_WAITOK |
IOMMU_PGF_ZERO | IOMMU_PGF_OBJL);
/* No implicit free of the top level page table page. */
- m->ref_count = 1;
+ vm_page_wire(m);
DMAR_DOMAIN_PGUNLOCK(domain);
DMAR_LOCK(domain->dmar);
domain->iodom.flags |= IOMMU_DOMAIN_PGTBL_INITED;
@@ -741,8 +741,10 @@
/* Obliterate ref_counts */
VM_OBJECT_ASSERT_WLOCKED(obj);
- for (m = vm_page_lookup(obj, 0); m != NULL; m = vm_page_next(m))
- m->ref_count = 0;
+ for (m = vm_page_lookup(obj, 0); m != NULL; m = vm_page_next(m)) {
+ vm_page_clearref(m);
+ vm_wire_sub(1);
+ }
VM_OBJECT_WUNLOCK(obj);
vm_object_deallocate(obj);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, May 1, 3:47 AM (5 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17872028
Default Alt Text
D45910.id140869.diff (2 KB)
Attached To
Mode
D45910: DMAR pagetable free: handle ref_count special references
Attached
Detach File
Event Timeline
Log In to Comment