From owner-svn-src-all@freebsd.org Thu Jul 4 19:12:14 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 74A4115DC145; Thu, 4 Jul 2019 19:12:14 +0000 (UTC) (envelope-from dougm@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1914E6E2AD; Thu, 4 Jul 2019 19:12:14 +0000 (UTC) (envelope-from dougm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DA0D327391; Thu, 4 Jul 2019 19:12:13 +0000 (UTC) (envelope-from dougm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x64JCDRg016917; Thu, 4 Jul 2019 19:12:13 GMT (envelope-from dougm@FreeBSD.org) Received: (from dougm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x64JCDQf016916; Thu, 4 Jul 2019 19:12:13 GMT (envelope-from dougm@FreeBSD.org) Message-Id: <201907041912.x64JCDQf016916@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dougm set sender to dougm@FreeBSD.org using -f From: Doug Moore Date: Thu, 4 Jul 2019 19:12:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r349743 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: dougm X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 349743 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1914E6E2AD X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jul 2019 19:12:14 -0000 Author: dougm Date: Thu Jul 4 19:12:13 2019 New Revision: 349743 URL: https://svnweb.freebsd.org/changeset/base/349743 Log: Change boolean_t variables in vm_map_unwire and vm_map_wire_locked to bool. Drop result variable. Add holes_ok bool to replace repeated masking of flags parameter. Approved by: markj (mentor) Differential Revision: https://reviews.freebsd.org/D20846 Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Thu Jul 4 19:02:03 2019 (r349742) +++ head/sys/vm/vm_map.c Thu Jul 4 19:12:13 2019 (r349743) @@ -2849,15 +2849,16 @@ vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offs vm_offset_t saved_start; unsigned int last_timestamp; int rv; - boolean_t need_wakeup, result, user_unwire; + bool holes_ok, need_wakeup, user_unwire; if (start == end) return (KERN_SUCCESS); - user_unwire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE; + holes_ok = (flags & VM_MAP_WIRE_HOLESOK) != 0; + user_unwire = (flags & VM_MAP_WIRE_USER) != 0; vm_map_lock(map); VM_MAP_RANGE_CHECK(map, start, end); if (!vm_map_lookup_entry(map, start, &first_entry)) { - if (flags & VM_MAP_WIRE_HOLESOK) + if (holes_ok) first_entry = first_entry->next; else { vm_map_unlock(map); @@ -2889,7 +2890,7 @@ vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offs */ if (!vm_map_lookup_entry(map, saved_start, &tmp_entry)) { - if (flags & VM_MAP_WIRE_HOLESOK) + if (holes_ok) tmp_entry = tmp_entry->next; else { if (saved_start == start) { @@ -2926,9 +2927,9 @@ vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offs entry->wiring_thread = curthread; /* * Check the map for holes in the specified region. - * If VM_MAP_WIRE_HOLESOK was specified, skip this check. + * If holes_ok, skip this check. */ - if (((flags & VM_MAP_WIRE_HOLESOK) == 0) && + if (!holes_ok && (entry->end < end && entry->next->start > entry->end)) { end = entry->end; rv = KERN_INVALID_ADDRESS; @@ -2947,17 +2948,15 @@ vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offs } rv = KERN_SUCCESS; done: - need_wakeup = FALSE; - if (first_entry == NULL) { - result = vm_map_lookup_entry(map, start, &first_entry); - if (!result && (flags & VM_MAP_WIRE_HOLESOK)) - first_entry = first_entry->next; - else - KASSERT(result, ("vm_map_unwire: lookup failed")); + need_wakeup = false; + if (first_entry == NULL && + !vm_map_lookup_entry(map, start, &first_entry)) { + KASSERT(holes_ok, ("vm_map_unwire: lookup failed")); + first_entry = first_entry->next; } for (entry = first_entry; entry->start < end; entry = entry->next) { /* - * If VM_MAP_WIRE_HOLESOK was specified, an empty + * If holes_ok was specified, an empty * space in the unwired region could have been mapped * while the map lock was dropped for draining * MAP_ENTRY_IN_TRANSITION. Moreover, another thread @@ -2967,7 +2966,7 @@ done: */ if ((entry->eflags & MAP_ENTRY_IN_TRANSITION) == 0 || entry->wiring_thread != curthread) { - KASSERT((flags & VM_MAP_WIRE_HOLESOK) != 0, + KASSERT(holes_ok, ("vm_map_unwire: !HOLESOK and new/changed entry")); continue; } @@ -2989,7 +2988,7 @@ done: entry->wiring_thread = NULL; if (entry->eflags & MAP_ENTRY_NEEDS_WAKEUP) { entry->eflags &= ~MAP_ENTRY_NEEDS_WAKEUP; - need_wakeup = TRUE; + need_wakeup = true; } vm_map_simplify_entry(map, entry); } @@ -3083,7 +3082,7 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm u_long npages; u_int last_timestamp; int rv; - boolean_t need_wakeup, result, user_wire; + bool holes_ok, need_wakeup, user_wire; vm_prot_t prot; VM_MAP_ASSERT_LOCKED(map); @@ -3093,10 +3092,11 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm prot = 0; if (flags & VM_MAP_WIRE_WRITE) prot |= VM_PROT_WRITE; - user_wire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE; + holes_ok = (flags & VM_MAP_WIRE_HOLESOK) != 0; + user_wire = (flags & VM_MAP_WIRE_USER) != 0; VM_MAP_RANGE_CHECK(map, start, end); if (!vm_map_lookup_entry(map, start, &first_entry)) { - if (flags & VM_MAP_WIRE_HOLESOK) + if (holes_ok) first_entry = first_entry->next; else return (KERN_INVALID_ADDRESS); @@ -3126,7 +3126,7 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm */ if (!vm_map_lookup_entry(map, saved_start, &tmp_entry)) { - if (flags & VM_MAP_WIRE_HOLESOK) + if (holes_ok) tmp_entry = tmp_entry->next; else { if (saved_start == start) { @@ -3163,7 +3163,7 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm if ((entry->protection & (VM_PROT_READ | VM_PROT_EXECUTE)) == 0 || (entry->protection & prot) != prot) { entry->eflags |= MAP_ENTRY_WIRE_SKIPPED; - if ((flags & VM_MAP_WIRE_HOLESOK) == 0) { + if (!holes_ok) { end = entry->end; rv = KERN_INVALID_ADDRESS; goto done; @@ -3208,9 +3208,10 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm * may have been clipped, but NOT merged or * deleted. */ - result = vm_map_lookup_entry(map, saved_start, - &tmp_entry); - KASSERT(result, ("vm_map_wire: lookup failed")); + if (!vm_map_lookup_entry(map, saved_start, + &tmp_entry)) + KASSERT(false, + ("vm_map_wire: lookup failed")); if (entry == first_entry) first_entry = tmp_entry; else @@ -3244,9 +3245,9 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm } /* * Check the map for holes in the specified region. - * If VM_MAP_WIRE_HOLESOK was specified, skip this check. + * If holes_ok was specified, skip this check. */ - if ((flags & VM_MAP_WIRE_HOLESOK) == 0 && + if (!holes_ok && entry->end < end && entry->next->start > entry->end) { end = entry->end; rv = KERN_INVALID_ADDRESS; @@ -3256,17 +3257,15 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm } rv = KERN_SUCCESS; done: - need_wakeup = FALSE; - if (first_entry == NULL) { - result = vm_map_lookup_entry(map, start, &first_entry); - if (!result && (flags & VM_MAP_WIRE_HOLESOK)) - first_entry = first_entry->next; - else - KASSERT(result, ("vm_map_wire: lookup failed")); + need_wakeup = false; + if (first_entry == NULL && + !vm_map_lookup_entry(map, start, &first_entry)) { + KASSERT(holes_ok, ("vm_map_wire: lookup failed")); + first_entry = first_entry->next; } for (entry = first_entry; entry->start < end; entry = entry->next) { /* - * If VM_MAP_WIRE_HOLESOK was specified, an empty + * If holes_ok was specified, an empty * space in the unwired region could have been mapped * while the map lock was dropped for faulting in the * pages or draining MAP_ENTRY_IN_TRANSITION. @@ -3276,7 +3275,7 @@ done: */ if ((entry->eflags & MAP_ENTRY_IN_TRANSITION) == 0 || entry->wiring_thread != curthread) { - KASSERT((flags & VM_MAP_WIRE_HOLESOK) != 0, + KASSERT(holes_ok, ("vm_map_wire: !HOLESOK and new/changed entry")); continue; } @@ -3317,7 +3316,7 @@ done: entry->wiring_thread = NULL; if (entry->eflags & MAP_ENTRY_NEEDS_WAKEUP) { entry->eflags &= ~MAP_ENTRY_NEEDS_WAKEUP; - need_wakeup = TRUE; + need_wakeup = true; } vm_map_simplify_entry(map, entry); }