summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2003-09-08 02:45:03 +0000
committeralc <alc@FreeBSD.org>2003-09-08 02:45:03 +0000
commita81d9ad0b98e80387ddd4e42ca6d4d3a2e30c1ec (patch)
treeb2790809d73f520fb71ebb6aa2acc4efb7933854
parentce0ede96f1c4135dba204423dccf8e16f7dc1dbd (diff)
downloadFreeBSD-src-a81d9ad0b98e80387ddd4e42ca6d4d3a2e30c1ec.zip
FreeBSD-src-a81d9ad0b98e80387ddd4e42ca6d4d3a2e30c1ec.tar.gz
Introduce a new pmap function, pmap_extract_and_hold(). This function
atomically extracts and holds the physical page that is associated with the given pmap and virtual address. Such a function is needed to make the memory mapping optimizations used by, for example, pipes and raw disk I/O MP-safe. Reviewed by: tegge
-rw-r--r--sys/alpha/alpha/pmap.c23
-rw-r--r--sys/amd64/amd64/pmap.c24
-rw-r--r--sys/i386/i386/pmap.c24
-rw-r--r--sys/ia64/ia64/pmap.c24
-rw-r--r--sys/sparc64/sparc64/pmap.c22
-rw-r--r--sys/vm/pmap.h1
6 files changed, 118 insertions, 0 deletions
diff --git a/sys/alpha/alpha/pmap.c b/sys/alpha/alpha/pmap.c
index 223d824..a2f5a50 100644
--- a/sys/alpha/alpha/pmap.c
+++ b/sys/alpha/alpha/pmap.c
@@ -811,6 +811,29 @@ pmap_extract(pmap, va)
return 0;
}
+/*
+ * Routine: pmap_extract_and_hold
+ * Function:
+ * Atomically extract and hold the physical page
+ * with the given pmap and virtual address.
+ */
+vm_page_t
+pmap_extract_and_hold(pmap_t pmap, vm_offset_t va)
+{
+ vm_paddr_t pa;
+ vm_page_t m;
+
+ m = NULL;
+ mtx_lock(&Giant);
+ if ((pa = pmap_extract(pmap, va)) != 0) {
+ m = PHYS_TO_VM_PAGE(pa);
+ vm_page_lock_queues();
+ vm_page_hold(m);
+ vm_page_unlock_queues();
+ }
+ mtx_unlock(&Giant);
+ return (m);
+}
/***************************************************
* Low level mapping routines.....
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index e862c82..fed7dac 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -749,6 +749,30 @@ pmap_extract(pmap, va)
}
+/*
+ * Routine: pmap_extract_and_hold
+ * Function:
+ * Atomically extract and hold the physical page
+ * with the given pmap and virtual address.
+ */
+vm_page_t
+pmap_extract_and_hold(pmap_t pmap, vm_offset_t va)
+{
+ vm_paddr_t pa;
+ vm_page_t m;
+
+ m = NULL;
+ mtx_lock(&Giant);
+ if ((pa = pmap_extract(pmap, va)) != 0) {
+ m = PHYS_TO_VM_PAGE(pa);
+ vm_page_lock_queues();
+ vm_page_hold(m);
+ vm_page_unlock_queues();
+ }
+ mtx_unlock(&Giant);
+ return (m);
+}
+
vm_paddr_t
pmap_kextract(vm_offset_t va)
{
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 1f13890..924a14f 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -861,6 +861,30 @@ pmap_extract(pmap, va)
}
+/*
+ * Routine: pmap_extract_and_hold
+ * Function:
+ * Atomically extract and hold the physical page
+ * with the given pmap and virtual address.
+ */
+vm_page_t
+pmap_extract_and_hold(pmap_t pmap, vm_offset_t va)
+{
+ vm_paddr_t pa;
+ vm_page_t m;
+
+ m = NULL;
+ mtx_lock(&Giant);
+ if ((pa = pmap_extract(pmap, va)) != 0) {
+ m = PHYS_TO_VM_PAGE(pa);
+ vm_page_lock_queues();
+ vm_page_hold(m);
+ vm_page_unlock_queues();
+ }
+ mtx_unlock(&Giant);
+ return (m);
+}
+
/***************************************************
* Low level mapping routines.....
***************************************************/
diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c
index 8b0a8c0..f5f5459 100644
--- a/sys/ia64/ia64/pmap.c
+++ b/sys/ia64/ia64/pmap.c
@@ -1102,6 +1102,30 @@ pmap_extract(pmap, va)
return pmap_pte_pa(pte);
}
+/*
+ * Routine: pmap_extract_and_hold
+ * Function:
+ * Atomically extract and hold the physical page
+ * with the given pmap and virtual address.
+ */
+vm_page_t
+pmap_extract_and_hold(pmap_t pmap, vm_offset_t va)
+{
+ vm_paddr_t pa;
+ vm_page_t m;
+
+ m = NULL;
+ mtx_lock(&Giant);
+ if ((pa = pmap_extract(pmap, va)) != 0) {
+ m = PHYS_TO_VM_PAGE(pa);
+ vm_page_lock_queues();
+ vm_page_hold(m);
+ vm_page_unlock_queues();
+ }
+ mtx_unlock(&Giant);
+ return (m);
+}
+
/***************************************************
* Low level mapping routines.....
***************************************************/
diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c
index f4a391b..f532152 100644
--- a/sys/sparc64/sparc64/pmap.c
+++ b/sys/sparc64/sparc64/pmap.c
@@ -621,6 +621,28 @@ pmap_extract(pmap_t pm, vm_offset_t va)
}
/*
+ * Atomically extract and hold the physical page with the given
+ * pmap and virtual address pair.
+ */
+vm_page_t
+pmap_extract_and_hold(pmap_t pmap, vm_offset_t va)
+{
+ vm_paddr_t pa;
+ vm_page_t m;
+
+ m = NULL;
+ mtx_lock(&Giant);
+ if ((pa = pmap_extract(pmap, va)) != 0) {
+ m = PHYS_TO_VM_PAGE(pa);
+ vm_page_lock_queues();
+ vm_page_hold(m);
+ vm_page_unlock_queues();
+ }
+ mtx_unlock(&Giant);
+ return (m);
+}
+
+/*
* Extract the physical page address associated with the given kernel virtual
* address.
*/
diff --git a/sys/vm/pmap.h b/sys/vm/pmap.h
index af809bb..29f20c2 100644
--- a/sys/vm/pmap.h
+++ b/sys/vm/pmap.h
@@ -106,6 +106,7 @@ void pmap_enter(pmap_t, vm_offset_t, vm_page_t, vm_prot_t,
vm_page_t pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m,
vm_page_t mpte);
vm_paddr_t pmap_extract(pmap_t pmap, vm_offset_t va);
+vm_page_t pmap_extract_and_hold(pmap_t pmap, vm_offset_t va);
void pmap_growkernel(vm_offset_t);
void pmap_init(vm_paddr_t, vm_paddr_t);
boolean_t pmap_is_modified(vm_page_t m);
OpenPOWER on IntegriCloud