Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Oct 2011 21:46:45 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 200255 for review
Message-ID:  <201110152146.p9FLkjPK043109@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@200255?ac=10

Change 200255 by jhb@jhb_fiver on 2011/10/15 21:46:16

	Change FADV_DONTNEED to actually force the pages out similar
	to msync(MS_INVALIDATE) by calling vm_object_sync().
	
	I want to change FADV_WILLNEED to actually kick off a read-ahead
	if needed, but not sure how best to do that.

Affected files ...

.. //depot/projects/fadvise/sys/kern/vfs_syscalls.c#6 edit

Differences ...

==== //depot/projects/fadvise/sys/kern/vfs_syscalls.c#6 (text+ko) ====

@@ -4941,11 +4941,8 @@
 		mtx_pool_unlock(mtxpool_sleep, fp);
 		break;
 	case FADV_WILLNEED:
-	case FADV_DONTNEED:
 		/*
-		 * Apply the request to the backing VM object.  Note
-		 * that the FADV_* constants map directly to the same
-		 * madvise(2) constants.
+		 * Apply the request to the backing VM object.
 		 *
 		 * XXX: madvise(MADV_WILLNEED) will not do readahead on
 		 * a file, perhaps FADV_WILLNEED should.
@@ -4956,10 +4953,19 @@
 		vn_lock(vp, LK_SHARED | LK_RETRY);
 		if (vp->v_object != NULL)
 			vm_object_madvise(vp->v_object, OFF_TO_IDX(start),
-			    atop(end - start), uap->advice);
+			    atop(end - start), MADV_WILLNEED);
 		VOP_UNLOCK(vp, 0);
 		VFS_UNLOCK_GIANT(vfslocked);
 		break;
+	case FADV_DONTNEED:
+		/*
+		 * Invalidate pages from the backing VM object similar
+		 * to msync(MS_INVALIDATE).
+		 */
+		if (vp->v_object != NULL)
+			vm_object_sync(vp->v_object, uap->offset, end - uap->offset,
+			    FALSE, TRUE);
+		break;
 	}
 out:
 	fdrop(fp, td);



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