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
82e2d956
Commit
82e2d956
authored
Jul 10, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Convert to CHECK_DIRTY
parent
01339a99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
73 deletions
+64
-73
bigfile/tests/test_virtmem.c
bigfile/tests/test_virtmem.c
+64
-73
No files found.
bigfile/tests/test_virtmem.c
View file @
82e2d956
...
...
@@ -230,7 +230,7 @@ void _assert_pagev(const char *subj, Page **vok, int nok, Page **pagev, int n,
int
i
;
if
(
!
(
n
==
nok
&&
!
memcmp
(
pagev
,
vok
,
n
*
sizeof
(
*
pagev
))))
{
fprintf
(
stderr
,
"%s:
different
\n
"
,
subj
);
fprintf
(
stderr
,
"%s:
failed
\n
"
,
subj
);
fprintf
(
stderr
,
"have: ["
);
for
(
i
=
0
;
i
<
n
;
i
++
)
fprintf
(
stderr
,
"%sp%ld"
,
(
i
>
0
?
", "
:
""
),
pagev
[
i
]
->
f_pgoffset
);
...
...
@@ -241,6 +241,20 @@ void _assert_pagev(const char *subj, Page **vok, int nok, Page **pagev, int n,
fprintf
(
stderr
,
"]
\n
"
);
_gen_result
(
0
,
func
,
file
,
line
,
"%s failed"
,
subj
);
}
else
{
char
vstr
[
128
],
*
s
=&
vstr
[
0
];
int
l
=
sizeof
(
vstr
),
d
;
d
=
snprintf
(
s
,
l
,
"["
);
s
+=
d
;
l
-=
d
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
d
=
snprintf
(
s
,
l
,
"%sp%ld"
,
(
i
>
0
?
", "
:
""
),
pagev
[
i
]
->
f_pgoffset
);
s
+=
d
;
l
-=
d
;
}
d
=
snprintf
(
s
,
l
,
"]"
);
s
+=
d
;
l
-=
d
;
pass
(
"%s %s"
,
subj
,
vstr
);
}
}
/* _check_mru checks that ram has MRU pages as specified by pagev */
...
...
@@ -268,13 +282,15 @@ void _check_mru(RAM *ram, Page *mruok[], int nok, const char *func, const char *
} while(0)
void
_check_dity
(
BigFileH
*
fileh
,
Page
*
dirtyok
[],
int
nok
,
const
char
*
func
,
const
char
*
file
,
int
line
)
{
/* _check_dirty checks that fileh has dirty pages as specified.
* the orderof dirty list traversal is to go through most recently dirtied pages first */
void
_check_dirty
(
BigFileH
*
fileh
,
Page
*
dirtyok
[],
int
nok
,
const
char
*
func
,
const
char
*
file
,
int
line
)
{
Page
**
dirtyv
=
NULL
,
*
page
;
int
n
=
0
;
struct
list_head
*
h
;
// collect dirtyv
list_for_each
(
h
,
&
fileh
->
dirty_pages
)
{
list_for_each
_backwardly
(
h
,
&
fileh
->
dirty_pages
)
{
page
=
list_entry
(
h
,
typeof
(
*
page
),
in_dirty
);
n
++
;
dirtyv
=
realloc
(
dirtyv
,
n
*
sizeof
(
*
dirtyv
));
...
...
@@ -404,8 +420,8 @@ void test_file_access_synthetic(void)
CHECK_NOPAGE
(
102
);
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
/*empty*/
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_MRU
(
ram
/*empty*/
);
CHECK_DIRTY
(
fh
/*empty */
);
/* simulate read access to page[0] - it should load it */
...
...
@@ -428,7 +444,7 @@ void test_file_access_synthetic(void)
ok1
(
B
(
vma
,
0
*
PSb
+
PSb
-
1
)
==
100
);
CHECK_MRU
(
ram
,
page0
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_DIRTY
(
fh
/*empty*/
);
/* simulate write access to page[2] - it should load it and mark page dirty */
...
...
@@ -453,9 +469,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
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page2
,
page0
);
CHECK_DIRTY
(
fh
,
page2
);
/* read access to page[3] - load */
...
...
@@ -483,9 +498,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
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page3
,
page2
,
page0
);
CHECK_DIRTY
(
fh
,
page2
);
/* write access to page[0] - upgrade loaded -> dirty */
...
...
@@ -512,12 +526,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);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page0
,
page3
,
page2
);
/* page0 became MRU */
CHECK_DIRTY
(
fh
,
page0
,
page2
);
/* read page[1]
...
...
@@ -551,10 +561,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
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page1
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
/* now explicit reclaim - should evict page[1] (the only PAGE_LOADED page) */
...
...
@@ -581,10 +589,8 @@ void test_file_access_synthetic(void)
ok1
(
B
(
vma
,
2
*
PSb
+
PSb
-
1
)
==
102
);
/* page[3] went away */
CHECK_MRU
(
ram
,
page0
,
page2
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
/* unmap vma - dirty pages should stay in fh->pagemap and memory should
...
...
@@ -599,10 +605,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
0
);
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page0
,
page2
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
b0
=
page_mmap
(
page0
,
NULL
,
PROT_READ
);
ok1
(
b0
);
...
...
@@ -638,10 +642,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
0
);
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page0
,
page2
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
/* read access to page[2] - should map it R/W - the page is in PAGE_DIRTY state */
...
...
@@ -658,10 +660,8 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page2
,
102
,
PAGE_DIRTY
,
1
);
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page2
,
page0
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page2
,
page0
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
/* discard - changes should go away */
...
...
@@ -679,7 +679,7 @@ void test_file_access_synthetic(void)
CHECK_NOPAGE
(
103
);
CHECK_MRU
(
ram
,
page2
,
page0
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_DIRTY
(
fh
/*empty*/
);
/* writeout in 3 variants - STORE, MARK, STORE+MARK */
...
...
@@ -713,8 +713,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
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_MRU
(
ram
,
page3
,
page2
,
page0
);
CHECK_DIRTY
(
fh
/*empty*/
);
/* prepare state (2 dirty pages, only 1 mapped) */
...
...
@@ -737,9 +737,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
0
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
}
diag
(
"writeout (store)"
);
...
...
@@ -762,9 +760,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
0
);
/* NOTE - becomes sorted by ->f_pgoffset */
ok1
(
fh
->
dirty_pages
.
next
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
next
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
next
==
&
fh
->
dirty_pages
);
CHECK_DIRTY
(
fh
,
page2
,
page0
);
/* checked in reverse order */
diag
(
"writeout (mark)"
);
blkv_len
=
0
;
...
...
@@ -783,7 +779,7 @@ void test_file_access_synthetic(void)
CHECK_PAGE
(
page3
,
103
,
PAGE_LOADED
,
0
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_DIRTY
(
fh
/*empty*/
);
diag
(
"writeout (store+mark)"
);
mkdirty2
();
...
...
@@ -804,8 +800,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
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
/*empty*/
);
/* invalidation */
diag
(
"invalidate"
);
...
...
@@ -823,10 +819,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
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
fileh_invalidate_page
(
fh
,
103
);
...
...
@@ -841,10 +835,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
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
page2
->
in_dirty
);
ok1
(
page2
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
fileh_invalidate_page
(
fh
,
102
);
...
...
@@ -859,9 +851,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
);
ok1
(
fh
->
dirty_pages
.
prev
==
&
page0
->
in_dirty
);
ok1
(
page0
->
in_dirty
.
prev
==
&
fh
->
dirty_pages
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
,
page0
);
fileh_invalidate_page
(
fh
,
100
);
...
...
@@ -876,8 +867,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
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_MRU
(
ram
,
page2
,
page0
,
page3
);
CHECK_DIRTY
(
fh
/*empty*/
);
/* read page[3] back */
xvma_on_pagefault
(
vma
,
vma
->
addr_start
+
3
*
PS
,
0
);
...
...
@@ -892,8 +883,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
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_MRU
(
ram
,
page3
,
page2
,
page0
);
CHECK_DIRTY
(
fh
/*empty*/
);
diag
(
"fileh_close"
);
...
...
@@ -1243,8 +1234,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*/
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_MRU
(
ram
/*empty*/
);
CHECK_DIRTY
(
fh
/*empty*/
);
/* read page[0] - served from base mmap and no RAM page is loaded */
ok1
(
B
(
vma
,
0
*
PSb
+
0
)
==
100
);
...
...
@@ -1256,8 +1247,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*/
);
ok1
(
list_empty
(
&
fh
->
dirty_pages
)
);
CHECK_MRU
(
ram
/*empty*/
);
CHECK_DIRTY
(
fh
/*empty*/
);
/* write to page[2] - page2 is copy-on-write created in RAM */
B
(
vma
,
2
*
PSb
)
=
12
;
...
...
@@ -1285,8 +1276,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
);
// XXX CHECK_DIRTY
CHECK_MRU
(
ram
,
page2
);
CHECK_DIRTY
(
fh
,
page2
);
/* write to page[0] - page COW'ed into RAM */
B
(
vma
,
0
*
PSb
)
=
10
;
...
...
@@ -1301,8 +1292,8 @@ 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
);
// XXX dirty
CHECK_MRU
(
ram
,
page0
,
page2
);
CHECK_DIRTY
(
fh
,
page0
,
page2
);
}
...
...
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