From 3ddafebe6cd8e34d872c44ac944df858c9838a54 Mon Sep 17 00:00:00 2001 From: mpi Date: Wed, 2 Aug 2023 09:19:47 +0000 Subject: [PATCH] Remove unused vm_map_upgrade() & vm_map_downgrade(). Upgrade/downgrade operations on a `vmmaplk' are no longer necessary since vm_map_busy() completely unlocks it (r1.318 of uvm/uvm_map.c). ok kettenis@ --- sys/uvm/uvm_map.c | 29 +---------------------------- sys/uvm/uvm_map.h | 27 ++++++--------------------- 2 files changed, 7 insertions(+), 49 deletions(-) diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 3951513654a..73467232e56 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.318 2023/05/20 12:48:36 mpi Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.319 2023/08/02 09:19:47 mpi Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -5398,33 +5398,6 @@ vm_map_unlock_read_ln(struct vm_map *map, char *file, int line) mtx_leave(&map->mtx); } -void -vm_map_downgrade_ln(struct vm_map *map, char *file, int line) -{ - uvm_tree_sanity(map, file, line); - uvm_tree_size_chk(map, file, line); - LPRINTF(("map unlock: %p (at %s %d)\n", map, file, line)); - LPRINTF(("map lock: %p (at %s %d)\n", map, file, line)); - KASSERT((map->flags & VM_MAP_INTRSAFE) == 0); - if ((map->flags & VM_MAP_INTRSAFE) == 0) - rw_enter(&map->lock, RW_DOWNGRADE); -} - -void -vm_map_upgrade_ln(struct vm_map *map, char *file, int line) -{ - /* XXX: RO */ uvm_tree_sanity(map, file, line); - /* XXX: RO */ uvm_tree_size_chk(map, file, line); - LPRINTF(("map unlock: %p (at %s %d)\n", map, file, line)); - KASSERT((map->flags & VM_MAP_INTRSAFE) == 0); - if ((map->flags & VM_MAP_INTRSAFE) == 0) { - rw_exit_read(&map->lock); - rw_enter_write(&map->lock); - } - LPRINTF(("map lock: %p (at %s %d)\n", map, file, line)); - uvm_tree_sanity(map, file, line); -} - void vm_map_busy_ln(struct vm_map *map, char *file, int line) { diff --git a/sys/uvm/uvm_map.h b/sys/uvm/uvm_map.h index 935333a2331..6f7d540278e 100644 --- a/sys/uvm/uvm_map.h +++ b/sys/uvm/uvm_map.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.h,v 1.86 2023/05/20 12:48:36 mpi Exp $ */ +/* $OpenBSD: uvm_map.h,v 1.87 2023/08/02 09:19:47 mpi Exp $ */ /* $NetBSD: uvm_map.h,v 1.24 2001/02/18 21:19:08 chs Exp $ */ /* @@ -189,20 +189,15 @@ RBT_PROTOTYPE(uvm_map_addr, vm_map_entry, daddrs.addr_entry, * * VM map locking is a little complicated. There are both shared * and exclusive locks on maps. However, it is sometimes required - * to downgrade an exclusive lock to a shared lock, and upgrade to - * an exclusive lock again (to perform error recovery). However, - * another thread *must not* queue itself to receive an exclusive - * lock while before we upgrade back to exclusive, otherwise the - * error recovery becomes extremely difficult, if not impossible. + * to unlock a VM map (to prevent lock ordering issues) without + * allowing any other thread to modify it. * * In order to prevent this scenario, we introduce the notion of - * a `busy' map. A `busy' map is read-locked, but other threads + * a `busy' map. A `busy' map is unlocked, but other threads * attempting to write-lock wait for this flag to clear before * entering the lock manager. A map may only be marked busy - * when the map is write-locked (and then the map must be downgraded - * to read-locked), and may only be marked unbusy by the thread - * which marked it busy (holding *either* a read-lock or a - * write-lock, the latter being gained by an upgrade). + * when the map is write-locked and may only be marked unbusy by + * the thread which marked it busy. * * Access to the map `flags' member is controlled by the `flags_lock' * simple lock. Note that some flags are static (set once at map @@ -414,10 +409,6 @@ int uvm_map_fill_vmmap(struct vm_map *, struct kinfo_vmentry *, * * vm_map_unlock_read: release a shared lock on a map. * - * vm_map_downgrade: downgrade an exclusive lock to a shared lock. - * - * vm_map_upgrade: upgrade a shared lock to an exclusive lock. - * * vm_map_busy: mark a map as busy. * * vm_map_unbusy: clear busy status on a map. @@ -429,8 +420,6 @@ void vm_map_lock_ln(struct vm_map*, char*, int); void vm_map_lock_read_ln(struct vm_map*, char*, int); void vm_map_unlock_ln(struct vm_map*, char*, int); void vm_map_unlock_read_ln(struct vm_map*, char*, int); -void vm_map_downgrade_ln(struct vm_map*, char*, int); -void vm_map_upgrade_ln(struct vm_map*, char*, int); void vm_map_busy_ln(struct vm_map*, char*, int); void vm_map_unbusy_ln(struct vm_map*, char*, int); void vm_map_assert_anylock_ln(struct vm_map*, char*, int); @@ -442,8 +431,6 @@ void vm_map_assert_wrlock_ln(struct vm_map*, char*, int); #define vm_map_lock_read(map) vm_map_lock_read_ln(map, __FILE__, __LINE__) #define vm_map_unlock(map) vm_map_unlock_ln(map, __FILE__, __LINE__) #define vm_map_unlock_read(map) vm_map_unlock_read_ln(map, __FILE__, __LINE__) -#define vm_map_downgrade(map) vm_map_downgrade_ln(map, __FILE__, __LINE__) -#define vm_map_upgrade(map) vm_map_upgrade_ln(map, __FILE__, __LINE__) #define vm_map_busy(map) vm_map_busy_ln(map, __FILE__, __LINE__) #define vm_map_unbusy(map) vm_map_unbusy_ln(map, __FILE__, __LINE__) #define vm_map_assert_anylock(map) \ @@ -456,8 +443,6 @@ void vm_map_assert_wrlock_ln(struct vm_map*, char*, int); #define vm_map_lock_read(map) vm_map_lock_read_ln(map, NULL, 0) #define vm_map_unlock(map) vm_map_unlock_ln(map, NULL, 0) #define vm_map_unlock_read(map) vm_map_unlock_read_ln(map, NULL, 0) -#define vm_map_downgrade(map) vm_map_downgrade_ln(map, NULL, 0) -#define vm_map_upgrade(map) vm_map_upgrade_ln(map, NULL, 0) #define vm_map_busy(map) vm_map_busy_ln(map, NULL, 0) #define vm_map_unbusy(map) vm_map_unbusy_ln(map, NULL, 0) #define vm_map_assert_anylock(map) vm_map_assert_anylock_ln(map, NULL, 0) -- 2.20.1