Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
38c08e6e
Commit
38c08e6e
authored
Jul 10, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Bind CHECK_MRU and CHECK_DIRTY to ram and fh
parent
82e2d956
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
65 deletions
+89
-65
bigfile/tests/test_virtmem.c
bigfile/tests/test_virtmem.c
+89
-65
No files found.
bigfile/tests/test_virtmem.c
View file @
38c08e6e
...
...
@@ -275,8 +275,8 @@ void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char *
free
(
mruv
);
}
/* CHECK_MRU(ram, ...pagev) - assert that ram has MRU pages as expected */
#define
CHECK_MRU(ram, ...) do {
\
/*
__
CHECK_MRU(ram, ...pagev) - assert that ram has MRU pages as expected */
#define
__CHECK_MRU(ram, ...) do {
\
Page *__mruok[] = {__VA_ARGS__}; \
_check_mru(ram, __mruok, ARRAY_SIZE(__mruok), __func__, __FILE__, __LINE__); \
} while(0)
...
...
@@ -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 */
#define
CHECK_DIRTY(fileh, ...) do {
\
/*
__
CHECK_DIRTY(fileh, ...pagev) - assert that fileh has dirty pages as expected */
#define
__CHECK_DIRTY(fileh, ...) do {
\
Page *__dirtyok[] = {__VA_ARGS__}; \
_check_dirty(fileh, __dirtyok, ARRAY_SIZE(__dirtyok), __func__, __FILE__, __LINE__); \
} while(0)
...
...
@@ -382,8 +382,11 @@ void test_file_access_synthetic(void)
PS
=
ram
->
pagesize
;
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 */
CHECK_MRU
(
ram
/*empty*/
);
CHECK_MRU
(
/*empty*/
);
/* setup id file */
struct
bigfile_ops
x_ops
=
{.
loadblk
=
fileid_loadblk
};
...
...
@@ -400,6 +403,7 @@ void test_file_access_synthetic(void)
#define CHECK_PAGE(page, pgoffset, pgstate, pgrefcnt) \
__CHECK_PAGE(page, fh, pgoffset, pgstate, pgrefcnt)
#define CHECK_NOPAGE(pgoffset) __CHECK_NOPAGE(fh, pgoffset)
#define CHECK_DIRTY(...) __CHECK_DIRTY(fh, __VA_ARGS__)
err
=
fileh_mmap
(
vma
,
fh
,
100
,
4
);
...
...
@@ -420,8 +424,8 @@ void test_file_access_synthetic(void)
CHECK_NOPAGE
(
102
);
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
/*empty*/
);
CHECK_DIRTY
(
fh
/*empty */
);
CHECK_MRU
(
/*empty*/
);
CHECK_DIRTY
(
/*empty */
);
/* simulate read access to page[0] - it should load it */
...
...
@@ -443,8 +447,8 @@ void test_file_access_synthetic(void)
ok1
(
B
(
vma
,
0
*
PSb
+
1
)
==
100
);
ok1
(
B
(
vma
,
0
*
PSb
+
PSb
-
1
)
==
100
);
CHECK_MRU
(
ram
,
page0
);
CHECK_DIRTY
(
fh
/*empty*/
);
CHECK_MRU
(
page0
);
CHECK_DIRTY
(
/*empty*/
);
/* simulate write access to page[2] - it should load it and mark page dirty */
...
...
@@ -469,8 +473,8 @@ void test_file_access_synthetic(void)
ok1
(
B
(
vma
,
2
*
PSb
+
1
)
==
102
);
ok1
(
B
(
vma
,
2
*
PSb
+
PSb
-
1
)
==
102
);
CHECK_MRU
(
ram
,
page2
,
page0
);
CHECK_DIRTY
(
fh
,
page2
);
CHECK_MRU
(
page2
,
page0
);
CHECK_DIRTY
(
page2
);
/* read access to page[3] - load */
...
...
@@ -498,8 +502,8 @@ void test_file_access_synthetic(void)
ok1
(
B
(
vma
,
3
*
PSb
+
1
)
==
103
);
ok1
(
B
(
vma
,
3
*
PSb
+
PSb
-
1
)
==
103
);
CHECK_MRU
(
ram
,
page3
,
page2
,
page0
);
CHECK_DIRTY
(
fh
,
page2
);
CHECK_MRU
(
page3
,
page2
,
page0
);
CHECK_DIRTY
(
page2
);
/* write access to page[0] - upgrade loaded -> dirty */
...
...
@@ -526,8 +530,8 @@ void test_file_access_synthetic(void)
ok1
(
B
(
vma
,
3
*
PSb
+
1
)
==
103
);
ok1
(
B
(
vma
,
3
*
PSb
+
PSb
-
1
)
==
103
);
CHECK_MRU
(
ram
,
page0
,
page3
,
page2
);
/* page0 became MRU */
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page0
,
page3
,
page2
);
/* page0 became MRU */
CHECK_DIRTY
(
page0
,
page2
);
/* read page[1]
...
...
@@ -561,8 +565,8 @@ void test_file_access_synthetic(void)
ok1
(
B
(
vma
,
2
*
PSb
+
1
)
==
102
);
ok1
(
B
(
vma
,
2
*
PSb
+
PSb
-
1
)
==
102
);
CHECK_MRU
(
ram
,
page1
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page1
,
page0
,
page2
);
CHECK_DIRTY
(
page0
,
page2
);
/* now explicit reclaim - should evict page[1] (the only PAGE_LOADED page) */
...
...
@@ -589,8 +593,8 @@ void test_file_access_synthetic(void)
ok1
(
B
(
vma
,
2
*
PSb
+
PSb
-
1
)
==
102
);
/* page[3] went away */
CHECK_MRU
(
ram
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page0
,
page2
);
CHECK_DIRTY
(
page0
,
page2
);
/* unmap vma - dirty pages should stay in fh->pagemap and memory should
...
...
@@ -605,8 +609,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
0
);
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page0
,
page2
);
CHECK_DIRTY
(
page0
,
page2
);
b0
=
page_mmap
(
page0
,
NULL
,
PROT_READ
);
ok1
(
b0
);
...
...
@@ -642,8 +646,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
0
);
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page0
,
page2
);
CHECK_DIRTY
(
page0
,
page2
);
/* 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)
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
1
);
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page2
,
page0
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page2
,
page0
);
CHECK_DIRTY
(
page0
,
page2
);
/* discard - changes should go away */
...
...
@@ -678,8 +682,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_EMPTY
,
0
);
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page2
,
page0
);
CHECK_DIRTY
(
fh
/*empty*/
);
CHECK_MRU
(
page2
,
page0
);
CHECK_DIRTY
(
/*empty*/
);
/* writeout in 3 variants - STORE, MARK, STORE+MARK */
...
...
@@ -713,8 +717,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_EMPTY
,
0
);
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
1
);
CHECK_MRU
(
ram
,
page3
,
page2
,
page0
);
CHECK_DIRTY
(
fh
/*empty*/
);
CHECK_MRU
(
page3
,
page2
,
page0
);
CHECK_DIRTY
(
/*empty*/
);
/* prepare state (2 dirty pages, only 1 mapped) */
...
...
@@ -736,8 +740,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
1
);
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
0
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page2
,
page0
,
page3
);
CHECK_DIRTY
(
page0
,
page2
);
}
diag
(
"writeout (store)"
);
...
...
@@ -760,7 +764,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
0
);
/* 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)"
);
blkv_len
=
0
;
...
...
@@ -778,8 +782,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_LOADED
,
1
);
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
0
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
/*empty*/
);
CHECK_MRU
(
page2
,
page0
,
page3
);
CHECK_DIRTY
(
/*empty*/
);
diag
(
"writeout (store+mark)"
);
mkdirty2
();
...
...
@@ -800,8 +804,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_LOADED
,
1
);
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
0
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
/*empty*/
);
CHECK_MRU
(
page2
,
page0
,
page3
);
CHECK_DIRTY
(
/*empty*/
);
/* invalidation */
diag
(
"invalidate"
);
...
...
@@ -819,8 +823,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
1
);
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
0
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page2
,
page0
,
page3
);
CHECK_DIRTY
(
page0
,
page2
);
fileh_invalidate_page
(
fh
,
103
);
...
...
@@ -835,8 +839,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
1
);
CHECK_PAGE
(
page3
,
103
,
PAGE_EMPTY
,
0
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page2
,
page0
,
page3
);
CHECK_DIRTY
(
page0
,
page2
);
fileh_invalidate_page
(
fh
,
102
);
...
...
@@ -851,8 +855,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_EMPTY
,
0
);
CHECK_PAGE
(
page3
,
103
,
PAGE_EMPTY
,
0
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
,
page0
);
CHECK_MRU
(
page2
,
page0
,
page3
);
CHECK_DIRTY
(
page0
);
fileh_invalidate_page
(
fh
,
100
);
...
...
@@ -867,8 +871,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_EMPTY
,
0
);
CHECK_PAGE
(
page3
,
103
,
PAGE_EMPTY
,
0
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
/*empty*/
);
CHECK_MRU
(
page2
,
page0
,
page3
);
CHECK_DIRTY
(
/*empty*/
);
/* read page[3] back */
xvma_on_pagefault
(
vma
,
vma
->
addr_start
+
3
*
PS
,
0
);
...
...
@@ -883,8 +887,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_EMPTY
,
0
);
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
1
);
CHECK_MRU
(
ram
,
page3
,
page2
,
page0
);
CHECK_DIRTY
(
fh
/*empty*/
);
CHECK_MRU
(
page3
,
page2
,
page0
);
CHECK_DIRTY
(
/*empty*/
);
diag
(
"fileh_close"
);
...
...
@@ -893,7 +897,7 @@ void test_file_access_synthetic(void)
vma_unmap
(
vma
);
/* 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
(
page0
->
state
==
PAGE_DIRTY
);
ok1
(
page3
->
state
==
PAGE_LOADED
);
...
...
@@ -901,7 +905,7 @@ void test_file_access_synthetic(void)
fileh_close
(
fh
);
/* pages associated with fileh should go away after fileh_close() */
CHECK_MRU
(
ram
/*empty*/
);
CHECK_MRU
(
/*empty*/
);
/* free resources & restore SIGSEGV handler */
...
...
@@ -910,8 +914,10 @@ void test_file_access_synthetic(void)
ok1
(
!
sigaction
(
SIGSEGV
,
&
saveact
,
NULL
));
#undef CHECK_MRU
#undef CHECK_PAGE
#undef CHECK_NOPAGE
#undef CHECK_DIRTY
}
...
...
@@ -940,8 +946,11 @@ void test_file_access_pagefault()
PS
=
ram
->
pagesize
;
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 */
CHECK_MRU
(
ram
/*empty*/
);
CHECK_MRU
(
/*empty*/
);
/* setup id file */
BigFileIdentity
fileid
=
{
...
...
@@ -956,6 +965,7 @@ void test_file_access_pagefault()
#define CHECK_PAGE(page, pgoffset, pgstate, pgrefcnt) \
__CHECK_PAGE(page, fh, pgoffset, pgstate, pgrefcnt)
#define CHECK_NOPAGE(pgoffset) __CHECK_NOPAGE(fh, pgoffset)
#define CHECK_DIRTY(...) __CHECK_DIRTY(fh, __VA_ARGS__)
err
=
fileh_mmap
(
vma
,
fh
,
100
,
4
);
ok1
(
!
err
);
...
...
@@ -966,7 +976,7 @@ void test_file_access_pagefault()
ok1
(
!
M
(
vma
,
2
));
CHECK_NOPAGE
(
102
);
ok1
(
!
M
(
vma
,
3
));
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
/*empty*/
);
CHECK_MRU
(
/*empty*/
);
/* read page[0] */
ok1
(
B
(
vma
,
0
*
PSb
)
==
100
);
...
...
@@ -977,7 +987,7 @@ void test_file_access_pagefault()
ok1
(
!
M
(
vma
,
2
));
CHECK_NOPAGE
(
102
);
ok1
(
!
M
(
vma
,
3
));
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page0
);
CHECK_MRU
(
page0
);
/* write to page[2] */
...
...
@@ -989,7 +999,7 @@ void test_file_access_pagefault()
ok1
(
M
(
vma
,
2
));
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
1
);
ok1
(
!
M
(
vma
,
3
));
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page2
,
page0
);
CHECK_MRU
(
page2
,
page0
);
/* read page[3] */
...
...
@@ -1001,7 +1011,7 @@ void test_file_access_pagefault()
ok1
(
M
(
vma
,
2
));
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
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] */
...
...
@@ -1012,7 +1022,7 @@ void test_file_access_pagefault()
ok1
(
M
(
vma
,
2
));
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
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 */
...
...
@@ -1024,6 +1034,11 @@ void test_file_access_pagefault()
// ok1(list_empty(&ram->lru_list));
ram_close
(
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)
PS
=
ram
->
pagesize
;
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 */
CHECK_MRU
(
ram
/*empty*/
);
CHECK_MRU
(
/*empty*/
);
/* setup mmaped file */
char
path
[]
=
"/tmp/bigfile_mmap.XXXXXX"
;
...
...
@@ -1224,6 +1242,7 @@ void test_file_access_mmapbase(void)
#define CHECK_PAGE(page, pgoffset, pgstate, pgrefcnt) \
__CHECK_PAGE(page, fh, pgoffset, pgstate, pgrefcnt)
#define CHECK_NOPAGE(pgoffset) __CHECK_NOPAGE(fh, pgoffset)
#define CHECK_DIRTY(...) __CHECK_DIRTY(fh, __VA_ARGS__)
err
=
fileh_mmap
(
vma
,
fh
,
100
,
4
);
ok1
(
!
err
);
...
...
@@ -1234,8 +1253,8 @@ void test_file_access_mmapbase(void)
ok1
(
!
M
(
vma
,
2
));
CHECK_NOPAGE
(
102
);
ok1
(
!
M
(
vma
,
3
));
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
/*empty*/
);
CHECK_DIRTY
(
fh
/*empty*/
);
CHECK_MRU
(
/*empty*/
);
CHECK_DIRTY
(
/*empty*/
);
/* read page[0] - served from base mmap and no RAM page is loaded */
ok1
(
B
(
vma
,
0
*
PSb
+
0
)
==
100
);
...
...
@@ -1247,8 +1266,8 @@ void test_file_access_mmapbase(void)
ok1
(
!
M
(
vma
,
2
));
CHECK_NOPAGE
(
102
);
ok1
(
!
M
(
vma
,
3
));
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
/*empty*/
);
CHECK_DIRTY
(
fh
/*empty*/
);
CHECK_MRU
(
/*empty*/
);
CHECK_DIRTY
(
/*empty*/
);
/* write to page[2] - page2 is copy-on-write created in RAM */
B
(
vma
,
2
*
PSb
)
=
12
;
...
...
@@ -1263,8 +1282,8 @@ void test_file_access_mmapbase(void)
ok1
(
B
(
vma
,
2
*
PSb
+
1
)
==
102
);
ok1
(
B
(
vma
,
2
*
PSb
+
PSb
-
1
)
==
102
);
CHECK_MRU
(
ram
,
page2
);
//CHECK_DIRTY(fh,
page2);
CHECK_MRU
(
page2
);
CHECK_DIRTY
(
page2
);
/* read page[3] - served from base mmap */
ok1
(
B
(
vma
,
3
*
PSb
+
0
)
==
103
);
...
...
@@ -1276,8 +1295,8 @@ void test_file_access_mmapbase(void)
ok1
(
M
(
vma
,
2
));
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
1
);
ok1
(
!
M
(
vma
,
3
));
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page2
);
CHECK_DIRTY
(
fh
,
page2
);
CHECK_MRU
(
page2
);
CHECK_DIRTY
(
page2
);
/* write to page[0] - page COW'ed into RAM */
B
(
vma
,
0
*
PSb
)
=
10
;
...
...
@@ -1292,8 +1311,13 @@ void test_file_access_mmapbase(void)
ok1
(
B
(
vma
,
0
*
PSb
+
1
)
==
100
);
ok1
(
B
(
vma
,
0
*
PSb
+
PSb
-
1
)
==
100
);
CHECK_MRU
(
ram
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
CHECK_MRU
(
page0
,
page2
);
CHECK_DIRTY
(
page0
,
page2
);
#undef CHECK_MRU
#undef CHECK_PAGE
#undef CHECK_NOPAGE
#undef CHECK_DIRTY
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment