summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2010-04-17 21:14:37 +0000
committeralc <alc@FreeBSD.org>2010-04-17 21:14:37 +0000
commitae8ea7c78385a57669ed9bb21cfc9a021afd410e (patch)
tree03c5d80e46d468b03a341854ac7b81a63559256b /sys/vm
parentcbed8db2a8ad2fb0abb82dfd7ad4e267456e9eb6 (diff)
downloadFreeBSD-src-ae8ea7c78385a57669ed9bb21cfc9a021afd410e.zip
FreeBSD-src-ae8ea7c78385a57669ed9bb21cfc9a021afd410e.tar.gz
In vm_object_madvise() setting PG_REFERENCED on a page before sleeping on
that page only makes sense if the advice is MADV_WILLNEED. In that case, the intention is to activate the page, so discouraging the page daemon from reclaiming the page makes sense. In contrast, in the other cases, MADV_DONTNEED and MADV_FREE, it makes no sense whatsoever to discourage the page daemon from reclaiming the page by setting PG_REFERENCED. Wrap a nearby line. Discussed with: kib MFC after: 3 weeks
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_object.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 7e84e58..1f9ba6d 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -1205,12 +1205,19 @@ shadowlookup:
goto unlock_tobject;
}
if ((m->oflags & VPO_BUSY) || m->busy) {
- vm_page_flag_set(m, PG_REFERENCED);
+ if (advise == MADV_WILLNEED)
+ /*
+ * Reference the page before unlocking and
+ * sleeping so that the page daemon is less
+ * likely to reclaim it.
+ */
+ vm_page_flag_set(m, PG_REFERENCED);
vm_page_unlock_queues();
if (object != tobject)
VM_OBJECT_UNLOCK(object);
m->oflags |= VPO_WANTED;
- msleep(m, VM_OBJECT_MTX(tobject), PDROP | PVM, "madvpo", 0);
+ msleep(m, VM_OBJECT_MTX(tobject), PDROP | PVM, "madvpo",
+ 0);
VM_OBJECT_LOCK(object);
goto relookup;
}
OpenPOWER on IntegriCloud