On 08/11/19(Fri) 17:54, Martin Pieuchot wrote:
> uvm_mapanon() is called in two occasions: mmap(2) and sigaltstack(2).
> Both code paths are obviously in process context an can sleep. That
> explains why none of them set the UVM_FLAG_TRYLOCK when calling such
> function.
>
> The diff below removes support for this flag. This introduces a
> difference with uvm_map(9) but simplifies the overall code. Removing
> support for an unneeded "try" variant also means the lock can be grabbed
> earlier. This is a requirement to not lose atomicity between
> uvm_mapanon() and uvm_map_pageable() in mmap(2).
Anyone?
> Index: uvm/uvm_map.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_map.c,v
> retrieving revision 1.250
> diff -u -p -r1.250 uvm_map.c
> --- uvm/uvm_map.c 2 Nov 2019 16:41:57 -0000 1.250
> +++ uvm/uvm_map.c 8 Nov 2019 16:43:30 -0000
> @@ -951,9 +951,9 @@ uvm_mapanon(struct vm_map *map, vaddr_t
> KASSERT((map->flags & VM_MAP_ISVMSPACE) == VM_MAP_ISVMSPACE);
> KASSERT(map != kernel_map);
> KASSERT((map->flags & UVM_FLAG_HOLE) == 0);
> -
> KASSERT((map->flags & VM_MAP_INTRSAFE) == 0);
> splassert(IPL_NONE);
> + KASSERT((flags & UVM_FLAG_TRYLOCK) == 0);
>
> /*
> * We use pmap_align and pmap_offset as alignment and offset variables.
> @@ -989,14 +989,7 @@ uvm_mapanon(struct vm_map *map, vaddr_t
> if (new == NULL)
> return(ENOMEM);
>
> - if (flags & UVM_FLAG_TRYLOCK) {
> - if (vm_map_lock_try(map) == FALSE) {
> - error = EFAULT;
> - goto out;
> - }
> - } else
> - vm_map_lock(map);
> -
> + vm_map_lock(map);
> first = last = NULL;
> if (flags & UVM_FLAG_FIXED) {
> /*
> @@ -1114,7 +1107,7 @@ unlock:
> * destroy free-space entries.
> */
> uvm_unmap_detach(&dead, 0);
> -out:
> +
> if (new)
> uvm_mapent_free(new);
> return error;
>