diff options
Diffstat (limited to 'meta-oe/recipes-benchmark/lmbench/lmbench-3.0-a9/fix-lmbench-memory-check-failure.patch')
-rw-r--r-- | meta-oe/recipes-benchmark/lmbench/lmbench-3.0-a9/fix-lmbench-memory-check-failure.patch | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/meta-oe/recipes-benchmark/lmbench/lmbench-3.0-a9/fix-lmbench-memory-check-failure.patch b/meta-oe/recipes-benchmark/lmbench/lmbench-3.0-a9/fix-lmbench-memory-check-failure.patch new file mode 100644 index 000000000..549a114d1 --- /dev/null +++ b/meta-oe/recipes-benchmark/lmbench/lmbench-3.0-a9/fix-lmbench-memory-check-failure.patch | |||
@@ -0,0 +1,206 @@ | |||
1 | lmbench: Can't proceed on some targets | ||
2 | |||
3 | lmbench can't proceed on some targets. The memory check fails because the | ||
4 | memory latency of each page is longer then 10us, which is a time limit set | ||
5 | in the original memsize.c. | ||
6 | |||
7 | The memory latency is very different on different targets due to the | ||
8 | hardware and current system load. The targets with slower memory | ||
9 | chips or heavy system load need much longer time to read or write | ||
10 | the memory. | ||
11 | |||
12 | This fix changes the fixed time limit of 10us to a specific value calculated | ||
13 | from the runtime target. | ||
14 | |||
15 | Also set an upper limit of memory size used for lmbench testing. The memory | ||
16 | check sometimes fails if the target has a large amount of memory, for | ||
17 | example more than 4G. | ||
18 | |||
19 | Signed-off-by: Qingming Su <qingming.su@windriver.com> | ||
20 | Signed-off-by: Fupan Li <fupan.li@windriver.com> | ||
21 | |||
22 | Add and reword above comments | ||
23 | |||
24 | Upstream-status: inappropriate [ configuration ] | ||
25 | |||
26 | Signed-off-by: Mark Hatle <mark.hatle@windriver.com> | ||
27 | |||
28 | diff --git a/scripts/config-run b/scripts/config-run | ||
29 | index e1f7b6d..31b9256 100755 | ||
30 | --- a/scripts/config-run | ||
31 | +++ b/scripts/config-run | ||
32 | @@ -214,6 +214,12 @@ The bigger the range, the more accurate the results, but larger sizes | ||
33 | take somewhat longer to run the benchmark. | ||
34 | |||
35 | EOF | ||
36 | + | ||
37 | +# By default, use 512M memory as the upper limit for lmbench test | ||
38 | +if [ $MB -gt 512 ];then | ||
39 | +MB=512 | ||
40 | +fi | ||
41 | + | ||
42 | echo $ECHON "MB [default $MB]: $ECHOC" | ||
43 | #read TMP | ||
44 | TMP="" | ||
45 | @@ -718,10 +724,10 @@ case $MAIL in | ||
46 | ;; | ||
47 | esac | ||
48 | |||
49 | -INFO=`../scripts/info` | ||
50 | +INFO=`../scripts/hostinfo` | ||
51 | if [ $MAIL = yes ] | ||
52 | then if [ ! -f $INFO ] | ||
53 | - then cp ../scripts/info-template $INFO | ||
54 | + then cp ../scripts/hostinfo-template $INFO | ||
55 | chmod +w $INFO | ||
56 | REUSE=no | ||
57 | else | ||
58 | @@ -765,7 +771,7 @@ EOF | ||
59 | then EDITOR=$TMP | ||
60 | fi | ||
61 | if [ X$EDITOR != "none" ] | ||
62 | - then $EDITOR `../scripts/info` | ||
63 | + then $EDITOR `../scripts/hostinfo` | ||
64 | fi | ||
65 | fi | ||
66 | fi | ||
67 | diff --git a/src/Makefile b/src/Makefile | ||
68 | index d1f0dc6..5098998 100644 | ||
69 | --- a/src/Makefile | ||
70 | +++ b/src/Makefile | ||
71 | @@ -49,7 +49,7 @@ TARGET=`../scripts/target` | ||
72 | BINDIR=../bin/$(OS) | ||
73 | CONFIG=../bin/$(OS)/`../scripts/config` | ||
74 | UTILS=../scripts/target ../scripts/os ../scripts/gnu-os ../scripts/compiler \ | ||
75 | - ../scripts/info ../scripts/info-template ../scripts/version \ | ||
76 | + ../scripts/hostinfo ../scripts/hostinfo-template ../scripts/version \ | ||
77 | ../scripts/config ../scripts/config-run ../scripts/results \ | ||
78 | ../scripts/lmbench ../scripts/make ../scripts/build | ||
79 | INSTALL=cp | ||
80 | @@ -240,7 +240,7 @@ $O/getopt.o : getopt.c $(INCS) | ||
81 | $(COMPILE) -c getopt.c -o $O/getopt.o | ||
82 | |||
83 | $(UTILS) : | ||
84 | - -cd ../scripts; make get | ||
85 | + -cd ../scripts; cp info hostinfo; cp info-template hostinfo-template | ||
86 | |||
87 | # Do not remove the next line, $(MAKE) depend needs it | ||
88 | # MAKEDEPEND follows | ||
89 | diff --git a/src/memsize.c b/src/memsize.c | ||
90 | index eb25a09..cf9fe0c 100644 | ||
91 | --- a/src/memsize.c | ||
92 | +++ b/src/memsize.c | ||
93 | @@ -14,9 +14,12 @@ char *id = "$Id$\n"; | ||
94 | |||
95 | #define CHK(x) if ((x) == -1) { perror("x"); exit(1); } | ||
96 | |||
97 | -#ifndef TOO_LONG | ||
98 | -#define TOO_LONG 10 /* usecs */ | ||
99 | -#endif | ||
100 | +//#ifndef TOO_LONG | ||
101 | +//#define TOO_LONG 10 /* usecs */ | ||
102 | +//#endif | ||
103 | + | ||
104 | +#define MEMORY_SIZE_1MB (1024 * 1024) | ||
105 | +#define MEMORY_SIZE_8MB (8 * 1024 * 1024) | ||
106 | |||
107 | int alarm_triggered = 0; | ||
108 | |||
109 | @@ -35,10 +38,10 @@ main(int ac, char **av) | ||
110 | size_t delta; | ||
111 | |||
112 | if (ac == 2) { | ||
113 | - max = size = bytes(av[1]) * 1024 * 1024; | ||
114 | + max = size = bytes(av[1]) * MEMORY_SIZE_1MB; | ||
115 | } | ||
116 | - if (max < 1024 * 1024) { | ||
117 | - max = size = 1024 * 1024 * 1024; | ||
118 | + if (max < MEMORY_SIZE_1MB) { | ||
119 | + max = size = 1024 * MEMORY_SIZE_1MB; | ||
120 | } | ||
121 | /* | ||
122 | * Binary search down and then binary search up | ||
123 | @@ -48,7 +51,7 @@ main(int ac, char **av) | ||
124 | } | ||
125 | /* delta = size / (2 * 1024 * 1024) */ | ||
126 | for (delta = (size >> 21); delta > 0; delta >>= 1) { | ||
127 | - uint64 sz = (uint64)size + (uint64)delta * 1024 * 1024; | ||
128 | + uint64 sz = (uint64)size + (uint64)delta * MEMORY_SIZE_1MB; | ||
129 | size_t check = sz; | ||
130 | if (max < sz) continue; | ||
131 | if (check < sz || !test_malloc(sz)) break; | ||
132 | @@ -66,41 +69,58 @@ timeit(char *where, size_t size) | ||
133 | { | ||
134 | int sum = 0; | ||
135 | size_t n; | ||
136 | - size_t s_prev; | ||
137 | + size_t s_prev = MEMORY_SIZE_8MB; | ||
138 | size_t range; | ||
139 | - size_t incr = 1024 * 1024; | ||
140 | + size_t incr = MEMORY_SIZE_1MB; | ||
141 | size_t pagesize = getpagesize(); | ||
142 | - unsigned long long s; | ||
143 | - | ||
144 | - if (size < 1024*1024 - 16*1024) { | ||
145 | - fprintf(stderr, "Bad size\n"); | ||
146 | - return; | ||
147 | - } | ||
148 | + size_t time_each_page = 0; | ||
149 | + size_t too_long = 0; | ||
150 | + unsigned long long s; | ||
151 | + | ||
152 | + if (pagesize < MEMORY_SIZE_1MB) | ||
153 | + range = MEMORY_SIZE_1MB; | ||
154 | + else | ||
155 | + range = MEMORY_SIZE_8MB; | ||
156 | + | ||
157 | + incr = MEMORY_SIZE_1MB; | ||
158 | + | ||
159 | + if (size < range) { | ||
160 | + fprintf(stderr, "Bad size\n"); | ||
161 | + return; | ||
162 | + } | ||
163 | + | ||
164 | + //Touch range of memory, get the average time (usec) of operating each memory page on this system | ||
165 | + start(0); | ||
166 | + touchRange(where, range, pagesize); | ||
167 | + sum = stop(0, 0); | ||
168 | + | ||
169 | + if ((time_each_page = sum * pagesize / range) < 1) | ||
170 | + time_each_page = 1; | ||
171 | + //Set the uper limit of time spending on one page | ||
172 | + too_long = 10 * time_each_page; | ||
173 | |||
174 | - range = 1024 * 1024; | ||
175 | - incr = 1024 * 1024; | ||
176 | - touchRange(where, range, pagesize); | ||
177 | for (range += incr; range <= size; range += incr) { | ||
178 | n = range / pagesize; | ||
179 | - set_alarm(n * TOO_LONG); | ||
180 | + set_alarm(n * too_long); | ||
181 | touchRange(where + range - incr, incr, pagesize); | ||
182 | clear_alarm(); | ||
183 | - set_alarm(n * TOO_LONG); | ||
184 | + set_alarm(n * too_long); | ||
185 | start(0); | ||
186 | touchRange(where, range, pagesize); | ||
187 | sum = stop(0, 0); | ||
188 | clear_alarm(); | ||
189 | - if ((sum / n) > TOO_LONG || alarm_triggered) { | ||
190 | + if ((sum / n) > too_long || alarm_triggered) { | ||
191 | size = range - incr; | ||
192 | + fprintf(stderr, "Error! Memory testing timeout! Touch one page of memory needs more than %d (usecs)\n ", too_long); | ||
193 | break; | ||
194 | } | ||
195 | - for (s = 8 * 1024 * 1024; s <= range; s_prev = s, s *= 2) | ||
196 | + for (s = s_prev; s <= range; s_prev = s, s *= 2) | ||
197 | if (s < s_prev) break; | ||
198 | incr = s / 8; | ||
199 | if (range < size && size < range + incr) { | ||
200 | incr = size - range; | ||
201 | } | ||
202 | - fprintf(stderr, "%dMB OK\r", (int)(range/(1024*1024))); | ||
203 | + fprintf(stderr, "%dMB OK\r", (int)(range/MEMORY_SIZE_1MB)); | ||
204 | } | ||
205 | fprintf(stderr, "\n"); | ||
206 | printf("%d\n", (int)(size>>20)); | ||