Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/uvm Add a set of "lockflags", which can control the lock...
details: https://anonhg.NetBSD.org/src/rev/7403be6e087c
branches: trunk
changeset: 474735:7403be6e087c
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Jul 17 21:35:49 1999 +0000
description:
Add a set of "lockflags", which can control the locking behavior
of some functions. Use these flags in uvm_map_pageable() to determine
if the map is locked on entry (replaces an already present boolean_t
argument `islocked'), and if the function should return with the map
still locked.
diffstat:
sys/uvm/uvm_extern.h | 10 ++++++++--
sys/uvm/uvm_map.c | 39 +++++++++++++++++++++++++++------------
sys/uvm/uvm_mmap.c | 8 ++++----
3 files changed, 39 insertions(+), 18 deletions(-)
diffs (170 lines):
diff -r 04dd52f13fa5 -r 7403be6e087c sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h Sat Jul 17 20:02:48 1999 +0000
+++ b/sys/uvm/uvm_extern.h Sat Jul 17 21:35:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_extern.h,v 1.32 1999/07/02 23:20:58 thorpej Exp $ */
+/* $NetBSD: uvm_extern.h,v 1.33 1999/07/17 21:35:49 thorpej Exp $ */
/*
*
@@ -135,6 +135,12 @@
#define UVM_PGA_USERESERVE 0x0001
/*
+ * lockflags that control the locking behavior of various functions.
+ */
+#define UVM_LK_ENTER 0x00000001 /* map locked on entry */
+#define UVM_LK_EXIT 0x00000002 /* leave map locked on exit */
+
+/*
* structures
*/
@@ -325,7 +331,7 @@
int uvm_map __P((vm_map_t, vaddr_t *, vsize_t,
struct uvm_object *, vaddr_t, uvm_flag_t));
int uvm_map_pageable __P((vm_map_t, vaddr_t,
- vaddr_t, boolean_t, boolean_t));
+ vaddr_t, boolean_t, int));
int uvm_map_pageable_all __P((vm_map_t, int, vsize_t));
boolean_t uvm_map_checkprot __P((vm_map_t, vaddr_t,
vaddr_t, vm_prot_t));
diff -r 04dd52f13fa5 -r 7403be6e087c sys/uvm/uvm_map.c
--- a/sys/uvm/uvm_map.c Sat Jul 17 20:02:48 1999 +0000
+++ b/sys/uvm/uvm_map.c Sat Jul 17 21:35:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_map.c,v 1.63 1999/07/07 21:51:35 thorpej Exp $ */
+/* $NetBSD: uvm_map.c,v 1.64 1999/07/17 21:35:49 thorpej Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -1918,10 +1918,11 @@
*/
int
-uvm_map_pageable(map, start, end, new_pageable, islocked)
+uvm_map_pageable(map, start, end, new_pageable, lockflags)
vm_map_t map;
vaddr_t start, end;
- boolean_t new_pageable, islocked;
+ boolean_t new_pageable;
+ int lockflags;
{
vm_map_entry_t entry, start_entry, failed_entry;
int rv;
@@ -1937,8 +1938,9 @@
panic("uvm_map_pageable: map %p not pageable", map);
#endif
- if (islocked == FALSE)
+ if ((lockflags & UVM_LK_ENTER) == 0)
vm_map_lock(map);
+
VM_MAP_RANGE_CHECK(map, start, end);
/*
@@ -1950,7 +1952,8 @@
*/
if (uvm_map_lookup_entry(map, start, &start_entry) == FALSE) {
- vm_map_unlock(map);
+ if ((lockflags & UVM_LK_EXIT) == 0)
+ vm_map_unlock(map);
UVMHIST_LOG(maphist,"<- done (INVALID ARG)",0,0,0,0);
return (KERN_INVALID_ADDRESS);
@@ -1972,7 +1975,8 @@
(entry->end < end &&
(entry->next == &map->header ||
entry->next->start > entry->end))) {
- vm_map_unlock(map);
+ if ((lockflags & UVM_LK_EXIT) == 0)
+ vm_map_unlock(map);
UVMHIST_LOG(maphist,
"<- done (INVALID UNWIRE ARG)",0,0,0,0);
return (KERN_INVALID_ARGUMENT);
@@ -1992,7 +1996,8 @@
uvm_map_entry_unwire(map, entry);
entry = entry->next;
}
- vm_map_unlock(map);
+ if ((lockflags & UVM_LK_EXIT) == 0)
+ vm_map_unlock(map);
UVMHIST_LOG(maphist,"<- done (OK UNWIRE)",0,0,0,0);
return(KERN_SUCCESS);
@@ -2060,7 +2065,8 @@
entry->wired_count--;
entry = entry->prev;
}
- vm_map_unlock(map);
+ if ((lockflags & UVM_LK_EXIT) == 0)
+ vm_map_unlock(map);
UVMHIST_LOG(maphist,"<- done (INVALID WIRE)",0,0,0,0);
return (KERN_INVALID_ARGUMENT);
}
@@ -2128,15 +2134,24 @@
uvm_map_entry_unwire(map, entry);
entry = entry->next;
}
- vm_map_unlock(map);
+ if ((lockflags & UVM_LK_EXIT) == 0)
+ vm_map_unlock(map);
UVMHIST_LOG(maphist, "<- done (RV=%d)", rv,0,0,0);
return(rv);
}
/* We are holding a read lock here. */
- vm_map_unbusy(map);
- vm_map_unlock_read(map);
-
+ if ((lockflags & UVM_LK_EXIT) == 0) {
+ vm_map_unbusy(map);
+ vm_map_unlock_read(map);
+ } else {
+ /*
+ * Get back to an exclusive (write) lock.
+ */
+ vm_map_upgrade(map);
+ vm_map_unbusy(map);
+ }
+
UVMHIST_LOG(maphist,"<- done (OK WIRE)",0,0,0,0);
return(KERN_SUCCESS);
}
diff -r 04dd52f13fa5 -r 7403be6e087c sys/uvm/uvm_mmap.c
--- a/sys/uvm/uvm_mmap.c Sat Jul 17 20:02:48 1999 +0000
+++ b/sys/uvm/uvm_mmap.c Sat Jul 17 21:35:49 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_mmap.c,v 1.34 1999/07/14 21:06:30 thorpej Exp $ */
+/* $NetBSD: uvm_mmap.c,v 1.35 1999/07/17 21:35:50 thorpej Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -981,7 +981,7 @@
#endif
error = uvm_map_pageable(&p->p_vmspace->vm_map, addr, addr+size, FALSE,
- FALSE);
+ 0);
return (error == KERN_SUCCESS ? 0 : ENOMEM);
}
@@ -1028,7 +1028,7 @@
#endif
error = uvm_map_pageable(&p->p_vmspace->vm_map, addr, addr+size, TRUE,
- FALSE);
+ 0);
return (error == KERN_SUCCESS ? 0 : ENOMEM);
}
@@ -1260,7 +1260,7 @@
goto bad;
}
retval = uvm_map_pageable(map, *addr, *addr + size,
- FALSE, TRUE);
+ FALSE, UVM_LK_ENTER);
if (retval != KERN_SUCCESS) {
/* unmap the region! */
(void) uvm_unmap(map, *addr, *addr + size);
Home |
Main Index |
Thread Index |
Old Index