Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Apr 2012 18:25:13 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r234039 - head/sys/vm
Message-ID:  <201204081825.q38IPDqT023159@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Sun Apr  8 18:25:12 2012
New Revision: 234039
URL: http://svn.freebsd.org/changeset/base/234039

Log:
  Fix mincore(2) so that it reports PG_CACHED pages as resident.
  
  MFC after:	2 weeks

Modified:
  head/sys/vm/vm_mmap.c
  head/sys/vm/vm_page.c
  head/sys/vm/vm_page.h

Modified: head/sys/vm/vm_mmap.c
==============================================================================
--- head/sys/vm/vm_mmap.c	Sun Apr  8 17:00:46 2012	(r234038)
+++ head/sys/vm/vm_mmap.c	Sun Apr  8 18:25:12 2012	(r234039)
@@ -888,6 +888,9 @@ RestartScan:
 					pindex = OFF_TO_IDX(current->offset +
 					    (addr - current->start));
 					m = vm_page_lookup(object, pindex);
+					if (m == NULL &&
+					    vm_page_is_cached(object, pindex))
+						mincoreinfo = MINCORE_INCORE;
 					if (m != NULL && m->valid == 0)
 						m = NULL;
 					if (m != NULL)

Modified: head/sys/vm/vm_page.c
==============================================================================
--- head/sys/vm/vm_page.c	Sun Apr  8 17:00:46 2012	(r234038)
+++ head/sys/vm/vm_page.c	Sun Apr  8 18:25:12 2012	(r234039)
@@ -1285,6 +1285,33 @@ vm_page_cache_transfer(vm_object_t orig_
 }
 
 /*
+ *	Returns TRUE if a cached page is associated with the given object and
+ *	offset, and FALSE otherwise.
+ *
+ *	The object must be locked.
+ */
+boolean_t
+vm_page_is_cached(vm_object_t object, vm_pindex_t pindex)
+{
+	vm_page_t m;
+
+	/*
+	 * Insertion into an object's collection of cached pages requires the
+	 * object to be locked.  Therefore, if the object is locked and the
+	 * object's collection is empty, there is no need to acquire the free
+	 * page queues lock in order to prove that the specified page doesn't
+	 * exist.
+	 */
+	VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
+	if (object->cache == NULL)
+		return (FALSE);
+	mtx_lock(&vm_page_queue_free_mtx);
+	m = vm_page_cache_lookup(object, pindex);
+	mtx_unlock(&vm_page_queue_free_mtx);
+	return (m != NULL);
+}
+
+/*
  *	vm_page_alloc:
  *
  *	Allocate and return a page that is associated with the specified

Modified: head/sys/vm/vm_page.h
==============================================================================
--- head/sys/vm/vm_page.h	Sun Apr  8 17:00:46 2012	(r234038)
+++ head/sys/vm/vm_page.h	Sun Apr  8 18:25:12 2012	(r234039)
@@ -392,6 +392,7 @@ void vm_page_deactivate (vm_page_t);
 vm_page_t vm_page_find_least(vm_object_t, vm_pindex_t);
 vm_page_t vm_page_getfake(vm_paddr_t paddr, vm_memattr_t memattr);
 void vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t);
+boolean_t vm_page_is_cached(vm_object_t object, vm_pindex_t pindex);
 vm_page_t vm_page_lookup (vm_object_t, vm_pindex_t);
 vm_page_t vm_page_next(vm_page_t m);
 int vm_page_pa_tryrelock(pmap_t, vm_paddr_t, vm_paddr_t *);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204081825.q38IPDqT023159>