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