Page MenuHomeFreeBSD

D33924.id101607.diff
No OneTemporary

D33924.id101607.diff

diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -712,6 +712,40 @@
return (error);
}
+/*
+ * Check if the object is active. Non-anonymous swap objects are
+ * always referenced by owner, for them require ref_count > 1 to
+ * ignore the ownership ref.
+ */
+static int
+vm_pageout_object_act(vm_object_t object)
+{
+ return ((object->flags & (OBJ_SWAP | OBJ_ANON)) ==
+ OBJ_SWAP ? 1 : 0);
+}
+
+static int
+vm_pageout_page_ts_referenced(vm_object_t object, vm_page_t m)
+{
+ /*
+ * Perform an unsynchronized object ref count check. While
+ * the page lock ensures that the page is not reallocated to
+ * another object, in particular, one with unmanaged mappings
+ * that cannot support pmap_ts_referenced(), two races are,
+ * nonetheless, possible:
+ * 1) The count was transitioning to zero, but we saw a non-
+ * zero value. pmap_ts_referenced() will return zero
+ * because the page is not mapped.
+ * 2) The count was transitioning to one, but we saw zero.
+ * This race delays the detection of a new reference. At
+ * worst, we will deactivate and reactivate the page.
+ */
+ if (object->ref_count <= vm_pageout_object_act(object))
+ return (0);
+
+ return (pmap_ts_referenced(m));
+}
+
/*
* Attempt to launder the specified number of pages.
*
@@ -806,7 +840,7 @@
if (vm_page_none_valid(m))
goto free_page;
- refs = object->ref_count != 0 ? pmap_ts_referenced(m) : 0;
+ refs = vm_pageout_page_ts_referenced(object, m);
for (old = vm_page_astate_load(m);;) {
/*
@@ -826,7 +860,8 @@
}
if (act_delta == 0) {
;
- } else if (object->ref_count != 0) {
+ } else if (object->ref_count >=
+ vm_pageout_object_act(object)) {
/*
* Increase the activation count if the page was
* referenced while in the laundry queue. This
@@ -1263,20 +1298,8 @@
* Test PGA_REFERENCED after calling pmap_ts_referenced() so
* that a reference from a concurrently destroyed mapping is
* observed here and now.
- *
- * Perform an unsynchronized object ref count check. While
- * the page lock ensures that the page is not reallocated to
- * another object, in particular, one with unmanaged mappings
- * that cannot support pmap_ts_referenced(), two races are,
- * nonetheless, possible:
- * 1) The count was transitioning to zero, but we saw a non-
- * zero value. pmap_ts_referenced() will return zero
- * because the page is not mapped.
- * 2) The count was transitioning to one, but we saw zero.
- * This race delays the detection of a new reference. At
- * worst, we will deactivate and reactivate the page.
*/
- refs = object->ref_count != 0 ? pmap_ts_referenced(m) : 0;
+ refs = vm_pageout_page_ts_referenced(object, m);
old = vm_page_astate_load(m);
do {
@@ -1526,7 +1549,7 @@
if (vm_page_none_valid(m))
goto free_page;
- refs = object->ref_count != 0 ? pmap_ts_referenced(m) : 0;
+ refs = vm_pageout_page_ts_referenced(object, m);
for (old = vm_page_astate_load(m);;) {
/*
@@ -1546,7 +1569,8 @@
}
if (act_delta == 0) {
;
- } else if (object->ref_count != 0) {
+ } else if (object->ref_count >=
+ vm_pageout_object_act(object)) {
/*
* Increase the activation count if the
* page was referenced while in the

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 1, 10:57 AM (19 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30675246
Default Alt Text
D33924.id101607.diff (3 KB)

Event Timeline