From owner-p4-projects@FreeBSD.ORG Mon Oct 24 18:41:50 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DDE4E1065673; Mon, 24 Oct 2011 18:41:49 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A0613106566B for ; Mon, 24 Oct 2011 18:41:49 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 750D08FC12 for ; Mon, 24 Oct 2011 18:41:49 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p9OIfnbY084524 for ; Mon, 24 Oct 2011 18:41:49 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p9OIfnr3084521 for perforce@freebsd.org; Mon, 24 Oct 2011 18:41:49 GMT (envelope-from jhb@freebsd.org) Date: Mon, 24 Oct 2011 18:41:49 GMT Message-Id: <201110241841.p9OIfnr3084521@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 200662 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Oct 2011 18:41:50 -0000 http://p4web.freebsd.org/@@200662?ac=10 Change 200662 by jhb@jhb_jhbbsd on 2011/10/24 18:40:59 Add a vm_object_page_cache() method which attempts to move clean pages into the cache queue. Affected files ... .. //depot/projects/fadvise/sys/vm/vm_object.c#2 edit .. //depot/projects/fadvise/sys/vm/vm_object.h#2 edit Differences ... ==== //depot/projects/fadvise/sys/vm/vm_object.c#2 (text+ko) ==== @@ -1863,6 +1863,50 @@ } /* + * vm_object_page_cache: + * + * For the given object, attempt to move the specified clean + * pages to the cache queue. If a page is wired for any reason, + * then it will not be changed. Pages are specified by the given + * range ["start", "end"). As a special case, if "end" is zero, + * then the range extends from "start" to the end of the object. + * Any mappings to the specified pages are removed before the + * pages are moved to the cache queue. + * + * This operation should only be performed on objects that + * contain managed pages. + * + * The object must be locked. + */ +void +vm_object_page_cache(vm_object_t object, vm_pindex_t start, vm_pindex_t end) +{ + vm_page_t p, next; + + VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); + KASSERT((object->type != OBJT_DEVICE && object->type != OBJT_SG && + object->type != OBJT_PHYS), + ("vm_object_page_cache: illegal object %p", object)); + if (object->resident_page_count == 0) + return; + vm_object_pip_add(object, 1); + p = vm_page_find_least(object, start); + + /* + * Here, the variable "p" is either (1) the page with the least pindex + * greater than or equal to the parameter "start" or (2) NULL. + */ + for (; p != NULL && (p->pindex < end || end == 0); p = next) { + next = TAILQ_NEXT(p, listq); + + vm_page_lock(p); + vm_page_try_to_cache(p); + vm_page_unlock(p); + } + vm_object_pip_wakeup(object); +} + +/* * Populate the specified range of the object with valid pages. Returns * TRUE if the range is successfully populated and FALSE otherwise. * ==== //depot/projects/fadvise/sys/vm/vm_object.h#2 (text+ko) ==== @@ -223,6 +223,8 @@ void vm_object_terminate (vm_object_t); void vm_object_set_writeable_dirty (vm_object_t); void vm_object_init (void); +void vm_object_page_cache(vm_object_t object, vm_pindex_t start, + vm_pindex_t end); void vm_object_page_clean(vm_object_t object, vm_ooffset_t start, vm_ooffset_t end, int flags); void vm_object_page_remove(vm_object_t object, vm_pindex_t start,