PERFORCE change 90612 for review
Alan Cox
alc at FreeBSD.org
Sun Jan 29 00:44:38 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=90612
Change 90612 by alc at alc_home on 2006/01/29 08:43:36
Prepare for handing cache pages to the buddy allocator.
Affected files ...
.. //depot/projects/superpages/src/sys/vm/vm_buddy.c#7 edit
.. //depot/projects/superpages/src/sys/vm/vm_buddy.h#6 edit
.. //depot/projects/superpages/src/sys/vm/vm_page.c#13 edit
.. //depot/projects/superpages/src/sys/vm/vm_pageq.c#15 edit
Differences ...
==== //depot/projects/superpages/src/sys/vm/vm_buddy.c#7 (text+ko) ====
@@ -212,7 +212,7 @@
{
mtx_lock_spin(&vm_page_queue_free_mtx);
- buddy_free_locked(m, q);
+ buddy_free_locked(PQ_BUDDY, m, q);
mtx_unlock_spin(&vm_page_queue_free_mtx);
}
@@ -220,36 +220,45 @@
* Free a contiguous, power of two-sized set of physical pages.
*/
void
-buddy_free_locked(vm_page_t m, int q)
+buddy_free_locked(int baseq, vm_page_t m, int q)
{
vm_paddr_t pa, pa_buddy;
vm_page_t buddy;
KASSERT(q < BUDDY_QUEUES,
- ("vm_page_buddy_free: queue %d is out of range", q));
+ ("buddy_free_locked: queue %d is out of range", q));
KASSERT(m->queue == PQ_NONE,
- ("vm_page_buddy_free: page %p has unexpected queue %d",
+ ("buddy_free_locked: page %p has unexpected queue %d",
m, m->queue));
KASSERT(m->dirty == 0,
- ("vm_page_buddy_free: page %p is dirty", m));
- mtx_assert(&vm_page_queue_free_mtx, MA_OWNED);
+ ("buddy_free_locked: page %p is dirty", m));
+ switch (baseq) {
+ case PQ_CACHE:
+ mtx_assert(&vm_page_queue_mtx, MA_OWNED);
+ break;
+ case PQ_BUDDY:
+ mtx_assert(&vm_page_queue_free_mtx, MA_OWNED);
+ break;
+ default:
+ KASSERT(FALSE, ("buddy_free_locked: unexpected baseq %d",
+ baseq));
+ break;
+ }
+ *vm_page_queues[baseq].cnt += 1 << q;
pa = VM_PAGE_TO_PHYS(m);
- cnt.v_free_count += 1 << q;
while (q < BUDDY_QUEUES - 1) {
pa_buddy = pa ^ (1 << (PAGE_SHIFT + q));
buddy = phys_to_vm_page(pa_buddy);
if (buddy == NULL ||
buddy->buddyq != q ||
- (buddy->queue - buddy->buddyq) != PQ_BUDDY)
+ (buddy->queue - buddy->buddyq) != baseq)
break;
- KASSERT(buddy->object == NULL,
- ("vm_page_buddy_free: page %p xxx", buddy));
buddy_remove(buddy);
q++;
pa &= ~((1 << (PAGE_SHIFT + q)) - 1);
m = PHYS_TO_VM_PAGE(pa);
}
- buddy_insert(PQ_BUDDY, q, m);
+ buddy_insert(baseq, q, m);
}
/*
@@ -388,7 +397,7 @@
KASSERT(m->queue == PQ_NONE,
("vm_page_alloc_contig: page %p has unexpected queue %d",
m, m->queue));
- buddy_free_locked(m, 0);
+ buddy_free_locked(PQ_BUDDY, m, 0);
}
mtx_unlock_spin(&vm_page_queue_free_mtx);
return (m_ret);
==== //depot/projects/superpages/src/sys/vm/vm_buddy.h#6 (text+ko) ====
@@ -5,5 +5,5 @@
vm_page_t buddy_alloc(int magn, boolean_t prefer_zero);
vm_page_t buddy_alloc_locked(int magn, boolean_t prefer_zero);
void buddy_free(vm_page_t m, int magn);
-void buddy_free_locked(vm_page_t m, int magn);
+void buddy_free_locked(int baseq, vm_page_t m, int magn);
void buddy_unfree(vm_page_t m);
==== //depot/projects/superpages/src/sys/vm/vm_page.c#13 (text+ko) ====
@@ -1090,7 +1090,7 @@
mtx_lock_spin(&vm_page_queue_free_mtx);
if (m->flags & PG_ZERO)
++vm_page_zero_count;
- buddy_free_locked(m, 0);
+ buddy_free_locked(PQ_BUDDY, m, 0);
mtx_unlock_spin(&vm_page_queue_free_mtx);
vm_page_free_wakeup();
}
==== //depot/projects/superpages/src/sys/vm/vm_pageq.c#15 (text+ko) ====
@@ -91,11 +91,15 @@
{
struct vpgqueues *vpq;
- vpq = &vm_page_queues[queue];
- VM_PAGE_SETQUEUE2(m, queue);
- TAILQ_INSERT_TAIL(&vpq->pl, m, pageq);
- ++*vpq->cnt;
- ++vpq->lcnt;
+ if ((m->flags & PG_CACHE) != 0)
+ buddy_free_locked(queue, m, 0);
+ else {
+ vpq = &vm_page_queues[queue];
+ VM_PAGE_SETQUEUE2(m, queue);
+ TAILQ_INSERT_TAIL(&vpq->pl, m, pageq);
+ ++*vpq->cnt;
+ ++vpq->lcnt;
+ }
}
/*
More information about the p4-projects
mailing list