git: 5abba9619cbb - stable/13 - vm_map: Add a macro to fetch a map entry's split boundary index

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 09 Aug 2023 20:57:09 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=5abba9619cbb6f1cdd598d6eaa80ebd1947fa7f5

commit 5abba9619cbb6f1cdd598d6eaa80ebd1947fa7f5
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-05-09 14:07:15 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-08-09 20:48:18 +0000

    vm_map: Add a macro to fetch a map entry's split boundary index
    
    The resulting code is a bit more concise.  No functional change
    intended.
    
    Reviewed by:    alc, dougm, kib
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D41249
    
    (cherry picked from commit d0e4e53ebd6499d420c19426586eeeafec157150)
---
 sys/vm/vm_fault.c |  3 +--
 sys/vm/vm_map.c   | 13 ++++---------
 sys/vm/vm_map.h   |  4 +++-
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index 51fb51f69f3d..86ffd8d141b6 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -486,8 +486,7 @@ vm_fault_populate(struct faultstate *fs)
 	MPASS(pager_last < fs->first_object->size);
 
 	vm_fault_restore_map_lock(fs);
-	bdry_idx = (fs->entry->eflags & MAP_ENTRY_SPLIT_BOUNDARY_MASK) >>
-	    MAP_ENTRY_SPLIT_BOUNDARY_SHIFT;
+	bdry_idx = MAP_ENTRY_SPLIT_BOUNDARY_INDEX(fs->entry);
 	if (fs->map->timestamp != fs->map_generation) {
 		if (bdry_idx == 0) {
 			vm_fault_populate_cleanup(fs->first_object, pager_first,
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index ce520de160ef..c2b7dd81d3ca 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -2445,8 +2445,7 @@ vm_map_clip_start(vm_map_t map, vm_map_entry_t entry, vm_offset_t startaddr)
 	KASSERT(entry->end > startaddr && entry->start < startaddr,
 	    ("%s: invalid clip of entry %p", __func__, entry));
 
-	bdry_idx = (entry->eflags & MAP_ENTRY_SPLIT_BOUNDARY_MASK) >>
-	    MAP_ENTRY_SPLIT_BOUNDARY_SHIFT;
+	bdry_idx = MAP_ENTRY_SPLIT_BOUNDARY_INDEX(entry);
 	if (bdry_idx != 0) {
 		if ((startaddr & (pagesizes[bdry_idx] - 1)) != 0)
 			return (KERN_INVALID_ARGUMENT);
@@ -2519,8 +2518,7 @@ vm_map_clip_end(vm_map_t map, vm_map_entry_t entry, vm_offset_t endaddr)
 	KASSERT(entry->start < endaddr && entry->end > endaddr,
 	    ("%s: invalid clip of entry %p", __func__, entry));
 
-	bdry_idx = (entry->eflags & MAP_ENTRY_SPLIT_BOUNDARY_MASK) >>
-	    MAP_ENTRY_SPLIT_BOUNDARY_SHIFT;
+	bdry_idx = MAP_ENTRY_SPLIT_BOUNDARY_INDEX(entry);
 	if (bdry_idx != 0) {
 		if ((endaddr & (pagesizes[bdry_idx] - 1)) != 0)
 			return (KERN_INVALID_ARGUMENT);
@@ -3513,8 +3511,7 @@ vm_map_wire_locked(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags)
 			saved_start = entry->start;
 			saved_end = entry->end;
 			last_timestamp = map->timestamp;
-			bidx = (entry->eflags & MAP_ENTRY_SPLIT_BOUNDARY_MASK)
-			    >> MAP_ENTRY_SPLIT_BOUNDARY_SHIFT;
+			bidx = MAP_ENTRY_SPLIT_BOUNDARY_INDEX(entry);
 			incr =  pagesizes[bidx];
 			vm_map_busy(map);
 			vm_map_unlock(map);
@@ -3712,9 +3709,7 @@ vm_map_sync(
 				vm_map_unlock_read(map);
 				return (KERN_INVALID_ARGUMENT);
 			}
-			bdry_idx = (entry->eflags &
-			    MAP_ENTRY_SPLIT_BOUNDARY_MASK) >>
-			    MAP_ENTRY_SPLIT_BOUNDARY_SHIFT;
+			bdry_idx = MAP_ENTRY_SPLIT_BOUNDARY_INDEX(entry);
 			if (bdry_idx != 0 &&
 			    ((start & (pagesizes[bdry_idx] - 1)) != 0 ||
 			    (end & (pagesizes[bdry_idx] - 1)) != 0)) {
diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h
index 8f318b34e601..7854a91f36a9 100644
--- a/sys/vm/vm_map.h
+++ b/sys/vm/vm_map.h
@@ -150,8 +150,10 @@ struct vm_map_entry {
 #define	MAP_ENTRY_HEADER		0x00080000
 
 #define	MAP_ENTRY_SPLIT_BOUNDARY_MASK	0x00300000
-
 #define	MAP_ENTRY_SPLIT_BOUNDARY_SHIFT	20
+#define	MAP_ENTRY_SPLIT_BOUNDARY_INDEX(entry)			\
+	(((entry)->eflags & MAP_ENTRY_SPLIT_BOUNDARY_MASK) >>	\
+	    MAP_ENTRY_SPLIT_BOUNDARY_SHIFT)
 
 #ifdef	_KERNEL
 static __inline u_char