Commit a30e0568 authored by Kirill Smelkov's avatar Kirill Smelkov

X convert everythig to CHECK_MRU

parent 8461fbf0
...@@ -223,7 +223,7 @@ int M(VMA *vma, pgoff_t idx) { return bitmap_test_bit(vma->page_ismappedv, idx) ...@@ -223,7 +223,7 @@ int M(VMA *vma, pgoff_t idx) { return bitmap_test_bit(vma->page_ismappedv, idx)
ok1(!pagemap_get(&(fileh)->pagemap, (pgoffset))); \ ok1(!pagemap_get(&(fileh)->pagemap, (pgoffset))); \
} while (0) } while (0)
/* check that ram has MRU pages as specified by pagev */ /* _check_mru checks that ram has MRU pages as specified by pagev */
void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char *file, int line) { void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char *file, int line) {
Page **mruv = NULL, *page; Page **mruv = NULL, *page;
int n = 0, i; int n = 0, i;
...@@ -235,9 +235,10 @@ void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char * ...@@ -235,9 +235,10 @@ void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char *
n++; n++;
mruv = realloc(mruv, n*sizeof(*mruv)); mruv = realloc(mruv, n*sizeof(*mruv));
mruv[n-1] = page; mruv[n-1] = page;
hlru = hlru->prev;
} }
if (!(n == nok && memcmp(mruv, mruok, n))) { if (!(n == nok && !memcmp(mruv, mruok, n*sizeof(*mruok)))) {
fprintf(stderr, "check_mru: different\n"); fprintf(stderr, "check_mru: different\n");
fprintf(stderr, "have: ["); fprintf(stderr, "have: [");
for (i=0; i<n; i++) for (i=0; i<n; i++)
...@@ -253,7 +254,7 @@ void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char * ...@@ -253,7 +254,7 @@ void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char *
free(mruv); free(mruv);
} }
// CHECK_MRU(ram, ...pagev) /* CHECK_MRU(ram, ...pagev) - check that ram has MRU pages as expected */
#define CHECK_MRU(ram, ...) do { \ #define CHECK_MRU(ram, ...) do { \
Page *__mruok[] = {__VA_ARGS__}; \ Page *__mruok[] = {__VA_ARGS__}; \
_check_mru(ram, __mruok, ARRAY_SIZE(__mruok), __func__, __FILE__, __LINE__); \ _check_mru(ram, __mruok, ARRAY_SIZE(__mruok), __func__, __FILE__, __LINE__); \
...@@ -333,7 +334,7 @@ void test_file_access_synthetic(void) ...@@ -333,7 +334,7 @@ void test_file_access_synthetic(void)
PSb = PS / sizeof(blk_t); /* page size in blk_t units */ PSb = PS / sizeof(blk_t); /* page size in blk_t units */
/* ensure we are starting from new ram */ /* ensure we are starting from new ram */
ok1(list_empty(&ram->lru_list)); CHECK_MRU(ram /*empty*/);
/* setup id file */ /* setup id file */
struct bigfile_ops x_ops = {.loadblk = fileid_loadblk}; struct bigfile_ops x_ops = {.loadblk = fileid_loadblk};
...@@ -370,7 +371,7 @@ void test_file_access_synthetic(void) ...@@ -370,7 +371,7 @@ void test_file_access_synthetic(void)
CHECK_NOPAGE( 102 ); CHECK_NOPAGE( 102 );
CHECK_NOPAGE( 103 ); CHECK_NOPAGE( 103 );
ok1(list_empty(&ram->lru_list)); CHECK_MRU(ram /*empty*/);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
...@@ -393,9 +394,7 @@ void test_file_access_synthetic(void) ...@@ -393,9 +394,7 @@ void test_file_access_synthetic(void)
ok1(B(vma, 0*PSb + 1) == 100); ok1(B(vma, 0*PSb + 1) == 100);
ok1(B(vma, 0*PSb + PSb - 1) == 100); ok1(B(vma, 0*PSb + PSb - 1) == 100);
ok1(ram->lru_list.prev == &page0->lru); CHECK_MRU(ram, page0);
ok1(page0->lru.prev == &ram->lru_list);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
...@@ -421,10 +420,7 @@ void test_file_access_synthetic(void) ...@@ -421,10 +420,7 @@ void test_file_access_synthetic(void)
ok1(B(vma, 2*PSb + 1) == 102); ok1(B(vma, 2*PSb + 1) == 102);
ok1(B(vma, 2*PSb + PSb - 1) == 102); ok1(B(vma, 2*PSb + PSb - 1) == 102);
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU(ram, page2, page0);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page2->in_dirty); ok1(fh->dirty_pages.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -454,11 +450,7 @@ void test_file_access_synthetic(void) ...@@ -454,11 +450,7 @@ void test_file_access_synthetic(void)
ok1(B(vma, 3*PSb + 1) == 103); ok1(B(vma, 3*PSb + 1) == 103);
ok1(B(vma, 3*PSb + PSb - 1) == 103); ok1(B(vma, 3*PSb + PSb - 1) == 103);
ok1(ram->lru_list.prev == &page3->lru); CHECK_MRU(ram, page3, page2, page0);
ok1(page3->lru.prev == &page2->lru);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page2->in_dirty); ok1(fh->dirty_pages.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -488,10 +480,6 @@ void test_file_access_synthetic(void) ...@@ -488,10 +480,6 @@ void test_file_access_synthetic(void)
ok1(B(vma, 3*PSb + PSb - 1) == 103); ok1(B(vma, 3*PSb + PSb - 1) == 103);
CHECK_MRU(ram, page0, page3, page2); /* page0 became MRU */ CHECK_MRU(ram, page0, page3, page2); /* page0 became MRU */
ok1(ram->lru_list.prev == &page0->lru); /* page0 became MRU */
ok1(page0->lru.prev == &page3->lru);
ok1(page3->lru.prev == &page2->lru);
ok1(page2->lru.prev == &ram->lru_list);
//CHECK_DIRTY(fh, page0, page2); //CHECK_DIRTY(fh, page0, page2);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
...@@ -530,11 +518,7 @@ void test_file_access_synthetic(void) ...@@ -530,11 +518,7 @@ void test_file_access_synthetic(void)
ok1(B(vma, 2*PSb + 1) == 102); ok1(B(vma, 2*PSb + 1) == 102);
ok1(B(vma, 2*PSb + PSb - 1) == 102); ok1(B(vma, 2*PSb + PSb - 1) == 102);
ok1(ram->lru_list.prev == &page1->lru); CHECK_MRU(ram, page1, page0, page2);
ok1(page1->lru.prev == &page0->lru);
ok1(page0->lru.prev == &page2->lru);
ok1(page2->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
ok1(page0->in_dirty.prev == &page2->in_dirty); ok1(page0->in_dirty.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -564,10 +548,7 @@ void test_file_access_synthetic(void) ...@@ -564,10 +548,7 @@ void test_file_access_synthetic(void)
ok1(B(vma, 2*PSb + PSb - 1) == 102); ok1(B(vma, 2*PSb + PSb - 1) == 102);
/* page[3] went away */ /* page[3] went away */
ok1(ram->lru_list.prev == &page0->lru); CHECK_MRU(ram, page0, page2);
ok1(page0->lru.prev == &page2->lru);
ok1(page2->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
ok1(page0->in_dirty.prev == &page2->in_dirty); ok1(page0->in_dirty.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -585,10 +566,7 @@ void test_file_access_synthetic(void) ...@@ -585,10 +566,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_DIRTY, 0); CHECK_PAGE (page2, 102, PAGE_DIRTY, 0);
CHECK_NOPAGE( 103 ); CHECK_NOPAGE( 103 );
ok1(ram->lru_list.prev == &page0->lru); CHECK_MRU(ram, page0, page2);
ok1(page0->lru.prev == &page2->lru);
ok1(page2->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
ok1(page0->in_dirty.prev == &page2->in_dirty); ok1(page0->in_dirty.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -627,10 +605,7 @@ void test_file_access_synthetic(void) ...@@ -627,10 +605,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_DIRTY, 0); CHECK_PAGE (page2, 102, PAGE_DIRTY, 0);
CHECK_NOPAGE( 103 ); CHECK_NOPAGE( 103 );
ok1(ram->lru_list.prev == &page0->lru); CHECK_MRU(ram, page0, page2);
ok1(page0->lru.prev == &page2->lru);
ok1(page2->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
ok1(page0->in_dirty.prev == &page2->in_dirty); ok1(page0->in_dirty.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -650,10 +625,7 @@ void test_file_access_synthetic(void) ...@@ -650,10 +625,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_DIRTY, 1); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1);
CHECK_NOPAGE( 103 ); CHECK_NOPAGE( 103 );
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU(ram, page2, page0);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
ok1(page0->in_dirty.prev == &page2->in_dirty); ok1(page0->in_dirty.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -673,10 +645,7 @@ void test_file_access_synthetic(void) ...@@ -673,10 +645,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_EMPTY, 0); CHECK_PAGE (page2, 102, PAGE_EMPTY, 0);
CHECK_NOPAGE( 103 ); CHECK_NOPAGE( 103 );
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU (ram, page2, page0);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &ram->lru_list);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
...@@ -711,11 +680,7 @@ void test_file_access_synthetic(void) ...@@ -711,11 +680,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_EMPTY, 0); CHECK_PAGE (page2, 102, PAGE_EMPTY, 0);
CHECK_PAGE (page3, 103, PAGE_LOADED, 1); CHECK_PAGE (page3, 103, PAGE_LOADED, 1);
ok1(ram->lru_list.prev == &page3->lru); CHECK_MRU(ram, page3, page2, page0);
ok1(page3->lru.prev == &page2->lru);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &ram->lru_list);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
...@@ -738,11 +703,7 @@ void test_file_access_synthetic(void) ...@@ -738,11 +703,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_DIRTY, 1); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1);
CHECK_PAGE (page3, 103, PAGE_LOADED, 0); CHECK_PAGE (page3, 103, PAGE_LOADED, 0);
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU (ram, page2, page0, page3);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &page3->lru);
ok1(page3->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
ok1(page0->in_dirty.prev == &page2->in_dirty); ok1(page0->in_dirty.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -788,11 +749,7 @@ void test_file_access_synthetic(void) ...@@ -788,11 +749,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_LOADED, 1); CHECK_PAGE (page2, 102, PAGE_LOADED, 1);
CHECK_PAGE (page3, 103, PAGE_LOADED, 0); CHECK_PAGE (page3, 103, PAGE_LOADED, 0);
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU (ram, page2, page0, page3);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &page3->lru);
ok1(page3->lru.prev == &ram->lru_list);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
diag("writeout (store+mark)"); diag("writeout (store+mark)");
...@@ -814,11 +771,7 @@ void test_file_access_synthetic(void) ...@@ -814,11 +771,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_LOADED, 1); CHECK_PAGE (page2, 102, PAGE_LOADED, 1);
CHECK_PAGE (page3, 103, PAGE_LOADED, 0); CHECK_PAGE (page3, 103, PAGE_LOADED, 0);
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU(ram, page2, page0, page3);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &page3->lru);
ok1(page3->lru.prev == &ram->lru_list);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
/* invalidation */ /* invalidation */
...@@ -837,11 +790,7 @@ void test_file_access_synthetic(void) ...@@ -837,11 +790,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_DIRTY, 1); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1);
CHECK_PAGE (page3, 103, PAGE_LOADED, 0); CHECK_PAGE (page3, 103, PAGE_LOADED, 0);
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU(ram, page2, page0, page3);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &page3->lru);
ok1(page3->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
ok1(page0->in_dirty.prev == &page2->in_dirty); ok1(page0->in_dirty.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -859,11 +808,7 @@ void test_file_access_synthetic(void) ...@@ -859,11 +808,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_DIRTY, 1); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1);
CHECK_PAGE (page3, 103, PAGE_EMPTY, 0); CHECK_PAGE (page3, 103, PAGE_EMPTY, 0);
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU(ram, page2, page0, page3);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &page3->lru);
ok1(page3->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
ok1(page0->in_dirty.prev == &page2->in_dirty); ok1(page0->in_dirty.prev == &page2->in_dirty);
ok1(page2->in_dirty.prev == &fh->dirty_pages); ok1(page2->in_dirty.prev == &fh->dirty_pages);
...@@ -881,11 +826,7 @@ void test_file_access_synthetic(void) ...@@ -881,11 +826,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_EMPTY, 0); CHECK_PAGE (page2, 102, PAGE_EMPTY, 0);
CHECK_PAGE (page3, 103, PAGE_EMPTY, 0); CHECK_PAGE (page3, 103, PAGE_EMPTY, 0);
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU(ram, page2, page0, page3);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &page3->lru);
ok1(page3->lru.prev == &ram->lru_list);
ok1(fh->dirty_pages.prev == &page0->in_dirty); ok1(fh->dirty_pages.prev == &page0->in_dirty);
ok1(page0->in_dirty.prev == &fh->dirty_pages); ok1(page0->in_dirty.prev == &fh->dirty_pages);
...@@ -902,11 +843,7 @@ void test_file_access_synthetic(void) ...@@ -902,11 +843,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_EMPTY, 0); CHECK_PAGE (page2, 102, PAGE_EMPTY, 0);
CHECK_PAGE (page3, 103, PAGE_EMPTY, 0); CHECK_PAGE (page3, 103, PAGE_EMPTY, 0);
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU(ram, page2, page0, page3);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &page3->lru);
ok1(page3->lru.prev == &ram->lru_list);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
/* read page[3] back */ /* read page[3] back */
...@@ -922,11 +859,7 @@ void test_file_access_synthetic(void) ...@@ -922,11 +859,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page2, 102, PAGE_EMPTY, 0); CHECK_PAGE (page2, 102, PAGE_EMPTY, 0);
CHECK_PAGE (page3, 103, PAGE_LOADED, 1); CHECK_PAGE (page3, 103, PAGE_LOADED, 1);
ok1(ram->lru_list.prev == &page3->lru); CHECK_MRU(ram, page3, page2, page0);
ok1(page3->lru.prev == &page2->lru);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &ram->lru_list);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
...@@ -936,15 +869,15 @@ void test_file_access_synthetic(void) ...@@ -936,15 +869,15 @@ void test_file_access_synthetic(void)
vma_unmap(vma); vma_unmap(vma);
/* ensure pages stay in ram lru with expected state */ /* ensure pages stay in ram lru with expected state */
ok1(ram->lru_list.prev == &page2->lru); ok1(page2->state == PAGE_DIRTY); CHECK_MRU(ram, page2, page0, page3);
ok1(page2->lru.prev == &page0->lru); ok1(page0->state == PAGE_DIRTY); ok1(page2->state == PAGE_DIRTY);
ok1(page0->lru.prev == &page3->lru); ok1(page3->state == PAGE_LOADED); ok1(page0->state == PAGE_DIRTY);
ok1(page3->lru.prev == &ram->lru_list); ok1(page3->state == PAGE_LOADED);
fileh_close(fh); fileh_close(fh);
/* pages associated with fileh should go away after fileh_close() */ /* pages associated with fileh should go away after fileh_close() */
ok1(list_empty(&ram->lru_list)); CHECK_MRU(ram /*empty*/);
/* free resources & restore SIGSEGV handler */ /* free resources & restore SIGSEGV handler */
...@@ -984,7 +917,7 @@ void test_file_access_pagefault() ...@@ -984,7 +917,7 @@ void test_file_access_pagefault()
PSb = PS / sizeof(blk_t); /* page size in blk_t units */ PSb = PS / sizeof(blk_t); /* page size in blk_t units */
/* ensure we are starting from new ram */ /* ensure we are starting from new ram */
ok1(list_empty(&ram->lru_list)); CHECK_MRU(ram /*empty*/);
/* setup id file */ /* setup id file */
BigFileIdentity fileid = { BigFileIdentity fileid = {
...@@ -1009,7 +942,7 @@ void test_file_access_pagefault() ...@@ -1009,7 +942,7 @@ void test_file_access_pagefault()
ok1(!M(vma, 2)); CHECK_NOPAGE( 102 ); ok1(!M(vma, 2)); CHECK_NOPAGE( 102 );
ok1(!M(vma, 3)); CHECK_NOPAGE( 103 ); ok1(!M(vma, 3)); CHECK_NOPAGE( 103 );
ok1(list_empty(&ram->lru_list)); CHECK_MRU(ram, /*empty*/);
/* read page[0] */ /* read page[0] */
ok1(B(vma, 0*PSb) == 100); ok1(B(vma, 0*PSb) == 100);
...@@ -1020,8 +953,7 @@ void test_file_access_pagefault() ...@@ -1020,8 +953,7 @@ void test_file_access_pagefault()
ok1(!M(vma, 2)); CHECK_NOPAGE( 102 ); ok1(!M(vma, 2)); CHECK_NOPAGE( 102 );
ok1(!M(vma, 3)); CHECK_NOPAGE( 103 ); ok1(!M(vma, 3)); CHECK_NOPAGE( 103 );
ok1(ram->lru_list.prev == &page0->lru); CHECK_MRU(ram, page0);
ok1(page0->lru.prev == &ram->lru_list);
/* write to page[2] */ /* write to page[2] */
...@@ -1033,9 +965,7 @@ void test_file_access_pagefault() ...@@ -1033,9 +965,7 @@ void test_file_access_pagefault()
ok1( M(vma, 2)); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1); ok1( M(vma, 2)); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1);
ok1(!M(vma, 3)); CHECK_NOPAGE( 103 ); ok1(!M(vma, 3)); CHECK_NOPAGE( 103 );
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU(ram, page2, page0);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &ram->lru_list);
/* read page[3] */ /* read page[3] */
...@@ -1047,10 +977,7 @@ void test_file_access_pagefault() ...@@ -1047,10 +977,7 @@ void test_file_access_pagefault()
ok1( M(vma, 2)); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1); ok1( M(vma, 2)); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1);
ok1( M(vma, 3)); CHECK_PAGE (page3, 103, PAGE_LOADED, 1); ok1( M(vma, 3)); CHECK_PAGE (page3, 103, PAGE_LOADED, 1);
ok1(ram->lru_list.prev == &page3->lru); CHECK_MRU(ram, page3, page2, page0);
ok1(page3->lru.prev == &page2->lru);
ok1(page2->lru.prev == &page0->lru);
ok1(page0->lru.prev == &ram->lru_list);
/* write to page[0] */ /* write to page[0] */
...@@ -1061,10 +988,7 @@ void test_file_access_pagefault() ...@@ -1061,10 +988,7 @@ void test_file_access_pagefault()
ok1( M(vma, 2)); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1); ok1( M(vma, 2)); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1);
ok1( M(vma, 3)); CHECK_PAGE (page3, 103, PAGE_LOADED, 1); ok1( M(vma, 3)); CHECK_PAGE (page3, 103, PAGE_LOADED, 1);
ok1(ram->lru_list.prev == &page0->lru); /* page0 became MRU */ CHECK_MRU(ram, page0, page3, page2); /* page0 became MRU */
ok1(page0->lru.prev == &page3->lru);
ok1(page3->lru.prev == &page2->lru);
ok1(page2->lru.prev == &ram->lru_list);
/* unmap vma */ /* unmap vma */
...@@ -1234,7 +1158,7 @@ void test_file_access_mmapbase(void) ...@@ -1234,7 +1158,7 @@ void test_file_access_mmapbase(void)
PSb = PS / sizeof(blk_t); /* page size in blk_t units */ PSb = PS / sizeof(blk_t); /* page size in blk_t units */
/* ensure we are starting from new ram */ /* ensure we are starting from new ram */
ok1(list_empty(&ram->lru_list)); CHECK_MRU(ram /*empty*/);
/* setup mmaped file */ /* setup mmaped file */
char path[] = "/tmp/bigfile_mmap.XXXXXX"; char path[] = "/tmp/bigfile_mmap.XXXXXX";
...@@ -1286,7 +1210,7 @@ void test_file_access_mmapbase(void) ...@@ -1286,7 +1210,7 @@ void test_file_access_mmapbase(void)
ok1(!M(vma, 2)); CHECK_NOPAGE( 102 ); ok1(!M(vma, 2)); CHECK_NOPAGE( 102 );
ok1(!M(vma, 3)); CHECK_NOPAGE( 103 ); ok1(!M(vma, 3)); CHECK_NOPAGE( 103 );
ok1(list_empty(&ram->lru_list)); CHECK_MRU(ram /*empty*/);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
/* read page[0] - served from base mmap and no RAM page is loaded */ /* read page[0] - served from base mmap and no RAM page is loaded */
...@@ -1299,7 +1223,7 @@ void test_file_access_mmapbase(void) ...@@ -1299,7 +1223,7 @@ void test_file_access_mmapbase(void)
ok1(!M(vma, 2)); CHECK_NOPAGE( 102 ); ok1(!M(vma, 2)); CHECK_NOPAGE( 102 );
ok1(!M(vma, 3)); CHECK_NOPAGE( 103 ); ok1(!M(vma, 3)); CHECK_NOPAGE( 103 );
ok1(list_empty(&ram->lru_list)); CHECK_MRU(ram /*empty*/);
ok1(list_empty(&fh->dirty_pages)); ok1(list_empty(&fh->dirty_pages));
/* write to page[2] - page2 is copy-on-write created in RAM */ /* write to page[2] - page2 is copy-on-write created in RAM */
...@@ -1317,8 +1241,6 @@ void test_file_access_mmapbase(void) ...@@ -1317,8 +1241,6 @@ void test_file_access_mmapbase(void)
CHECK_MRU(ram, page2); CHECK_MRU(ram, page2);
//CHECK_DIRTY(fh, page2); //CHECK_DIRTY(fh, page2);
ok1(ram->lru_list.prev == &page2->lru);
ok1(page2->lru.prev == &ram->lru_list);
/* read page[3] - served from base mmap */ /* read page[3] - served from base mmap */
ok1(B(vma, 3*PSb + 0) == 103); ok1(B(vma, 3*PSb + 0) == 103);
...@@ -1330,8 +1252,8 @@ void test_file_access_mmapbase(void) ...@@ -1330,8 +1252,8 @@ void test_file_access_mmapbase(void)
ok1( M(vma, 2)); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1); ok1( M(vma, 2)); CHECK_PAGE (page2, 102, PAGE_DIRTY, 1);
ok1(!M(vma, 3)); CHECK_NOPAGE( 103 ); ok1(!M(vma, 3)); CHECK_NOPAGE( 103 );
ok1(ram->lru_list.prev == &page2->lru); CHECK_MRU(ram, page2);
ok1(page2->lru.prev == &ram->lru_list); // XXX CHECK_DIRTY
/* write to page[0] - page COW'ed into RAM */ /* write to page[0] - page COW'ed into RAM */
B(vma, 0*PSb) = 10; B(vma, 0*PSb) = 10;
...@@ -1346,9 +1268,8 @@ void test_file_access_mmapbase(void) ...@@ -1346,9 +1268,8 @@ void test_file_access_mmapbase(void)
ok1(B(vma, 0*PSb + 1) == 100); ok1(B(vma, 0*PSb + 1) == 100);
ok1(B(vma, 0*PSb + PSb - 1) == 100); ok1(B(vma, 0*PSb + PSb - 1) == 100);
ok1(ram->lru_list.prev == &page0->lru); CHECK_MRU(ram, page0, page2);
ok1(page0->lru.prev == &page2->lru); // XXX dirty
ok1(page2->lru.prev == &ram->lru_list);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment