From a81d9ad0b98e80387ddd4e42ca6d4d3a2e30c1ec Mon Sep 17 00:00:00 2001 From: alc Date: Mon, 8 Sep 2003 02:45:03 +0000 Subject: 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 --- sys/sparc64/sparc64/pmap.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sys/sparc64') 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. */ -- cgit v1.1