git: 0188344fc3ec - stable/15 - vm_fault: add vm_fault_might_be_cow() helper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 11 Oct 2025 05:08:35 UTC
The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0188344fc3ec94b55b2fa628a5339ed88c25d897 commit 0188344fc3ec94b55b2fa628a5339ed88c25d897 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2025-08-14 03:39:05 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2025-10-11 05:08:13 +0000 vm_fault: add vm_fault_might_be_cow() helper (cherry picked from commit 5bd4c04a4e7f7bda657e6027e64675d0caf50715) --- sys/vm/vm_fault.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 63a1e7ac0675..0039a8786387 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -258,6 +258,12 @@ vm_fault_unlock_vp(struct faultstate *fs) } } +static bool +vm_fault_might_be_cow(struct faultstate *fs) +{ + return (fs->object != fs->first_object); +} + static void vm_fault_deallocate(struct faultstate *fs) { @@ -265,7 +271,7 @@ vm_fault_deallocate(struct faultstate *fs) vm_fault_page_release(&fs->m_cow); vm_fault_page_release(&fs->m); vm_object_pip_wakeup(fs->object); - if (fs->object != fs->first_object) { + if (vm_fault_might_be_cow(fs)) { VM_OBJECT_WLOCK(fs->first_object); vm_fault_page_free(&fs->first_m); VM_OBJECT_WUNLOCK(fs->first_object); @@ -1002,7 +1008,7 @@ vm_fault_cow(struct faultstate *fs) { bool is_first_object_locked; - KASSERT(fs->object != fs->first_object, + KASSERT(vm_fault_might_be_cow(fs), ("source and target COW objects are identical")); /* @@ -1166,7 +1172,7 @@ vm_fault_zerofill(struct faultstate *fs) * If there's no object left, fill the page in the top * object with zeros. */ - if (fs->object != fs->first_object) { + if (vm_fault_might_be_cow(fs)) { vm_object_pip_wakeup(fs->object); fs->object = fs->first_object; fs->pindex = fs->first_pindex; @@ -1430,7 +1436,7 @@ vm_fault_busy_sleep(struct faultstate *fs, int allocflags) * likely to reclaim it. */ vm_page_aflag_set(fs->m, PGA_REFERENCED); - if (fs->object != fs->first_object) { + if (vm_fault_might_be_cow(fs)) { vm_fault_page_release(&fs->first_m); vm_object_pip_wakeup(fs->first_object); } @@ -1728,7 +1734,7 @@ found: * top-level object, we have to copy it into a new page owned by the * top-level object. */ - if (fs.object != fs.first_object) { + if (vm_fault_might_be_cow(&fs)) { /* * We only really need to copy if we want to write it. */