* Renamed page queues according to our style guide.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22155 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-09-03 15:35:09 +00:00
parent b50494aaac
commit d8badf6791

View File

@ -39,15 +39,15 @@
typedef struct page_queue { typedef struct page_queue {
vm_page *head; vm_page *head;
vm_page *tail; vm_page *tail;
int count; uint32 count;
} page_queue; } page_queue;
extern bool trimming_cycle; extern bool trimming_cycle;
static page_queue page_free_queue; static page_queue sFreePageQueue;
static page_queue page_clear_queue; static page_queue sClearPageQueue;
static page_queue page_modified_queue; static page_queue sModifiedPageQueue;
static page_queue page_active_queue; static page_queue sActivePageQueue;
static vm_page *sPages; static vm_page *sPages;
static addr_t sPhysicalPageOffset; static addr_t sPhysicalPageOffset;
@ -112,7 +112,7 @@ enqueue_page(page_queue *q, vm_page *page)
page->queue = q; page->queue = q;
#endif #endif
if (q == &page_modified_queue) { if (q == &sModifiedPageQueue) {
if (q->count == 1) if (q->count == 1)
release_sem_etc(modified_pages_available, 1, B_DO_NOT_RESCHEDULE); release_sem_etc(modified_pages_available, 1, B_DO_NOT_RESCHEDULE);
} }
@ -177,10 +177,10 @@ find_page(int argc, char **argv)
const char* name; const char* name;
page_queue* queue; page_queue* queue;
} pageQueueInfos[] = { } pageQueueInfos[] = {
{ "free", &page_free_queue }, { "free", &sFreePageQueue },
{ "clear", &page_clear_queue }, { "clear", &sClearPageQueue },
{ "modified", &page_modified_queue }, { "modified", &sModifiedPageQueue },
{ "active", &page_active_queue }, { "active", &sActivePageQueue },
{ NULL, NULL } { NULL, NULL }
}; };
@ -301,26 +301,29 @@ dump_page_queue(int argc, char **argv)
if (strlen(argv[1]) >= 2 && argv[1][0] == '0' && argv[1][1] == 'x') if (strlen(argv[1]) >= 2 && argv[1][0] == '0' && argv[1][1] == 'x')
queue = (struct page_queue *)strtoul(argv[1], NULL, 16); queue = (struct page_queue *)strtoul(argv[1], NULL, 16);
if (!strcmp(argv[1], "free")) if (!strcmp(argv[1], "free"))
queue = &page_free_queue; queue = &sFreePageQueue;
else if (!strcmp(argv[1], "clear")) else if (!strcmp(argv[1], "clear"))
queue = &page_clear_queue; queue = &sClearPageQueue;
else if (!strcmp(argv[1], "modified")) else if (!strcmp(argv[1], "modified"))
queue = &page_modified_queue; queue = &sModifiedPageQueue;
else if (!strcmp(argv[1], "active")) else if (!strcmp(argv[1], "active"))
queue = &page_active_queue; queue = &sActivePageQueue;
else { else {
kprintf("page_queue: unknown queue \"%s\".\n", argv[1]); kprintf("page_queue: unknown queue \"%s\".\n", argv[1]);
return 0; return 0;
} }
kprintf("queue = %p, queue->head = %p, queue->tail = %p, queue->count = %d\n", queue, queue->head, queue->tail, queue->count); kprintf("queue = %p, queue->head = %p, queue->tail = %p, queue->count = %ld\n",
queue, queue->head, queue->tail, queue->count);
if (argc == 3) { if (argc == 3) {
struct vm_page *page = queue->head; struct vm_page *page = queue->head;
int i; int i;
for (i = 0; page; i++, page = page->queue_next) { for (i = 0; page; i++, page = page->queue_next) {
kprintf("%5d. queue_next = %p, queue_prev = %p, type = %d, state = %d\n", i, page->queue_next, page->queue_prev, page->type, page->state); kprintf("%5d. queue_next = %p, queue_prev = %p, type = %d, "
"state = %d\n", i, page->queue_next, page->queue_prev,
page->type, page->state);
} }
} }
return 0; return 0;
@ -349,10 +352,10 @@ dump_page_stats(int argc, char **argv)
kprintf("wired: %lu\nmodified: %lu\nfree: %lu\nclear: %lu\n", kprintf("wired: %lu\nmodified: %lu\nfree: %lu\nclear: %lu\n",
counter[PAGE_STATE_WIRED], counter[PAGE_STATE_MODIFIED], counter[PAGE_STATE_FREE], counter[PAGE_STATE_CLEAR]); counter[PAGE_STATE_WIRED], counter[PAGE_STATE_MODIFIED], counter[PAGE_STATE_FREE], counter[PAGE_STATE_CLEAR]);
kprintf("\nfree_queue: %p, count = %d\n", &page_free_queue, page_free_queue.count); kprintf("\nfree_queue: %p, count = %ld\n", &sFreePageQueue, sFreePageQueue.count);
kprintf("clear_queue: %p, count = %d\n", &page_clear_queue, page_clear_queue.count); kprintf("clear_queue: %p, count = %ld\n", &sClearPageQueue, sClearPageQueue.count);
kprintf("modified_queue: %p, count = %d\n", &page_modified_queue, page_modified_queue.count); kprintf("modified_queue: %p, count = %ld\n", &sModifiedPageQueue, sModifiedPageQueue.count);
kprintf("active_queue: %p, count = %d\n", &page_active_queue, page_active_queue.count); kprintf("active_queue: %p, count = %ld\n", &sActivePageQueue, sActivePageQueue.count);
return 0; return 0;
} }
@ -420,16 +423,16 @@ set_page_state_nolock(vm_page *page, int pageState)
case PAGE_STATE_INACTIVE: case PAGE_STATE_INACTIVE:
case PAGE_STATE_WIRED: case PAGE_STATE_WIRED:
case PAGE_STATE_UNUSED: case PAGE_STATE_UNUSED:
from_q = &page_active_queue; from_q = &sActivePageQueue;
break; break;
case PAGE_STATE_MODIFIED: case PAGE_STATE_MODIFIED:
from_q = &page_modified_queue; from_q = &sModifiedPageQueue;
break; break;
case PAGE_STATE_FREE: case PAGE_STATE_FREE:
from_q = &page_free_queue; from_q = &sFreePageQueue;
break; break;
case PAGE_STATE_CLEAR: case PAGE_STATE_CLEAR:
from_q = &page_clear_queue; from_q = &sClearPageQueue;
break; break;
default: default:
panic("vm_page_set_state: vm_page %p in invalid state %d\n", page, page->state); panic("vm_page_set_state: vm_page %p in invalid state %d\n", page, page->state);
@ -450,16 +453,16 @@ set_page_state_nolock(vm_page *page, int pageState)
case PAGE_STATE_INACTIVE: case PAGE_STATE_INACTIVE:
case PAGE_STATE_WIRED: case PAGE_STATE_WIRED:
case PAGE_STATE_UNUSED: case PAGE_STATE_UNUSED:
to_q = &page_active_queue; to_q = &sActivePageQueue;
break; break;
case PAGE_STATE_MODIFIED: case PAGE_STATE_MODIFIED:
to_q = &page_modified_queue; to_q = &sModifiedPageQueue;
break; break;
case PAGE_STATE_FREE: case PAGE_STATE_FREE:
to_q = &page_free_queue; to_q = &sFreePageQueue;
break; break;
case PAGE_STATE_CLEAR: case PAGE_STATE_CLEAR:
to_q = &page_clear_queue; to_q = &sClearPageQueue;
break; break;
default: default:
panic("vm_page_set_state: invalid target state %d\n", pageState); panic("vm_page_set_state: invalid target state %d\n", pageState);
@ -502,7 +505,7 @@ page_scrubber(void *unused)
for (;;) { for (;;) {
snooze(100000); // 100ms snooze(100000); // 100ms
if (page_free_queue.count > 0) { if (sFreePageQueue.count > 0) {
cpu_status state; cpu_status state;
vm_page *page[SCRUB_SIZE]; vm_page *page[SCRUB_SIZE];
int32 i, scrubCount; int32 i, scrubCount;
@ -513,7 +516,7 @@ page_scrubber(void *unused)
acquire_spinlock(&sPageLock); acquire_spinlock(&sPageLock);
for (i = 0; i < SCRUB_SIZE; i++) { for (i = 0; i < SCRUB_SIZE; i++) {
page[i] = dequeue_page(&page_free_queue); page[i] = dequeue_page(&sFreePageQueue);
if (page[i] == NULL) if (page[i] == NULL)
break; break;
page[i]->state = PAGE_STATE_BUSY; page[i]->state = PAGE_STATE_BUSY;
@ -537,7 +540,7 @@ page_scrubber(void *unused)
for (i = 0; i < scrubCount; i++) { for (i = 0; i < scrubCount; i++) {
page[i]->state = PAGE_STATE_CLEAR; page[i]->state = PAGE_STATE_CLEAR;
enqueue_page(&page_clear_queue, page[i]); enqueue_page(&sClearPageQueue, page[i]);
} }
release_spinlock(&sPageLock); release_spinlock(&sPageLock);
@ -567,7 +570,7 @@ static int pageout_daemon()
state = disable_interrupts(); state = disable_interrupts();
acquire_spinlock(&sPageLock); acquire_spinlock(&sPageLock);
page = dequeue_page(&page_modified_queue); page = dequeue_page(&sModifiedPageQueue);
page->state = PAGE_STATE_BUSY; page->state = PAGE_STATE_BUSY;
vm_cache_acquire_ref(page->cache_ref, true); vm_cache_acquire_ref(page->cache_ref, true);
release_spinlock(&sPageLock); release_spinlock(&sPageLock);
@ -580,7 +583,7 @@ static int pageout_daemon()
// that back anonymous stores // that back anonymous stores
state = disable_interrupts(); state = disable_interrupts();
acquire_spinlock(&sPageLock); acquire_spinlock(&sPageLock);
enqueue_page(&page_modified_queue, page); enqueue_page(&sModifiedPageQueue, page);
page->state = PAGE_STATE_MODIFIED; page->state = PAGE_STATE_MODIFIED;
release_spinlock(&sPageLock); release_spinlock(&sPageLock);
restore_interrupts(state); restore_interrupts(state);
@ -618,7 +621,7 @@ static int pageout_daemon()
} else { } else {
page->state = PAGE_STATE_INACTIVE; page->state = PAGE_STATE_INACTIVE;
} }
enqueue_page(&page_active_queue, page); enqueue_page(&sActivePageQueue, page);
release_spinlock(&sPageLock); release_spinlock(&sPageLock);
restore_interrupts(state); restore_interrupts(state);
@ -683,7 +686,7 @@ vm_page_write_modified(vm_cache *cache, bool fsReenter)
acquire_spinlock(&sPageLock); acquire_spinlock(&sPageLock);
if (page->state == PAGE_STATE_MODIFIED) { if (page->state == PAGE_STATE_MODIFIED) {
remove_page_from_queue(&page_modified_queue, page); remove_page_from_queue(&sModifiedPageQueue, page);
page->state = PAGE_STATE_BUSY; page->state = PAGE_STATE_BUSY;
busyCondition.Publish(page, "page"); busyCondition.Publish(page, "page");
gotPage = true; gotPage = true;
@ -754,7 +757,7 @@ vm_page_write_modified(vm_cache *cache, bool fsReenter)
busyCondition.Unpublish(); busyCondition.Unpublish();
enqueue_page(&page_active_queue, page); enqueue_page(&sActivePageQueue, page);
release_spinlock(&sPageLock); release_spinlock(&sPageLock);
restore_interrupts(state); restore_interrupts(state);
@ -767,7 +770,7 @@ vm_page_write_modified(vm_cache *cache, bool fsReenter)
acquire_spinlock(&sPageLock); acquire_spinlock(&sPageLock);
page->state = PAGE_STATE_MODIFIED; page->state = PAGE_STATE_MODIFIED;
enqueue_page(&page_modified_queue, page); enqueue_page(&sModifiedPageQueue, page);
busyCondition.Unpublish(); busyCondition.Unpublish();
@ -812,18 +815,18 @@ vm_page_init(kernel_args *args)
sPageLock = 0; sPageLock = 0;
// initialize queues // initialize queues
page_free_queue.head = NULL; sFreePageQueue.head = NULL;
page_free_queue.tail = NULL; sFreePageQueue.tail = NULL;
page_free_queue.count = 0; sFreePageQueue.count = 0;
page_clear_queue.head = NULL; sClearPageQueue.head = NULL;
page_clear_queue.tail = NULL; sClearPageQueue.tail = NULL;
page_clear_queue.count = 0; sClearPageQueue.count = 0;
page_modified_queue.head = NULL; sModifiedPageQueue.head = NULL;
page_modified_queue.tail = NULL; sModifiedPageQueue.tail = NULL;
page_modified_queue.count = 0; sModifiedPageQueue.count = 0;
page_active_queue.head = NULL; sActivePageQueue.head = NULL;
page_active_queue.tail = NULL; sActivePageQueue.tail = NULL;
page_active_queue.count = 0; sActivePageQueue.count = 0;
// map in the new free page table // map in the new free page table
sPages = (vm_page *)vm_allocate_early(args, sNumPages * sizeof(vm_page), sPages = (vm_page *)vm_allocate_early(args, sNumPages * sizeof(vm_page),
@ -848,7 +851,7 @@ vm_page_init(kernel_args *args)
sPages[i].debug_flags = 0; sPages[i].debug_flags = 0;
sPages[i].collided_page = NULL; sPages[i].collided_page = NULL;
#endif // DEBUG_PAGE_CACHE_TRANSITIONS #endif // DEBUG_PAGE_CACHE_TRANSITIONS
enqueue_page(&page_free_queue, &sPages[i]); enqueue_page(&sFreePageQueue, &sPages[i]);
} }
TRACE(("initialized table\n")); TRACE(("initialized table\n"));
@ -977,10 +980,10 @@ vm_page_allocate_specific_page(addr_t page_num, int page_state)
switch (p->state) { switch (p->state) {
case PAGE_STATE_FREE: case PAGE_STATE_FREE:
remove_page_from_queue(&page_free_queue, p); remove_page_from_queue(&sFreePageQueue, p);
break; break;
case PAGE_STATE_CLEAR: case PAGE_STATE_CLEAR:
remove_page_from_queue(&page_clear_queue, p); remove_page_from_queue(&sClearPageQueue, p);
break; break;
case PAGE_STATE_UNUSED: case PAGE_STATE_UNUSED:
break; break;
@ -995,7 +998,7 @@ vm_page_allocate_specific_page(addr_t page_num, int page_state)
p->state = PAGE_STATE_BUSY; p->state = PAGE_STATE_BUSY;
if (old_page_state != PAGE_STATE_UNUSED) if (old_page_state != PAGE_STATE_UNUSED)
enqueue_page(&page_active_queue, p); enqueue_page(&sActivePageQueue, p);
out: out:
release_spinlock(&sPageLock); release_spinlock(&sPageLock);
@ -1020,12 +1023,12 @@ vm_page_allocate_page(int page_state)
switch (page_state) { switch (page_state) {
case PAGE_STATE_FREE: case PAGE_STATE_FREE:
q = &page_free_queue; q = &sFreePageQueue;
q_other = &page_clear_queue; q_other = &sClearPageQueue;
break; break;
case PAGE_STATE_CLEAR: case PAGE_STATE_CLEAR:
q = &page_clear_queue; q = &sClearPageQueue;
q_other = &page_free_queue; q_other = &sFreePageQueue;
break; break;
default: default:
return NULL; // invalid return NULL; // invalid
@ -1060,7 +1063,7 @@ vm_page_allocate_page(int page_state)
old_page_state = p->state; old_page_state = p->state;
p->state = PAGE_STATE_BUSY; p->state = PAGE_STATE_BUSY;
enqueue_page(&page_active_queue, p); enqueue_page(&sActivePageQueue, p);
release_spinlock(&sPageLock); release_spinlock(&sPageLock);
restore_interrupts(state); restore_interrupts(state);
@ -1191,6 +1194,6 @@ vm_page_num_pages(void)
size_t size_t
vm_page_num_free_pages(void) vm_page_num_free_pages(void)
{ {
return page_free_queue.count + page_clear_queue.count; return sFreePageQueue.count + sClearPageQueue.count;
} }