Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
9a5cbf9f
Commit
9a5cbf9f
authored
Mar 19, 2012
by
antirez
Browse files
Memory addressing test implemented.
parent
1dfe75a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/memtest.c
View file @
9a5cbf9f
...
...
@@ -56,6 +56,33 @@ void memtest_progress_step(size_t curr, size_t size, char c) {
fflush
(
stdout
);
}
/* Test that addressing is fine. Every location is populated with its own
* address, and finally verified. This test is very fast but may detect
* ASAP big issues with the memory subsystem. */
void
memtest_addressing
(
unsigned
long
*
l
,
size_t
bytes
)
{
unsigned
long
words
=
bytes
/
sizeof
(
unsigned
long
);
unsigned
long
j
,
*
p
;
/* Fill */
p
=
l
;
for
(
j
=
0
;
j
<
words
;
j
++
)
{
*
p
=
(
unsigned
long
)
p
;
p
++
;
if
((
j
&
0xffff
)
==
0
)
memtest_progress_step
(
j
,
words
*
2
,
'A'
);
}
/* Test */
p
=
l
;
for
(
j
=
0
;
j
<
words
;
j
++
)
{
if
(
*
p
!=
(
unsigned
long
)
p
)
{
printf
(
"
\n
*** MEMORY ADDRESSING ERROR: %p contains %lu
\n
"
,
(
void
*
)
p
,
*
p
);
exit
(
1
);
}
p
++
;
if
((
j
&
0xffff
)
==
0
)
memtest_progress_step
(
j
+
words
,
words
*
2
,
'A'
);
}
}
/* Fill words stepping a single page at every write, so we continue to
* touch all the pages in the smallest amount of time reducing the
* effectiveness of caches, and making it hard for the OS to transfer
...
...
@@ -162,6 +189,11 @@ void memtest_test(size_t megabytes, int passes) {
}
while
(
pass
!=
passes
)
{
pass
++
;
memtest_progress_start
(
"Addressing test"
,
pass
);
memtest_addressing
(
m
,
bytes
);
memtest_progress_end
();
memtest_progress_start
(
"Random fill"
,
pass
);
memtest_fill_random
(
m
,
bytes
);
memtest_progress_end
();
...
...
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