From cfcce55c38d2d3dd6e3e5d1cac353bfe1a9922f2 Mon Sep 17 00:00:00 2001 From: alc Date: Sat, 27 Oct 2018 17:49:46 +0000 Subject: [PATCH] Eliminate typically pointless calls to vm_fault_prefault() on soft, copy- on-write faults. On a page fault, when we call vm_fault_prefault(), it probes the pmap and the shadow chain of vm objects to see if there are opportunities to create read and/or execute-only mappings to neighoring pages. For example, in the case of hard faults, such effort typically pays off, that is, mappings are created that eliminate future soft page faults. However, in the the case of soft, copy-on-write faults, the effort very rarely pays off. (See the review for some specific data.) Reviewed by: kib, markj MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D17367 --- sys/vm/vm_fault.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index c56e51f3dbfe..e095ccc69edf 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1181,6 +1181,16 @@ readrest: */ vm_object_pip_wakeup(fs.object); VM_OBJECT_WUNLOCK(fs.object); + + /* + * We only try to prefault read-only mappings to the + * neighboring pages when this copy-on-write fault is + * a hard fault. In other cases, trying to prefault + * is typically wasted effort. + */ + if (faultcount == 0) + faultcount = 1; + /* * Only use the new page below... */