diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 4ac100a6e033..56d197a45f05 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1268,8 +1268,6 @@ vm_map_madvise( vm_map_entry_t current, entry; int modify_map = 0; - GIANT_REQUIRED; - /* * Some madvise calls directly modify the vm_map_entry, in which case * we need to use an exclusive lock on the map and we need to perform @@ -1390,6 +1388,7 @@ vm_map_madvise( vm_object_madvise(current->object.vm_object, pindex, count, behav); if (behav == MADV_WILLNEED) { + mtx_lock(&Giant); pmap_object_init_pt( map->pmap, useStart, @@ -1398,6 +1397,7 @@ vm_map_madvise( (count << PAGE_SHIFT), MAP_PREFAULT_MADVISE ); + mtx_unlock(&Giant); } } vm_map_unlock_read(map); diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index d2d2851be50d..fca62e754098 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -743,7 +743,6 @@ madvise(td, uap) struct madvise_args *uap; { vm_offset_t start, end; - int ret; /* * Check for illegal behavior @@ -771,10 +770,10 @@ madvise(td, uap) start = trunc_page((vm_offset_t) uap->addr); end = round_page((vm_offset_t) uap->addr + uap->len); - mtx_lock(&Giant); - ret = vm_map_madvise(&td->td_proc->p_vmspace->vm_map, start, end, uap->behav); - mtx_unlock(&Giant); - return (ret ? EINVAL : 0); + if (vm_map_madvise(&td->td_proc->p_vmspace->vm_map, start, end, + uap->behav)) + return (EINVAL); + return (0); } #ifndef _SYS_SYSPROTO_H_ diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 0db982ec9bc6..373b16bb0e9f 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1002,10 +1002,11 @@ vm_object_madvise(vm_object_t object, vm_pindex_t pindex, int count, int advise) vm_object_t tobject; vm_page_t m; - GIANT_REQUIRED; if (object == NULL) return; + mtx_lock(&Giant); + end = pindex + count; /* @@ -1093,6 +1094,7 @@ vm_object_madvise(vm_object_t object, vm_pindex_t pindex, int count, int advise) swap_pager_freespace(tobject, tpindex, 1); } } + mtx_unlock(&Giant); } /*