diff options
author | alc <alc@FreeBSD.org> | 2008-03-18 06:52:15 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2008-03-18 06:52:15 +0000 |
commit | 4e9b2a2931712b722c3954fa39b4385f0d710b6c (patch) | |
tree | b661554c75fe6515f71dc8bebb23a33f67ad3319 /sys/vm | |
parent | 5b6560526e3f033b3c4613a1e51d748fa7e747d7 (diff) | |
download | FreeBSD-src-4e9b2a2931712b722c3954fa39b4385f0d710b6c.zip FreeBSD-src-4e9b2a2931712b722c3954fa39b4385f0d710b6c.tar.gz |
Almost seven years ago, vm/vm_page.c was split into three parts:
vm/vm_contig.c, vm/vm_page.c, and vm/vm_pageq.c. Today, vm/vm_pageq.c
has withered to the point that it contains only four short functions,
two of which are only used by vm/vm_page.c. Since I can't foresee any
reason for vm/vm_pageq.c to grow, it is time to fold the remaining
contents of vm/vm_pageq.c back into vm/vm_page.c.
Add some comments. Rename one of the functions, vm_pageq_enqueue(),
that is now static within vm/vm_page.c to vm_page_enqueue().
Eliminate PQ_MAXCOUNT as it no longer serves any purpose.
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_page.c | 79 | ||||
-rw-r--r-- | sys/vm/vm_page.h | 5 | ||||
-rw-r--r-- | sys/vm/vm_pageq.c | 115 |
3 files changed, 75 insertions, 124 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index cea7a23..2df20e4 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1,6 +1,7 @@ /*- * Copyright (c) 1991 Regents of the University of California. * All rights reserved. + * Copyright (c) 1998 Matthew Dillon. All Rights Reserved. * * This code is derived from software contributed to Berkeley by * The Mach Operating System project at Carnegie-Mellon University. @@ -132,6 +133,7 @@ __FBSDID("$FreeBSD$"); * page structure. */ +struct vpgqueues vm_page_queues[PQ_COUNT]; struct mtx vm_page_queue_mtx; struct mtx vm_page_queue_free_mtx; @@ -145,6 +147,8 @@ TUNABLE_INT("vm.boot_pages", &boot_pages); SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RD, &boot_pages, 0, "number of pages allocated for bootstrapping the VM system"); +static void vm_page_enqueue(int queue, vm_page_t m); + /* * vm_set_page_size: * @@ -259,7 +263,11 @@ vm_page_startup(vm_offset_t vaddr) * Initialize the queue headers for the hold queue, the active queue, * and the inactive queue. */ - vm_pageq_init(); + for (i = 0; i < PQ_COUNT; i++) + TAILQ_INIT(&vm_page_queues[i].pl); + vm_page_queues[PQ_INACTIVE].cnt = &cnt.v_inactive_count; + vm_page_queues[PQ_ACTIVE].cnt = &cnt.v_active_count; + vm_page_queues[PQ_HOLD].cnt = &cnt.v_active_count; /* * Allocate memory for use when boot strapping the kernel memory @@ -1208,6 +1216,67 @@ vm_waitpfault(void) } /* + * vm_pageq_requeue: + * + * If the given page is contained within a page queue, move it to the tail + * of that queue. + * + * The page queues must be locked. + */ +void +vm_pageq_requeue(vm_page_t m) +{ + int queue = VM_PAGE_GETQUEUE(m); + struct vpgqueues *vpq; + + if (queue != PQ_NONE) { + vpq = &vm_page_queues[queue]; + TAILQ_REMOVE(&vpq->pl, m, pageq); + TAILQ_INSERT_TAIL(&vpq->pl, m, pageq); + } +} + +/* + * vm_pageq_remove: + * + * Remove a page from its queue. + * + * The queue containing the given page must be locked. + * This routine may not block. + */ +void +vm_pageq_remove(vm_page_t m) +{ + int queue = VM_PAGE_GETQUEUE(m); + struct vpgqueues *pq; + + if (queue != PQ_NONE) { + VM_PAGE_SETQUEUE2(m, PQ_NONE); + pq = &vm_page_queues[queue]; + TAILQ_REMOVE(&pq->pl, m, pageq); + (*pq->cnt)--; + } +} + +/* + * vm_page_enqueue: + * + * Add the given page to the specified queue. + * + * The page queues must be locked. + */ +static void +vm_page_enqueue(int queue, vm_page_t m) +{ + struct vpgqueues *vpq; + + vpq = &vm_page_queues[queue]; + VM_PAGE_SETQUEUE2(m, queue); + TAILQ_INSERT_TAIL(&vpq->pl, m, pageq); + ++*vpq->cnt; +} + +/* * vm_page_activate: * * Put the specified page on the active list (if appropriate). @@ -1227,7 +1296,7 @@ vm_page_activate(vm_page_t m) if (m->wire_count == 0 && (m->flags & PG_UNMANAGED) == 0) { if (m->act_count < ACT_INIT) m->act_count = ACT_INIT; - vm_pageq_enqueue(PQ_ACTIVE, m); + vm_page_enqueue(PQ_ACTIVE, m); } } else { if (m->act_count < ACT_INIT) @@ -1330,7 +1399,7 @@ vm_page_free_toq(vm_page_t m) } if (m->hold_count != 0) { m->flags &= ~PG_ZERO; - vm_pageq_enqueue(PQ_HOLD, m); + vm_page_enqueue(PQ_HOLD, m); } else { mtx_lock(&vm_page_queue_free_mtx); m->flags |= PG_FREE; @@ -1423,10 +1492,10 @@ vm_page_unwire(vm_page_t m, int activate) if (m->flags & PG_UNMANAGED) { ; } else if (activate) - vm_pageq_enqueue(PQ_ACTIVE, m); + vm_page_enqueue(PQ_ACTIVE, m); else { vm_page_flag_clear(m, PG_WINATCFLS); - vm_pageq_enqueue(PQ_INACTIVE, m); + vm_page_enqueue(PQ_INACTIVE, m); } } } else { diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index c13511d..60695b3 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -162,7 +162,6 @@ CTASSERT(sizeof(u_long) >= 8); #define PQ_ACTIVE 2 #define PQ_HOLD 3 #define PQ_COUNT 4 -#define PQ_MAXCOUNT 4 /* Returns the real queue a page is on. */ #define VM_PAGE_GETQUEUE(m) ((m)->queue) @@ -181,7 +180,7 @@ struct vpgqueues { int *cnt; }; -extern struct vpgqueues vm_page_queues[PQ_MAXCOUNT]; +extern struct vpgqueues vm_page_queues[PQ_COUNT]; extern struct mtx vm_page_queue_free_mtx; /* @@ -311,8 +310,6 @@ void vm_page_free_zero(vm_page_t m); void vm_page_dirty(vm_page_t m); void vm_page_wakeup(vm_page_t m); -void vm_pageq_init(void); -void vm_pageq_enqueue(int queue, vm_page_t m); void vm_pageq_remove(vm_page_t m); void vm_pageq_requeue(vm_page_t m); diff --git a/sys/vm/vm_pageq.c b/sys/vm/vm_pageq.c deleted file mode 100644 index 055bac5..0000000 --- a/sys/vm/vm_pageq.c +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * Copyright (c) 1998 Matthew Dillon. All Rights Reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/linker_set.h> -#include <sys/lock.h> -#include <sys/malloc.h> -#include <sys/mutex.h> -#include <sys/sysctl.h> -#include <sys/proc.h> -#include <sys/vmmeter.h> -#include <sys/vnode.h> - -#include <vm/vm.h> -#include <vm/vm_param.h> -#include <vm/vm_kern.h> -#include <vm/vm_object.h> -#include <vm/vm_page.h> -#include <vm/vm_pageout.h> -#include <vm/vm_pager.h> -#include <vm/vm_phys.h> -#include <vm/vm_extern.h> - -struct vpgqueues vm_page_queues[PQ_MAXCOUNT]; - -void -vm_pageq_init(void) -{ - int i; - - vm_page_queues[PQ_INACTIVE].cnt = &cnt.v_inactive_count; - vm_page_queues[PQ_ACTIVE].cnt = &cnt.v_active_count; - vm_page_queues[PQ_HOLD].cnt = &cnt.v_active_count; - - for (i = 0; i < PQ_COUNT; i++) { - TAILQ_INIT(&vm_page_queues[i].pl); - } -} - -void -vm_pageq_requeue(vm_page_t m) -{ - int queue = VM_PAGE_GETQUEUE(m); - struct vpgqueues *vpq; - - if (queue != PQ_NONE) { - vpq = &vm_page_queues[queue]; - TAILQ_REMOVE(&vpq->pl, m, pageq); - TAILQ_INSERT_TAIL(&vpq->pl, m, pageq); - } -} - -/* - * vm_pageq_enqueue: - */ -void -vm_pageq_enqueue(int queue, vm_page_t m) -{ - struct vpgqueues *vpq; - - vpq = &vm_page_queues[queue]; - VM_PAGE_SETQUEUE2(m, queue); - TAILQ_INSERT_TAIL(&vpq->pl, m, pageq); - ++*vpq->cnt; -} - -/* - * vm_pageq_remove: - * - * Remove a page from its queue. - * - * The queue containing the given page must be locked. - * This routine may not block. - */ -void -vm_pageq_remove(vm_page_t m) -{ - int queue = VM_PAGE_GETQUEUE(m); - struct vpgqueues *pq; - - if (queue != PQ_NONE) { - VM_PAGE_SETQUEUE2(m, PQ_NONE); - pq = &vm_page_queues[queue]; - TAILQ_REMOVE(&pq->pl, m, pageq); - (*pq->cnt)--; - } -} |