Commit 38c08e6e authored by Kirill Smelkov's avatar Kirill Smelkov

X Bind CHECK_MRU and CHECK_DIRTY to ram and fh

parent 82e2d956
...@@ -275,8 +275,8 @@ void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char * ...@@ -275,8 +275,8 @@ void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char *
free(mruv); free(mruv);
} }
/* CHECK_MRU(ram, ...pagev) - assert that ram has MRU pages as expected */ /* __CHECK_MRU(ram, ...pagev) - assert 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__); \
} while(0) } while(0)
...@@ -302,8 +302,8 @@ void _check_dirty(BigFileH *fileh, Page *dirtyok[], int nok, const char *func, c ...@@ -302,8 +302,8 @@ void _check_dirty(BigFileH *fileh, Page *dirtyok[], int nok, const char *func, c
} }
/* CHECK_DIRTY(fileh, ...pagev) - assert that fileh has dirty pages as expected */ /* __CHECK_DIRTY(fileh, ...pagev) - assert that fileh has dirty pages as expected */
#define CHECK_DIRTY(fileh, ...) do { \ #define __CHECK_DIRTY(fileh, ...) do { \
Page *__dirtyok[] = {__VA_ARGS__}; \ Page *__dirtyok[] = {__VA_ARGS__}; \
_check_dirty(fileh, __dirtyok, ARRAY_SIZE(__dirtyok), __func__, __FILE__, __LINE__); \ _check_dirty(fileh, __dirtyok, ARRAY_SIZE(__dirtyok), __func__, __FILE__, __LINE__); \
} while(0) } while(0)
...@@ -382,8 +382,11 @@ void test_file_access_synthetic(void) ...@@ -382,8 +382,11 @@ void test_file_access_synthetic(void)
PS = ram->pagesize; PS = ram->pagesize;
PSb = PS / sizeof(blk_t); /* page size in blk_t units */ PSb = PS / sizeof(blk_t); /* page size in blk_t units */
/* implicitly use ram=ram */
#define CHECK_MRU(...) __CHECK_MRU(ram, __VA_ARGS__)
/* ensure we are starting from new ram */ /* ensure we are starting from new ram */
CHECK_MRU(ram /*empty*/); CHECK_MRU(/*empty*/);
/* setup id file */ /* setup id file */
struct bigfile_ops x_ops = {.loadblk = fileid_loadblk}; struct bigfile_ops x_ops = {.loadblk = fileid_loadblk};
...@@ -400,6 +403,7 @@ void test_file_access_synthetic(void) ...@@ -400,6 +403,7 @@ void test_file_access_synthetic(void)
#define CHECK_PAGE(page, pgoffset, pgstate, pgrefcnt) \ #define CHECK_PAGE(page, pgoffset, pgstate, pgrefcnt) \
__CHECK_PAGE(page, fh, pgoffset, pgstate, pgrefcnt) __CHECK_PAGE(page, fh, pgoffset, pgstate, pgrefcnt)
#define CHECK_NOPAGE(pgoffset) __CHECK_NOPAGE(fh, pgoffset) #define CHECK_NOPAGE(pgoffset) __CHECK_NOPAGE(fh, pgoffset)
#define CHECK_DIRTY(...) __CHECK_DIRTY(fh, __VA_ARGS__)
err = fileh_mmap(vma, fh, 100, 4); err = fileh_mmap(vma, fh, 100, 4);
...@@ -420,8 +424,8 @@ void test_file_access_synthetic(void) ...@@ -420,8 +424,8 @@ void test_file_access_synthetic(void)
CHECK_NOPAGE( 102 ); CHECK_NOPAGE( 102 );
CHECK_NOPAGE( 103 ); CHECK_NOPAGE( 103 );
CHECK_MRU (ram /*empty*/); CHECK_MRU (/*empty*/);
CHECK_DIRTY (fh /*empty */); CHECK_DIRTY (/*empty */);
/* simulate read access to page[0] - it should load it */ /* simulate read access to page[0] - it should load it */
...@@ -443,8 +447,8 @@ void test_file_access_synthetic(void) ...@@ -443,8 +447,8 @@ 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);
CHECK_MRU(ram, page0); CHECK_MRU (page0);
CHECK_DIRTY(fh /*empty*/); CHECK_DIRTY (/*empty*/);
/* simulate write access to page[2] - it should load it and mark page dirty */ /* simulate write access to page[2] - it should load it and mark page dirty */
...@@ -469,8 +473,8 @@ void test_file_access_synthetic(void) ...@@ -469,8 +473,8 @@ 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);
CHECK_MRU (ram, page2, page0); CHECK_MRU (page2, page0);
CHECK_DIRTY (fh, page2); CHECK_DIRTY (page2);
/* read access to page[3] - load */ /* read access to page[3] - load */
...@@ -498,8 +502,8 @@ void test_file_access_synthetic(void) ...@@ -498,8 +502,8 @@ 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);
CHECK_MRU (ram, page3, page2, page0); CHECK_MRU (page3, page2, page0);
CHECK_DIRTY (fh, page2); CHECK_DIRTY (page2);
/* write access to page[0] - upgrade loaded -> dirty */ /* write access to page[0] - upgrade loaded -> dirty */
...@@ -526,8 +530,8 @@ void test_file_access_synthetic(void) ...@@ -526,8 +530,8 @@ 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);
CHECK_MRU (ram, page0, page3, page2); /* page0 became MRU */ CHECK_MRU (page0, page3, page2); /* page0 became MRU */
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
/* read page[1] /* read page[1]
...@@ -561,8 +565,8 @@ void test_file_access_synthetic(void) ...@@ -561,8 +565,8 @@ 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);
CHECK_MRU (ram, page1, page0, page2); CHECK_MRU (page1, page0, page2);
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
/* now explicit reclaim - should evict page[1] (the only PAGE_LOADED page) */ /* now explicit reclaim - should evict page[1] (the only PAGE_LOADED page) */
...@@ -589,8 +593,8 @@ void test_file_access_synthetic(void) ...@@ -589,8 +593,8 @@ 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 */
CHECK_MRU (ram, page0, page2); CHECK_MRU (page0, page2);
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
/* unmap vma - dirty pages should stay in fh->pagemap and memory should /* unmap vma - dirty pages should stay in fh->pagemap and memory should
...@@ -605,8 +609,8 @@ void test_file_access_synthetic(void) ...@@ -605,8 +609,8 @@ 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 );
CHECK_MRU (ram, page0, page2); CHECK_MRU (page0, page2);
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
b0 = page_mmap(page0, NULL, PROT_READ); b0 = page_mmap(page0, NULL, PROT_READ);
ok1(b0); ok1(b0);
...@@ -642,8 +646,8 @@ void test_file_access_synthetic(void) ...@@ -642,8 +646,8 @@ 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 );
CHECK_MRU (ram, page0, page2); CHECK_MRU (page0, page2);
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
/* read access to page[2] - should map it R/W - the page is in PAGE_DIRTY state */ /* read access to page[2] - should map it R/W - the page is in PAGE_DIRTY state */
...@@ -660,8 +664,8 @@ void test_file_access_synthetic(void) ...@@ -660,8 +664,8 @@ 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 );
CHECK_MRU (ram, page2, page0); CHECK_MRU (page2, page0);
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
/* discard - changes should go away */ /* discard - changes should go away */
...@@ -678,8 +682,8 @@ void test_file_access_synthetic(void) ...@@ -678,8 +682,8 @@ 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 );
CHECK_MRU (ram, page2, page0); CHECK_MRU (page2, page0);
CHECK_DIRTY (fh /*empty*/); CHECK_DIRTY (/*empty*/);
/* writeout in 3 variants - STORE, MARK, STORE+MARK */ /* writeout in 3 variants - STORE, MARK, STORE+MARK */
...@@ -713,8 +717,8 @@ void test_file_access_synthetic(void) ...@@ -713,8 +717,8 @@ 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);
CHECK_MRU (ram, page3, page2, page0); CHECK_MRU (page3, page2, page0);
CHECK_DIRTY (fh /*empty*/); CHECK_DIRTY (/*empty*/);
/* prepare state (2 dirty pages, only 1 mapped) */ /* prepare state (2 dirty pages, only 1 mapped) */
...@@ -736,8 +740,8 @@ void test_file_access_synthetic(void) ...@@ -736,8 +740,8 @@ 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);
CHECK_MRU (ram, page2, page0, page3); CHECK_MRU (page2, page0, page3);
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
} }
diag("writeout (store)"); diag("writeout (store)");
...@@ -760,7 +764,7 @@ void test_file_access_synthetic(void) ...@@ -760,7 +764,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE (page3, 103, PAGE_LOADED, 0); CHECK_PAGE (page3, 103, PAGE_LOADED, 0);
/* NOTE - becomes sorted by ->f_pgoffset */ /* NOTE - becomes sorted by ->f_pgoffset */
CHECK_DIRTY (fh, page2, page0); /* checked in reverse order */ CHECK_DIRTY (page2, page0); /* checked in reverse order */
diag("writeout (mark)"); diag("writeout (mark)");
blkv_len = 0; blkv_len = 0;
...@@ -778,8 +782,8 @@ void test_file_access_synthetic(void) ...@@ -778,8 +782,8 @@ 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);
CHECK_MRU (ram, page2, page0, page3); CHECK_MRU (page2, page0, page3);
CHECK_DIRTY (fh /*empty*/); CHECK_DIRTY (/*empty*/);
diag("writeout (store+mark)"); diag("writeout (store+mark)");
mkdirty2(); mkdirty2();
...@@ -800,8 +804,8 @@ void test_file_access_synthetic(void) ...@@ -800,8 +804,8 @@ 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);
CHECK_MRU (ram, page2, page0, page3); CHECK_MRU (page2, page0, page3);
CHECK_DIRTY (fh /*empty*/); CHECK_DIRTY (/*empty*/);
/* invalidation */ /* invalidation */
diag("invalidate"); diag("invalidate");
...@@ -819,8 +823,8 @@ void test_file_access_synthetic(void) ...@@ -819,8 +823,8 @@ 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);
CHECK_MRU (ram, page2, page0, page3); CHECK_MRU (page2, page0, page3);
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
fileh_invalidate_page(fh, 103); fileh_invalidate_page(fh, 103);
...@@ -835,8 +839,8 @@ void test_file_access_synthetic(void) ...@@ -835,8 +839,8 @@ 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);
CHECK_MRU (ram, page2, page0, page3); CHECK_MRU (page2, page0, page3);
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
fileh_invalidate_page(fh, 102); fileh_invalidate_page(fh, 102);
...@@ -851,8 +855,8 @@ void test_file_access_synthetic(void) ...@@ -851,8 +855,8 @@ 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);
CHECK_MRU (ram, page2, page0, page3); CHECK_MRU (page2, page0, page3);
CHECK_DIRTY (fh, page0); CHECK_DIRTY (page0);
fileh_invalidate_page(fh, 100); fileh_invalidate_page(fh, 100);
...@@ -867,8 +871,8 @@ void test_file_access_synthetic(void) ...@@ -867,8 +871,8 @@ 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);
CHECK_MRU (ram, page2, page0, page3); CHECK_MRU (page2, page0, page3);
CHECK_DIRTY (fh /*empty*/); CHECK_DIRTY (/*empty*/);
/* read page[3] back */ /* read page[3] back */
xvma_on_pagefault(vma, vma->addr_start + 3*PS, 0); xvma_on_pagefault(vma, vma->addr_start + 3*PS, 0);
...@@ -883,8 +887,8 @@ void test_file_access_synthetic(void) ...@@ -883,8 +887,8 @@ 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);
CHECK_MRU (ram, page3, page2, page0); CHECK_MRU (page3, page2, page0);
CHECK_DIRTY (fh /*empty*/); CHECK_DIRTY (/*empty*/);
diag("fileh_close"); diag("fileh_close");
...@@ -893,7 +897,7 @@ void test_file_access_synthetic(void) ...@@ -893,7 +897,7 @@ 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 */
CHECK_MRU(ram, page2, page0, page3); CHECK_MRU(page2, page0, page3);
ok1(page2->state == PAGE_DIRTY); ok1(page2->state == PAGE_DIRTY);
ok1(page0->state == PAGE_DIRTY); ok1(page0->state == PAGE_DIRTY);
ok1(page3->state == PAGE_LOADED); ok1(page3->state == PAGE_LOADED);
...@@ -901,7 +905,7 @@ void test_file_access_synthetic(void) ...@@ -901,7 +905,7 @@ void test_file_access_synthetic(void)
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() */
CHECK_MRU(ram /*empty*/); CHECK_MRU(/*empty*/);
/* free resources & restore SIGSEGV handler */ /* free resources & restore SIGSEGV handler */
...@@ -910,8 +914,10 @@ void test_file_access_synthetic(void) ...@@ -910,8 +914,10 @@ void test_file_access_synthetic(void)
ok1(!sigaction(SIGSEGV, &saveact, NULL)); ok1(!sigaction(SIGSEGV, &saveact, NULL));
#undef CHECK_MRU
#undef CHECK_PAGE #undef CHECK_PAGE
#undef CHECK_NOPAGE #undef CHECK_NOPAGE
#undef CHECK_DIRTY
} }
...@@ -940,8 +946,11 @@ void test_file_access_pagefault() ...@@ -940,8 +946,11 @@ void test_file_access_pagefault()
PS = ram->pagesize; PS = ram->pagesize;
PSb = PS / sizeof(blk_t); /* page size in blk_t units */ PSb = PS / sizeof(blk_t); /* page size in blk_t units */
/* implicitly use ram=ram */
#define CHECK_MRU(...) __CHECK_MRU(ram, __VA_ARGS__)
/* ensure we are starting from new ram */ /* ensure we are starting from new ram */
CHECK_MRU(ram /*empty*/); CHECK_MRU(/*empty*/);
/* setup id file */ /* setup id file */
BigFileIdentity fileid = { BigFileIdentity fileid = {
...@@ -956,6 +965,7 @@ void test_file_access_pagefault() ...@@ -956,6 +965,7 @@ void test_file_access_pagefault()
#define CHECK_PAGE(page, pgoffset, pgstate, pgrefcnt) \ #define CHECK_PAGE(page, pgoffset, pgstate, pgrefcnt) \
__CHECK_PAGE(page, fh, pgoffset, pgstate, pgrefcnt) __CHECK_PAGE(page, fh, pgoffset, pgstate, pgrefcnt)
#define CHECK_NOPAGE(pgoffset) __CHECK_NOPAGE(fh, pgoffset) #define CHECK_NOPAGE(pgoffset) __CHECK_NOPAGE(fh, pgoffset)
#define CHECK_DIRTY(...) __CHECK_DIRTY(fh, __VA_ARGS__)
err = fileh_mmap(vma, fh, 100, 4); err = fileh_mmap(vma, fh, 100, 4);
ok1(!err); ok1(!err);
...@@ -966,7 +976,7 @@ void test_file_access_pagefault() ...@@ -966,7 +976,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 );
CHECK_MRU(ram, /*empty*/); CHECK_MRU(/*empty*/);
/* read page[0] */ /* read page[0] */
ok1(B(vma, 0*PSb) == 100); ok1(B(vma, 0*PSb) == 100);
...@@ -977,7 +987,7 @@ void test_file_access_pagefault() ...@@ -977,7 +987,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 );
CHECK_MRU(ram, page0); CHECK_MRU(page0);
/* write to page[2] */ /* write to page[2] */
...@@ -989,7 +999,7 @@ void test_file_access_pagefault() ...@@ -989,7 +999,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 );
CHECK_MRU(ram, page2, page0); CHECK_MRU(page2, page0);
/* read page[3] */ /* read page[3] */
...@@ -1001,7 +1011,7 @@ void test_file_access_pagefault() ...@@ -1001,7 +1011,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);
CHECK_MRU(ram, page3, page2, page0); CHECK_MRU(page3, page2, page0);
/* write to page[0] */ /* write to page[0] */
...@@ -1012,7 +1022,7 @@ void test_file_access_pagefault() ...@@ -1012,7 +1022,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);
CHECK_MRU(ram, page0, page3, page2); /* page0 became MRU */ CHECK_MRU(page0, page3, page2); /* page0 became MRU */
/* unmap vma */ /* unmap vma */
...@@ -1024,6 +1034,11 @@ void test_file_access_pagefault() ...@@ -1024,6 +1034,11 @@ void test_file_access_pagefault()
// ok1(list_empty(&ram->lru_list)); // ok1(list_empty(&ram->lru_list));
ram_close(ram); ram_close(ram);
free(ram); free(ram);
#undef CHECK_MRU
#undef CHECK_PAGE
#undef CHECK_NOPAGE
#undef CHECK_DIRTY
} }
...@@ -1181,8 +1196,11 @@ void test_file_access_mmapbase(void) ...@@ -1181,8 +1196,11 @@ void test_file_access_mmapbase(void)
PS = ram->pagesize; PS = ram->pagesize;
PSb = PS / sizeof(blk_t); /* page size in blk_t units */ PSb = PS / sizeof(blk_t); /* page size in blk_t units */
/* implicitly use ram=ram */
#define CHECK_MRU(...) __CHECK_MRU(ram, __VA_ARGS__)
/* ensure we are starting from new ram */ /* ensure we are starting from new ram */
CHECK_MRU(ram /*empty*/); CHECK_MRU(/*empty*/);
/* setup mmaped file */ /* setup mmaped file */
char path[] = "/tmp/bigfile_mmap.XXXXXX"; char path[] = "/tmp/bigfile_mmap.XXXXXX";
...@@ -1224,6 +1242,7 @@ void test_file_access_mmapbase(void) ...@@ -1224,6 +1242,7 @@ void test_file_access_mmapbase(void)
#define CHECK_PAGE(page, pgoffset, pgstate, pgrefcnt) \ #define CHECK_PAGE(page, pgoffset, pgstate, pgrefcnt) \
__CHECK_PAGE(page, fh, pgoffset, pgstate, pgrefcnt) __CHECK_PAGE(page, fh, pgoffset, pgstate, pgrefcnt)
#define CHECK_NOPAGE(pgoffset) __CHECK_NOPAGE(fh, pgoffset) #define CHECK_NOPAGE(pgoffset) __CHECK_NOPAGE(fh, pgoffset)
#define CHECK_DIRTY(...) __CHECK_DIRTY(fh, __VA_ARGS__)
err = fileh_mmap(vma, fh, 100, 4); err = fileh_mmap(vma, fh, 100, 4);
ok1(!err); ok1(!err);
...@@ -1234,8 +1253,8 @@ void test_file_access_mmapbase(void) ...@@ -1234,8 +1253,8 @@ 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 );
CHECK_MRU (ram /*empty*/); CHECK_MRU (/*empty*/);
CHECK_DIRTY (fh /*empty*/); CHECK_DIRTY (/*empty*/);
/* 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 */
ok1(B(vma, 0*PSb + 0) == 100); ok1(B(vma, 0*PSb + 0) == 100);
...@@ -1247,8 +1266,8 @@ void test_file_access_mmapbase(void) ...@@ -1247,8 +1266,8 @@ 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 );
CHECK_MRU (ram /*empty*/); CHECK_MRU (/*empty*/);
CHECK_DIRTY (fh /*empty*/); CHECK_DIRTY (/*empty*/);
/* write to page[2] - page2 is copy-on-write created in RAM */ /* write to page[2] - page2 is copy-on-write created in RAM */
B(vma, 2*PSb) = 12; B(vma, 2*PSb) = 12;
...@@ -1263,8 +1282,8 @@ void test_file_access_mmapbase(void) ...@@ -1263,8 +1282,8 @@ void test_file_access_mmapbase(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);
CHECK_MRU(ram, page2); CHECK_MRU (page2);
//CHECK_DIRTY(fh, page2); CHECK_DIRTY (page2);
/* 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);
...@@ -1276,8 +1295,8 @@ void test_file_access_mmapbase(void) ...@@ -1276,8 +1295,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 );
CHECK_MRU (ram, page2); CHECK_MRU (page2);
CHECK_DIRTY (fh, page2); CHECK_DIRTY (page2);
/* 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;
...@@ -1292,8 +1311,13 @@ void test_file_access_mmapbase(void) ...@@ -1292,8 +1311,13 @@ 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);
CHECK_MRU (ram, page0, page2); CHECK_MRU (page0, page2);
CHECK_DIRTY (fh, page0, page2); CHECK_DIRTY (page0, page2);
#undef CHECK_MRU
#undef CHECK_PAGE
#undef CHECK_NOPAGE
#undef CHECK_DIRTY
} }
......
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