svn commit: r292406 - head/sys/vm
Conrad E. Meyer
cem at FreeBSD.org
Thu Dec 17 17:48:59 UTC 2015
Author: cem
Date: Thu Dec 17 17:48:57 2015
New Revision: 292406
URL: https://svnweb.freebsd.org/changeset/base/292406
Log:
vm_page_replace: add wrapper to KASSERT about old page
It turns out the callers of vm_page_replace know exactly which page they are
replacing and would like to assert about it. Change those from hard panics to
KASSERTs, and provide them with a wrapper so they don't have to deal with
warnings from an INVARIANTS-dependent dead store of the return value of
vm_page_replace.
Submitted by: Ryan Libby <rlibby at gmail.com>
Reviewed by: alc, kib (earlier version)
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D4497
Modified:
head/sys/vm/device_pager.c
head/sys/vm/sg_pager.c
head/sys/vm/vm_page.h
Modified: head/sys/vm/device_pager.c
==============================================================================
--- head/sys/vm/device_pager.c Thu Dec 17 17:00:04 2015 (r292405)
+++ head/sys/vm/device_pager.c Thu Dec 17 17:48:57 2015 (r292406)
@@ -347,8 +347,7 @@ old_dev_pager_fault(vm_object_t object,
*/
page = vm_page_getfake(paddr, memattr);
VM_OBJECT_WLOCK(object);
- if (vm_page_replace(page, object, (*mres)->pindex) != *mres)
- panic("old_dev_pager_fault: invalid page replacement");
+ vm_page_replace_checked(page, object, (*mres)->pindex, *mres);
vm_page_lock(*mres);
vm_page_free(*mres);
vm_page_unlock(*mres);
Modified: head/sys/vm/sg_pager.c
==============================================================================
--- head/sys/vm/sg_pager.c Thu Dec 17 17:00:04 2015 (r292405)
+++ head/sys/vm/sg_pager.c Thu Dec 17 17:48:57 2015 (r292406)
@@ -188,8 +188,7 @@ sg_pager_getpages(vm_object_t object, vm
page = vm_page_getfake(paddr, memattr);
VM_OBJECT_WLOCK(object);
TAILQ_INSERT_TAIL(&object->un_pager.sgp.sgp_pglist, page, plinks.q);
- if (vm_page_replace(page, object, offset) != m[0])
- panic("sg_pager_getpages: invalid place replacement");
+ vm_page_replace_checked(page, object, offset, m[0]);
m[0] = page;
page->valid = VM_PAGE_BITS_ALL;
Modified: head/sys/vm/vm_page.h
==============================================================================
--- head/sys/vm/vm_page.h Thu Dec 17 17:00:04 2015 (r292405)
+++ head/sys/vm/vm_page.h Thu Dec 17 17:48:57 2015 (r292406)
@@ -678,5 +678,20 @@ vm_page_undirty(vm_page_t m)
m->dirty = 0;
}
+static inline void
+vm_page_replace_checked(vm_page_t mnew, vm_object_t object, vm_pindex_t pindex,
+ vm_page_t mold)
+{
+ vm_page_t mret;
+
+ mret = vm_page_replace(mnew, object, pindex);
+ KASSERT(mret == mold,
+ ("invalid page replacement, mold=%p, mret=%p", mold, mret));
+
+ /* Unused if !INVARIANTS. */
+ (void)mold;
+ (void)mret;
+}
+
#endif /* _KERNEL */
#endif /* !_VM_PAGE_ */
More information about the svn-src-head
mailing list