From b131a2abc80d9ea68d6ff41d2ab9bde70e6023d7 Mon Sep 17 00:00:00 2001
From: alc <alc@FreeBSD.org>
Date: Sat, 21 Mar 2015 17:56:55 +0000
Subject: Introduce vm_object_color() and use it in mmap(2) to set the color of
 named objects to zero before the virtual address is selected.  Previously,
 the color setting was delayed until after the virtual address was selected. 
 In rtld, this delay effectively prevented the mapping of a shared library's
 code section using superpages.  Now, for example, we see the first 1 MB of
 libc's code on armv6 mapped by a superpage after we've gotten through the
 initial cold misses that bring the first 1 MB of code into memory.  (With the
 page clustering that we perform on read faults, this happens quickly.)

Differential Revision:	https://reviews.freebsd.org/D2013
Reviewed by:	jhb, kib
Tested by:	Svatopluk Kraus (armv6)
MFC after:	6 weeks
---
 sys/vm/vm_fault.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

(limited to 'sys/vm/vm_fault.c')

diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index ff18a15..536076a 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -522,11 +522,8 @@ fast_failed:
 			fs.m = NULL;
 			if (!vm_page_count_severe() || P_KILLED(curproc)) {
 #if VM_NRESERVLEVEL > 0
-				if ((fs.object->flags & OBJ_COLORED) == 0) {
-					fs.object->flags |= OBJ_COLORED;
-					fs.object->pg_color = atop(vaddr) -
-					    fs.pindex;
-				}
+				vm_object_color(fs.object, atop(vaddr) -
+				    fs.pindex);
 #endif
 				alloc_req = P_KILLED(curproc) ?
 				    VM_ALLOC_SYSTEM : VM_ALLOC_NORMAL;
-- 
cgit v1.1