The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/vm/vm_pageq.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1998 Matthew Dillon.  All Rights Reserved.
    3  * Redistribution and use in source and binary forms, with or without
    4  * modification, are permitted provided that the following conditions
    5  * are met:
    6  * 1. Redistributions of source code must retain the above copyright
    7  *    notice, this list of conditions and the following disclaimer.
    8  * 2. Redistributions in binary form must reproduce the above copyright
    9  *    notice, this list of conditions and the following disclaimer in the
   10  *    documentation and/or other materials provided with the distribution.
   11  * 4. Neither the name of the University nor the names of its contributors
   12  *    may be used to endorse or promote products derived from this software
   13  *    without specific prior written permission.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
   16  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
   19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   21  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   24  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   26  */
   27 
   28 #include <sys/cdefs.h>
   29 __FBSDID("$FreeBSD$");
   30 
   31 #include <sys/param.h>
   32 #include <sys/systm.h>
   33 #include <sys/linker_set.h>
   34 #include <sys/lock.h>
   35 #include <sys/malloc.h>
   36 #include <sys/mutex.h>
   37 #include <sys/sysctl.h>
   38 #include <sys/proc.h>
   39 #include <sys/vmmeter.h>
   40 #include <sys/vnode.h>
   41 
   42 #include <vm/vm.h>
   43 #include <vm/vm_param.h>
   44 #include <vm/vm_kern.h>
   45 #include <vm/vm_object.h>
   46 #include <vm/vm_page.h>
   47 #include <vm/vm_pageout.h>
   48 #include <vm/vm_pager.h>
   49 #include <vm/vm_phys.h>
   50 #include <vm/vm_extern.h>
   51 
   52 struct vpgqueues vm_page_queues[PQ_MAXCOUNT];
   53 
   54 void
   55 vm_pageq_init(void)
   56 {
   57         int i;
   58 
   59         vm_page_queues[PQ_INACTIVE].cnt = &cnt.v_inactive_count;
   60         vm_page_queues[PQ_ACTIVE].cnt = &cnt.v_active_count;
   61         vm_page_queues[PQ_HOLD].cnt = &cnt.v_active_count;
   62 
   63         for (i = 0; i < PQ_COUNT; i++) {
   64                 TAILQ_INIT(&vm_page_queues[i].pl);
   65         }
   66 }
   67 
   68 void
   69 vm_pageq_requeue(vm_page_t m)
   70 {
   71         int queue = VM_PAGE_GETQUEUE(m);
   72         struct vpgqueues *vpq;
   73 
   74         if (queue != PQ_NONE) {
   75                 vpq = &vm_page_queues[queue];
   76                 TAILQ_REMOVE(&vpq->pl, m, pageq);
   77                 TAILQ_INSERT_TAIL(&vpq->pl, m, pageq);
   78         }
   79 }
   80 
   81 /*
   82  *      vm_pageq_enqueue:
   83  */
   84 void
   85 vm_pageq_enqueue(int queue, vm_page_t m)
   86 {
   87         struct vpgqueues *vpq;
   88 
   89         vpq = &vm_page_queues[queue];
   90         VM_PAGE_SETQUEUE2(m, queue);
   91         TAILQ_INSERT_TAIL(&vpq->pl, m, pageq);
   92         ++*vpq->cnt;
   93 }
   94 
   95 /*
   96  * vm_pageq_remove:
   97  *
   98  *      Remove a page from its queue.
   99  *
  100  *      The queue containing the given page must be locked.
  101  *      This routine may not block.
  102  */
  103 void
  104 vm_pageq_remove(vm_page_t m)
  105 {
  106         int queue = VM_PAGE_GETQUEUE(m);
  107         struct vpgqueues *pq;
  108 
  109         if (queue != PQ_NONE) {
  110                 VM_PAGE_SETQUEUE2(m, PQ_NONE);
  111                 pq = &vm_page_queues[queue];
  112                 TAILQ_REMOVE(&pq->pl, m, pageq);
  113                 (*pq->cnt)--;
  114         }
  115 }

Cache object: 6b377a7c1e468219958d28beea3af8b3


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.