| 1 |
memtester |
| 2 |
|
| 3 |
Utility to test for faulty memory subsystem. |
| 4 |
|
| 5 |
by Charles Cazabon <[email protected]> |
| 6 |
|
| 7 |
Copyright 1999 Simon Kirby. |
| 8 |
Version 2 Copyright 1999 Charles Cazabon. |
| 9 |
Version 3 not publicly released. |
| 10 |
Version 4 rewrite: |
| 11 |
Copyright 2004-2024 Charles Cazabon. |
| 12 |
Licensed under the terms of the GNU General Public License version 2 (only). |
| 13 |
See the file COPYING for details. |
| 14 |
|
| 15 |
|
| 16 |
About memtester |
| 17 |
|
| 18 |
memtester is a utility for testing the memory subsystem in a computer to |
| 19 |
determine if it is faulty. The original source was by Simon Kirby |
| 20 |
<[email protected]>. I have by this time completely rewritten the |
| 21 |
original source, and added many additional tests to help catch |
| 22 |
borderline memory. I also rewrote the original tests (which catch |
| 23 |
mainly memory bits which are stuck permanently high or low) so that |
| 24 |
they run approximately an order of magnitude faster. |
| 25 |
|
| 26 |
The version 4 rewrite was mainly to accomplish three things: |
| 27 |
|
| 28 |
(1) the previous code was basically a hack, and was ugly. |
| 29 |
(2) to make the code more portable. The previous version required some |
| 30 |
hackery to compile on some systems. |
| 31 |
(3) to make the code fully 64-bit aware. The previous version worked |
| 32 |
on 64-bit systems, but did not fully stress the memory subsystems |
| 33 |
on them -- this version should be better at stress-testing 64-bit |
| 34 |
systems. |
| 35 |
|
| 36 |
Building memtester |
| 37 |
|
| 38 |
memtester is currently only distributed in source-code form. Building |
| 39 |
it, however, is simple -- just type `make`. There's no `configure` script |
| 40 |
or anything like that. |
| 41 |
|
| 42 |
If you have a really strange system/toolchain, you might need to edit the |
| 43 |
conf-cc or conf-ld files, but try to build it without changes first. |
| 44 |
For example, if you want to cross-compile with `armgcc`, you would edit |
| 45 |
conf-cc and conf-ld to use `armgcc` instead of `cc`. You can also change |
| 46 |
the contents of these files for other reasons; for example, if your |
| 47 |
compiler isn't in your PATH, you could change it to use `/path/to/cc` or |
| 48 |
similar. |
| 49 |
|
| 50 |
You can run the resulting binary from anywhere, but if you want to install |
| 51 |
it and the manpage to /usr/local/, `make install` will do that. Edit |
| 52 |
INSTALLPATH in the makefile if you prefer a different location. |
| 53 |
|
| 54 |
I've successfully built and run memtester 4 on the following systems: |
| 55 |
|
| 56 |
HP Tru64 Unix 4.0g (Alpha) |
| 57 |
HP Tru64 Unix 5.1b (Alpha) |
| 58 |
HP-UX 11i 11.11 (PA-RISC) |
| 59 |
HP-UX 11i 11.23 (64-bit Itanium) |
| 60 |
Debian GNU/Linux 3.0 (various) |
| 61 |
other 32-bit Linux (RedHat, SuSE, Ubuntu, etc) (various) |
| 62 |
RedHat Enterprise Linux/CentOS (64-bit AMD Opteron) |
| 63 |
FreeBSD 4.9 (32-bit Intel) |
| 64 |
FreeBSD 5.1 (64-bit Alpha) |
| 65 |
NetBSD 1.6 (32-bit Intel) |
| 66 |
Darwin (OS X) 7.5.0 (32-bit PowerPC) |
| 67 |
OS X Leopard/Panther/whatever -- 32- or 64-bit, PPC or x86 |
| 68 |
|
| 69 |
It should, however, work on other Unix-like systems -- I simply don't |
| 70 |
have access to systems running Solaris, AIX, etc. at the moment. |
| 71 |
If you have trouble building memtester on your system, please report it |
| 72 |
to me so I can fix this. |
| 73 |
|
| 74 |
Using memtester |
| 75 |
|
| 76 |
Usage is simple for the basic case. As root, run the resulting memtester |
| 77 |
binary with the following commandline: |
| 78 |
|
| 79 |
memtester <memory> [runs] |
| 80 |
|
| 81 |
where <memory> is the amount of memory to test, in megabytes by default. |
| 82 |
You can optionally include a suffix of B, K, M, or G (for bytes, |
| 83 |
kilobytes, megabytes, and gigabytes respectively). |
| 84 |
[runs] is an optional limit to the number of runs through all tests. |
| 85 |
|
| 86 |
An optional "-p physaddr" argument available to cause memtester to test |
| 87 |
memory starting at a specific physical memory address (by mmap(2)ing |
| 88 |
a device file representing physical memory (/dev/mem by default, but can |
| 89 |
be specified with the "-d device" option) starting at an offset of |
| 90 |
`physaddr`, which is given in hex). |
| 91 |
|
| 92 |
Note: the memory specified will be overwritten during testing; you |
| 93 |
therefore *cannot* specify a region belonging to the kernel or other |
| 94 |
applications without causing the other process or entire system to |
| 95 |
crash). If you use this option, it is up to you to ensure the specified |
| 96 |
memory is safe to overwrite. That makes this option mostly of use for |
| 97 |
testing memory-mapped I/O devices and similar. Thanks to Allon Stern |
| 98 |
for the idea behind this feature. For example, if you want to test a |
| 99 |
bank of RAM or device which is 64kbytes in size and starts at physical |
| 100 |
address 0x0C0000 through the normal /dev/mem, you would run memtester as |
| 101 |
follows: |
| 102 |
|
| 103 |
memtester -p 0x0c0000 64k [runs] |
| 104 |
|
| 105 |
If instead that device presented its memory as /dev/foodev at offset |
| 106 |
0, you would run memtester instead as follows: |
| 107 |
|
| 108 |
memtester -p 0 -d /dev/foodev 64k [runs] |
| 109 |
|
| 110 |
Note that the "-d" option can only be specified in combination with "-p". |
| 111 |
|
| 112 |
memtester must run as user root so that it can lock its pages into |
| 113 |
memory. If memtester fails to lock its pages, it will issue a warning and |
| 114 |
continue regardless. Testing without the memory being locked is generally |
| 115 |
very slow and not particularly accurate, as you'll end up testing the same |
| 116 |
memory over and over as the system swaps the larger region. |
| 117 |
|
| 118 |
Current Version |
| 119 |
|
| 120 |
The current version of memtester should be available at |
| 121 |
http://pyropus.ca/software/memtester/ |
| 122 |
|
| 123 |
Questions, comments, and feature requests should be |
| 124 |
directed to me at <[email protected]>. Read BUGS to report |
| 125 |
bugs found in memtester. |
| 126 |
|
| 127 |
Platform Compatibility Notes |
| 128 |
|
| 129 |
As mentioned, memtester v4 was tested with a wide variety of Unix- and |
| 130 |
Unix-like systems. However, at least two issues with ancient HP/UX |
| 131 |
versions, and one with Tru64, have come up since. |
| 132 |
|
| 133 |
HP/UX versions prior to v11 do not support mlock() and will fail with an |
| 134 |
invalid syscall error at runtime. If you're building on HP/UX v10.20 or |
| 135 |
similar, change `int do_mlock = 1` around line 128 of memtester.c to |
| 136 |
`int do_mlock = 0` and rebuild. |
| 137 |
They also are missing strtoull() from C99. To fix this build error, |
| 138 |
add `#define strtoull __strtoull` to the top of memtester.c; this should |
| 139 |
at least work with a GCC toolchain. |
| 140 |
|
| 141 |
Tru64 is missing strtoull() from C99. To fix this build error when using |
| 142 |
cc, add `#define strtoull strtoul` to the top of memtester.c; this is |
| 143 |
safe because long on Tru64 is 64-bits. This build problem could be dealt |
| 144 |
with automatically, but I don't particularly want to invest the necessary |
| 145 |
time, because Tru64 went out of support in 2012. In addition, I no longer |
| 146 |
have access to a build machine for testing on this platform. |
| 147 |
|
| 148 |
|