vm_reserv.c (b626f5a73a48f44a31a200291b141e1da408a2ff) vm_reserv.c (7667839a7ec4354de9984d411c45cbacf9fe8e3b)
1/*-
2 * Copyright (c) 2002-2006 Rice University
3 * Copyright (c) 2007-2011 Alan L. Cox <alc@cs.rice.edu>
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Alan L. Cox,
7 * Olivier Crameri, Peter Druschel, Sitaram Iyer, and Juan Navarro.
8 *

--- 894 unchanged lines hidden (view full) ---

903{
904 vm_reserv_t rv;
905
906 rv = vm_reserv_from_page(m);
907 return (rv->popcnt == VM_LEVEL_0_NPAGES ? 0 : -1);
908}
909
910/*
1/*-
2 * Copyright (c) 2002-2006 Rice University
3 * Copyright (c) 2007-2011 Alan L. Cox <alc@cs.rice.edu>
4 * All rights reserved.
5 *
6 * This software was developed for the FreeBSD Project by Alan L. Cox,
7 * Olivier Crameri, Peter Druschel, Sitaram Iyer, and Juan Navarro.
8 *

--- 894 unchanged lines hidden (view full) ---

903{
904 vm_reserv_t rv;
905
906 rv = vm_reserv_from_page(m);
907 return (rv->popcnt == VM_LEVEL_0_NPAGES ? 0 : -1);
908}
909
910/*
911 * Prepare for the reactivation of a cached page.
912 *
913 * First, suppose that the given page "m" was allocated individually, i.e., not
914 * as part of a reservation, and cached. Then, suppose a reservation
915 * containing "m" is allocated by the same object. Although "m" and the
916 * reservation belong to the same object, "m"'s pindex may not match the
917 * reservation's.
918 *
919 * The free page queue must be locked.
920 */
921boolean_t
922vm_reserv_reactivate_page(vm_page_t m)
923{
924 vm_reserv_t rv;
925 int index;
926
927 mtx_assert(&vm_page_queue_free_mtx, MA_OWNED);
928 rv = vm_reserv_from_page(m);
929 if (rv->object == NULL)
930 return (FALSE);
931 KASSERT((m->flags & PG_CACHED) != 0,
932 ("vm_reserv_reactivate_page: page %p is not cached", m));
933 if (m->object == rv->object &&
934 m->pindex - rv->pindex == (index = VM_RESERV_INDEX(m->object,
935 m->pindex)))
936 vm_reserv_populate(rv, index);
937 else {
938 KASSERT(rv->inpartpopq,
939 ("vm_reserv_reactivate_page: reserv %p's inpartpopq is FALSE",
940 rv));
941 TAILQ_REMOVE(&vm_rvq_partpop, rv, partpopq);
942 rv->inpartpopq = FALSE;
943 /* Don't release "m" to the physical memory allocator. */
944 vm_reserv_break(rv, m);
945 }
946 return (TRUE);
947}
948
949/*
950 * Breaks the given partially-populated reservation, releasing its cached and
951 * free pages to the physical memory allocator.
952 *
953 * The free page queue lock must be held.
954 */
955static void
956vm_reserv_reclaim(vm_reserv_t rv)
957{

--- 201 unchanged lines hidden ---
911 * Breaks the given partially-populated reservation, releasing its cached and
912 * free pages to the physical memory allocator.
913 *
914 * The free page queue lock must be held.
915 */
916static void
917vm_reserv_reclaim(vm_reserv_t rv)
918{

--- 201 unchanged lines hidden ---