From nobody Fri Sep 20 06:46:46 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X92x23bFMz5Wj25; Fri, 20 Sep 2024 06:46:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X92x2327mz4r41; Fri, 20 Sep 2024 06:46:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726814806; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YO5Y2vhqsqmndQYMT0MDZN9ahawY3AUUpwRXbw+sRuI=; b=wmLcVlMAR8J7xI4wTYgEAkSXsWaNqFNXCm4On/a05TKhI2EfsMY7LtQZKXc7syt8NEgO3/ 2OQrbmDGcVvcWFuGeFL+viwfQJ6ZLWHMc1DAmDtMA5niug+35y5KyXLMhNnwNdHQy/Q78v VLA+FjCt7+jb2jYotMXY8jvHUVa1/ekrZqGWeL6Q8Y/bCP8py5Okj/JgVosn18N6M9/0kL U9+OW0r2wfyHOq8sas7OUnlf/shupu5e+V9rHMyVJQBtoXBPntPBwX3vmPWhDx99tW3v8r qkn68pAQtgLc6bMRstSr7cPvgyHfbP0LwZZ9kj7SZQniH/GS/b2x0jSbk81JHg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726814806; a=rsa-sha256; cv=none; b=XFcQF6EDjWxOgSrvZrat8fLc+5Xsyqz+rm6gNdTloXLwSbO8QJsdzJqsTJVFXL3wtrd/eN cy5sYk/z9pJ+TSjTlvzi/EnzLy7Dgt92g+RaMhlvqsApSrR9NO2Stla6alf5XcoRw9fPD6 hW4K/0SugQB44Di1U3Ge8MhqnTwBfOEhY1rmjd8ztbq3mJf14JpaXz+9igxEjbLFRrkTaT rKBOp7Tbp+hiEjinP7dft//kI3slLdUlG7l5B6qUoeRhEFwAU5O5Cj3n57rWM/5U7XS/Gh tEKYwWyDihtqCtcFxojLOGYMisaW3Rqx7JTddddd0vIH+gv4WOYtHRJwH2njqA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726814806; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YO5Y2vhqsqmndQYMT0MDZN9ahawY3AUUpwRXbw+sRuI=; b=oNnn3pQpxvdRwFghql9LKNlCXhRgQhw1e1NmcpPaabWwM+ZpR3U+RzYyPKxB0NLKQOBrsK GCtnCz4yrsO98ngZt2QZll12E5Haq44jSsmqaA6ViE6++h7aznfh4fmdx8vIcnU2xI7QyM q6j3sPGc1AOnrRwt+GHRbeSS2vXZaMMvOv1vt7F7hQ8bJi7dJEKBNaJFRnmhfhtfLKTDDg AUPXOvPeadnDlpsa5vzAN3RTr74bjVftKD+XcHwKzxFX3gEUaYWXJL6BtMLNxKTgpOA47c V7OxGPGx4eiHU4mhHhZZy/o6/loYX4OsPqzTB1M9GKg3UAx75/6pArJfQvOr+w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4X92x22VvyzdV1; Fri, 20 Sep 2024 06:46:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48K6kkUO009407; Fri, 20 Sep 2024 06:46:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48K6kkXv009404; Fri, 20 Sep 2024 06:46:46 GMT (envelope-from git) Date: Fri, 20 Sep 2024 06:46:46 GMT Message-Id: <202409200646.48K6kkXv009404@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 0ecbb28ce351 - main - vm_map: add vm_map_find_locked(9) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0ecbb28ce351652b3a2dae271eedf1eb3aa65400 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0ecbb28ce351652b3a2dae271eedf1eb3aa65400 commit 0ecbb28ce351652b3a2dae271eedf1eb3aa65400 Author: Konstantin Belousov AuthorDate: 2024-09-15 06:29:28 +0000 Commit: Konstantin Belousov CommitDate: 2024-09-20 06:46:06 +0000 vm_map: add vm_map_find_locked(9) Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D46678 --- sys/vm/vm_map.c | 39 ++++++++++++++++++++++++--------------- sys/vm/vm_map.h | 2 ++ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 77297a0e3957..3d82f0835c09 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -2117,9 +2117,24 @@ vm_map_find_aligned(vm_map_t map, vm_offset_t *addr, vm_size_t length, */ int vm_map_find(vm_map_t map, vm_object_t object, vm_ooffset_t offset, - vm_offset_t *addr, /* IN/OUT */ - vm_size_t length, vm_offset_t max_addr, int find_space, - vm_prot_t prot, vm_prot_t max, int cow) + vm_offset_t *addr, /* IN/OUT */ + vm_size_t length, vm_offset_t max_addr, int find_space, + vm_prot_t prot, vm_prot_t max, int cow) +{ + int rv; + + vm_map_lock(map); + rv = vm_map_find_locked(map, object, offset, addr, length, max_addr, + find_space, prot, max, cow); + vm_map_unlock(map); + return (rv); +} + +int +vm_map_find_locked(vm_map_t map, vm_object_t object, vm_ooffset_t offset, + vm_offset_t *addr, /* IN/OUT */ + vm_size_t length, vm_offset_t max_addr, int find_space, + vm_prot_t prot, vm_prot_t max, int cow) { vm_offset_t alignment, curr_min_addr, min_addr; int gap, pidx, rv, try; @@ -2127,7 +2142,7 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffset_t offset, KASSERT((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) == 0 || object == NULL, - ("vm_map_find: non-NULL backing object for stack")); + ("non-NULL backing object for stack")); MPASS((cow & MAP_REMAP) == 0 || (find_space == VMFS_NO_SPACE && (cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) == 0)); if (find_space == VMFS_OPTIMAL_SPACE && (object == NULL || @@ -2150,7 +2165,6 @@ vm_map_find(vm_map_t map, vm_object_t object, vm_ooffset_t offset, (map->flags & MAP_ASLR_IGNSTART) != 0) curr_min_addr = min_addr = vm_map_min(map); try = 0; - vm_map_lock(map); if (cluster) { curr_min_addr = map->anon_loc; if (curr_min_addr == 0) @@ -2235,8 +2249,7 @@ again: MPASS(try == 1); goto again; } - rv = KERN_NO_SPACE; - goto done; + return (KERN_NO_SPACE); } } @@ -2250,16 +2263,14 @@ again: try = 0; goto again; } - goto done; + return (rv); } } else if ((cow & MAP_REMAP) != 0) { - if (!vm_map_range_valid(map, *addr, *addr + length)) { - rv = KERN_INVALID_ADDRESS; - goto done; - } + if (!vm_map_range_valid(map, *addr, *addr + length)) + return (KERN_INVALID_ADDRESS); rv = vm_map_delete(map, *addr, *addr + length); if (rv != KERN_SUCCESS) - goto done; + return (rv); } if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) { rv = vm_map_stack_locked(map, *addr, length, sgrowsiz, prot, @@ -2277,8 +2288,6 @@ again: if (update_anon && rv == KERN_SUCCESS && (map->anon_loc == 0 || *addr < map->anon_loc)) map->anon_loc = *addr; -done: - vm_map_unlock(map); return (rv); } diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 1862ad48c442..a226f9adaa9a 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -473,6 +473,8 @@ boolean_t vm_map_check_protection (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t int vm_map_delete(vm_map_t, vm_offset_t, vm_offset_t); int vm_map_find(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t, vm_offset_t, int, vm_prot_t, vm_prot_t, int); +int vm_map_find_locked(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, + vm_size_t, vm_offset_t, int, vm_prot_t, vm_prot_t, int); int vm_map_find_min(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t, vm_offset_t, vm_offset_t, int, vm_prot_t, vm_prot_t, int); int vm_map_find_aligned(vm_map_t map, vm_offset_t *addr, vm_size_t length,