> Date: Thu, 10 Feb 2022 10:19:20 +0000
> From: Klemens Nanni <[email protected]>
>
> On Mon, Feb 07, 2022 at 02:12:52PM +0100, Mark Kettenis wrote:
> > > Date: Mon, 7 Feb 2022 12:11:42 +0000
> > > From: Klemens Nanni <[email protected]>
> > >
> > > On Mon, Feb 07, 2022 at 12:41:27PM +0100, Mark Kettenis wrote:
>
> > > > So there is the existing UVM_MAP_REQ_WRITE(). Compared to
> > > > vm_map_assert_wrlock() it checks the reference count of the map. I
> > > > think that's questionable, so these should probably be replaced by
> > > > vm_map_assert_wrlock().
> > >
> > > Yes, I'd replace the old macro with the new functions in a separate diff.
> >
> > Fair enough. This has been tested extensively and it doesn't make a
> > lot of sense to start all over again.
>
> Here's the replacement diff.
>
> OK?
If this survives a make build, I think this should be safe.
ok kettenis@
> Index: uvm_map.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_map.c,v
> retrieving revision 1.282
> diff -u -p -r1.282 uvm_map.c
> --- uvm_map.c 21 Dec 2021 22:21:32 -0000 1.282
> +++ uvm_map.c 10 Feb 2022 09:23:21 -0000
> @@ -326,16 +326,6 @@ vaddr_t uvm_maxkaddr;
> /*
> * Locking predicate.
> */
> -#define UVM_MAP_REQ_WRITE(_map)
> \
> - do { \
> - if ((_map)->ref_count > 0) { \
> - if (((_map)->flags & VM_MAP_INTRSAFE) == 0) \
> - rw_assert_wrlock(&(_map)->lock); \
> - else \
> - MUTEX_ASSERT_LOCKED(&(_map)->mtx); \
> - } \
> - } while (0)
> -
> #define vm_map_modflags(map, set, clear)
> \
> do { \
> mtx_enter(&(map)->flags_lock); \
> @@ -407,7 +397,7 @@ uvm_mapent_free_insert(struct vm_map *ma
> KDASSERT((entry->fspace & (vaddr_t)PAGE_MASK) == 0);
> KASSERT((entry->etype & UVM_ET_FREEMAPPED) == 0);
>
> - UVM_MAP_REQ_WRITE(map);
> + vm_map_assert_wrlock(map);
>
> /* Actual insert: forward to uaddr pointer. */
> if (uaddr != NULL) {
> @@ -433,7 +423,7 @@ uvm_mapent_free_remove(struct vm_map *ma
>
> KASSERT((entry->etype & UVM_ET_FREEMAPPED) != 0 || uaddr == NULL);
> KASSERT(uvm_map_uaddr_e(map, entry) == uaddr);
> - UVM_MAP_REQ_WRITE(map);
> + vm_map_assert_wrlock(map);
>
> if (uaddr != NULL) {
> fun = uaddr->uaddr_functions;
> @@ -460,7 +450,7 @@ uvm_mapent_addr_insert(struct vm_map *ma
> TRACEPOINT(uvm, map_insert,
> entry->start, entry->end, entry->protection, NULL);
>
> - UVM_MAP_REQ_WRITE(map);
> + vm_map_assert_wrlock(map);
> res = RBT_INSERT(uvm_map_addr, &map->addr, entry);
> if (res != NULL) {
> panic("uvm_mapent_addr_insert: map %p entry %p "
> @@ -483,7 +473,7 @@ uvm_mapent_addr_remove(struct vm_map *ma
> TRACEPOINT(uvm, map_remove,
> entry->start, entry->end, entry->protection, NULL);
>
> - UVM_MAP_REQ_WRITE(map);
> + vm_map_assert_wrlock(map);
> res = RBT_REMOVE(uvm_map_addr, &map->addr, entry);
> if (res != entry)
> panic("uvm_mapent_addr_remove");
>