author | mikek |
Wed, 16 Jun 2010 12:59:18 +0100 | |
branch | GCC_SURGE |
changeset 160 | 30e086416910 |
parent 90 | 947f0dc9f7a8 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32test\mmu\paging_info.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <e32debug.h> |
|
19 |
#include <e32svr.h> |
|
20 |
#include <u32hal.h> |
|
21 |
#include <hal.h> |
|
22 |
#include "paging_info.h" |
|
23 |
||
24 |
||
25 |
const TUint8* BenchmarkNames[] = |
|
26 |
{ |
|
27 |
(const TUint8*)"Read rom page", |
|
28 |
(const TUint8*)"Read code page", |
|
29 |
(const TUint8*)"Decompress", |
|
30 |
(const TUint8*)"Set code page free", |
|
31 |
(const TUint8*)"Set code page old", |
|
32 |
(const TUint8*)"Read media", |
|
33 |
(const TUint8*)"Fixup code page", |
|
34 |
(const TUint8*)"Read data page", |
|
35 |
(const TUint8*)"Write data page", |
|
36 |
(const TUint8*)"Del notify data page", |
|
37 |
(const TUint8*)"Read media data page", |
|
38 |
(const TUint8*)"Write media data page", |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
39 |
(const TUint8*)"Rejuvenate page", |
0 | 40 |
}; |
41 |
||
42 |
__ASSERT_COMPILE(sizeof(BenchmarkNames)/sizeof(TUint8*) == EMaxPagingBm); |
|
43 |
||
44 |
||
45 |
TInt PagingInfo::ResetConcurrency(TInt aLocDrvNo, TMediaPagingStats aMediaStats) |
|
46 |
{ |
|
47 |
TInt r = UserSvr::HalFunction(EHalGroupVM, EVMHalResetConcurrencyInfo, NULL, NULL); |
|
48 |
if (r!=KErrNotSupported && r!=KErrNone) |
|
49 |
return r; |
|
50 |
if(aLocDrvNo>=0) |
|
51 |
r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalResetConcurrencyInfo,(TAny*)aLocDrvNo,(TAny*)aMediaStats); |
|
52 |
if(r==KErrNotSupported) |
|
53 |
r = KErrNone; |
|
54 |
return r; |
|
55 |
} |
|
56 |
||
57 |
||
58 |
TInt PagingInfo::PrintConcurrency(TInt aLocDrvNo, TMediaPagingStats aMediaStats) |
|
59 |
{ |
|
60 |
SPagingConcurrencyInfo info; |
|
61 |
TInt r = UserSvr::HalFunction(EHalGroupVM, EVMHalGetConcurrencyInfo, &info, NULL); |
|
62 |
if (r!=KErrNotSupported && r!=KErrNone) |
|
63 |
return r; |
|
64 |
if (r == KErrNone) |
|
65 |
{ |
|
66 |
RDebug::Printf("Concurrency info:"); |
|
67 |
RDebug::Printf(" Max waiting threads == %d", info.iMaxWaitingCount); |
|
68 |
RDebug::Printf(" Max paging threads == %d", info.iMaxPagingCount); |
|
69 |
} |
|
70 |
if(aLocDrvNo>=0) |
|
71 |
{ |
|
72 |
if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsRom) |
|
73 |
{ |
|
74 |
SMediaROMPagingConcurrencyInfo info; |
|
75 |
r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetROMConcurrencyInfo,(TAny*)aLocDrvNo,&info); |
|
76 |
if (r!=KErrNotSupported && r!=KErrNone) |
|
77 |
return r; |
|
78 |
if(r==KErrNone) |
|
79 |
{ |
|
80 |
RDebug::Printf("ROM paging media concurrency stats on drive %d:",aLocDrvNo); |
|
81 |
RDebug::Printf(" Total page-in issued whilst processing other page-ins : %d",info.iTotalConcurrentReqs); |
|
82 |
RDebug::Printf(" Total page-in issued with at least one queue not empty : %d",info.iTotalReqIssuedNonEmptyQ); |
|
83 |
RDebug::Printf(" Max pending page-in in the main queue : %d",info.iMaxReqsInPending); |
|
84 |
RDebug::Printf(" Max pending page-in in the deferred queue : %d",info.iMaxReqsInDeferred); |
|
85 |
RDebug::Printf(" Total page-in first-time deferred during this session : %d",info.iTotalFirstTimeDeferrals); |
|
86 |
RDebug::Printf(" Total page-in re-deferred during this session : %d",info.iTotalReDeferrals); |
|
87 |
RDebug::Printf(" Maximum deferrals of any single page-in : %d",info.iMaxDeferrals); |
|
88 |
RDebug::Printf(" Total times the main queue was emptied during asynchronous request : %d",info.iTotalSynchEmptiedMainQ); |
|
89 |
RDebug::Printf(" Total page-in serviced from main queue during asynchronous request : %d",info.iTotalSynchServicedFromMainQ); |
|
90 |
RDebug::Printf(" Total page-in deferred from main queue during asynchronous request : %d",info.iTotalSynchDeferredFromMainQ); |
|
91 |
RDebug::Printf(" Total page-in DFC run with an empty main queue : %d",info.iTotalRunDry); |
|
92 |
RDebug::Printf(" Total dry runs of paging DFC avoided : %d",info.iTotalDryRunsAvoided); |
|
93 |
} |
|
94 |
} |
|
95 |
||
96 |
if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsCode) |
|
97 |
{ |
|
98 |
SMediaCodePagingConcurrencyInfo infoCode; |
|
99 |
r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetCodeConcurrencyInfo,(TAny*)aLocDrvNo,&infoCode); |
|
100 |
if(r==KErrNone) |
|
101 |
{ |
|
102 |
RDebug::Printf("Media Code Paging concurrency stats on drive %d", aLocDrvNo); |
|
103 |
RDebug::Printf(" Total page-in issued whilst processing other page in requests : %d", infoCode.iTotalConcurrentReqs); |
|
104 |
RDebug::Printf(" Total page-in issued with at least one queue not empty : %d", infoCode.iTotalReqIssuedNonEmptyQ); |
|
105 |
RDebug::Printf(" Max pending page-in in the main queue : %d", infoCode.iMaxReqsInPending); |
|
106 |
RDebug::Printf(" Max pending page-in requests in the deferred queue : %d", infoCode.iMaxReqsInDeferred); |
|
107 |
RDebug::Printf(" Total page-in first-time deferred : %d", infoCode.iTotalFirstTimeDeferrals); |
|
108 |
RDebug::Printf(" Total page-in re-deferred during this session (from deferred queue): %d", infoCode.iTotalReDeferrals); |
|
109 |
RDebug::Printf(" Max number of deferrals of any single page in : %d", infoCode.iMaxDeferrals); |
|
110 |
RDebug::Printf(" Total pagein serviced from main queue during asynchronous request : %d", infoCode.iTotalSynchServicedFromMainQ); |
|
111 |
RDebug::Printf(" Total pagein deferred from main queue during asynchronous request : %d", infoCode.iTotalSynchDeferredFromMainQ); |
|
112 |
} |
|
113 |
} |
|
114 |
} |
|
115 |
if (r == KErrNotSupported) |
|
116 |
r = KErrNone; |
|
117 |
return r; |
|
118 |
} |
|
119 |
||
120 |
||
121 |
TInt PagingInfo::ResetEvents() |
|
122 |
{ |
|
123 |
return UserSvr::HalFunction(EHalGroupVM,EVMHalResetEventInfo,0,0); |
|
124 |
} |
|
125 |
||
126 |
||
127 |
TInt PagingInfo::PrintEvents() |
|
128 |
{ |
|
129 |
SVMEventInfo info; |
|
130 |
TPckg<SVMEventInfo> infoBuf(info); |
|
131 |
TInt r = UserSvr::HalFunction(EHalGroupVM,EVMHalGetEventInfo,&infoBuf,0); |
|
132 |
if(r!=KErrNone) |
|
133 |
return r; |
|
134 |
RDebug::Printf("Event info:"); |
|
135 |
RDebug::Printf(" Page fault events: %Ld", info.iPageFaultCount); |
|
136 |
RDebug::Printf(" Page in events: %Ld", info.iPageInReadCount); |
|
137 |
return KErrNone; |
|
138 |
} |
|
139 |
||
140 |
||
141 |
TInt PagingInfo::ResetBenchmarks(TInt aLocDrvNo, TMediaPagingStats aMediaStats) |
|
142 |
{ |
|
143 |
TInt r = KErrNone; |
|
144 |
for (TInt i = 0 ; r == KErrNone && i < EMaxPagingBm ; ++i) |
|
145 |
{ |
|
146 |
r = UserSvr::HalFunction(EHalGroupVM, EVMHalResetPagingBenchmark, (TAny*)i, NULL); |
|
147 |
if (r!=KErrNotSupported && r!=KErrNone) |
|
148 |
return r; |
|
149 |
} |
|
150 |
if(aLocDrvNo>=0) |
|
151 |
r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalResetPagingBenchmark,(TAny*)aLocDrvNo,(TAny*)aMediaStats); |
|
152 |
if(r==KErrNotSupported) |
|
153 |
r = KErrNone; |
|
154 |
return r; |
|
155 |
} |
|
156 |
||
157 |
||
158 |
TInt PagingInfo::PrintBenchmarks(TInt aLocDrvNo, TMediaPagingStats aMediaStats) |
|
159 |
{ |
|
160 |
RDebug::Printf("Paging benchmarks:"); |
|
161 |
RDebug::Printf(" Name: Count: Min (us): Max(us): Avg(us):"); |
|
162 |
||
163 |
TInt freq = 0; |
|
164 |
TReal min; |
|
165 |
TReal max; |
|
166 |
TReal avg; |
|
167 |
TInt r = HAL::Get(HAL::EFastCounterFrequency, freq); |
|
168 |
if (r != KErrNone) |
|
169 |
return r; |
|
170 |
||
171 |
TReal mult = 1000000.0 / freq; |
|
172 |
||
173 |
for (TInt i = 0 ; i < EMaxPagingBm ; ++i) |
|
174 |
{ |
|
175 |
SPagingBenchmarkInfo info; |
|
176 |
r = UserSvr::HalFunction(EHalGroupVM, EVMHalGetPagingBenchmark, (TAny*)i, &info); |
|
177 |
if (r!=KErrNotSupported && r!=KErrNone) |
|
178 |
return r; |
|
179 |
if (r == KErrNone) |
|
180 |
{ |
|
181 |
min = 0.0; |
|
182 |
max = 0.0; |
|
183 |
avg = 0.0; |
|
184 |
if (info.iCount != 0) |
|
185 |
{ |
|
186 |
min = info.iMinTime * mult; |
|
187 |
max = info.iMaxTime * mult; |
|
188 |
avg = (info.iTotalTime * mult) / info.iCount; |
|
189 |
} |
|
190 |
const TUint8* name = BenchmarkNames[i]; |
|
191 |
RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", name, info.iCount, min, max, avg); |
|
192 |
} |
|
193 |
} |
|
194 |
||
195 |
if(aLocDrvNo>=0) |
|
196 |
{ |
|
197 |
if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsRom) |
|
198 |
{ |
|
199 |
SPagingBenchmarkInfo info; |
|
200 |
r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetROMPagingBenchmark,(TAny*)aLocDrvNo,&info); |
|
201 |
if (r!=KErrNotSupported && r!=KErrNone) |
|
202 |
return r; |
|
203 |
if(r==KErrNone) |
|
204 |
{ |
|
205 |
if (info.iCount != 0) |
|
206 |
{ |
|
207 |
min = info.iMinTime * mult; |
|
208 |
max = info.iMaxTime * mult; |
|
209 |
avg = (info.iTotalTime * mult) / info.iCount; |
|
210 |
RDebug::Printf("ROM paging media benchmarks on drive %d:",aLocDrvNo); |
|
211 |
RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg); |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
||
216 |
if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsCode) |
|
217 |
{ |
|
218 |
SPagingBenchmarkInfo info; |
|
219 |
r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetCodePagingBenchmark,(TAny*)aLocDrvNo,&info); |
|
220 |
if (r!=KErrNotSupported && r!=KErrNone) |
|
221 |
return r; |
|
222 |
if(r==KErrNone) |
|
223 |
{ |
|
224 |
if (info.iCount != 0) |
|
225 |
{ |
|
226 |
min = info.iMinTime * mult; |
|
227 |
max = info.iMaxTime * mult; |
|
228 |
avg = (info.iTotalTime * mult) / info.iCount; |
|
229 |
RDebug::Printf("Code paging media benchmarks on drive %d:",aLocDrvNo); |
|
230 |
RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg); |
|
231 |
} |
|
232 |
} |
|
233 |
} |
|
234 |
||
235 |
if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsDataIn) |
|
236 |
{ |
|
237 |
SPagingBenchmarkInfo info; |
|
238 |
r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetDataInPagingBenchmark,(TAny*)aLocDrvNo,&info); |
|
239 |
if (r!=KErrNotSupported && r!=KErrNone) |
|
240 |
return r; |
|
241 |
if(r==KErrNone) |
|
242 |
{ |
|
243 |
if (info.iCount != 0) |
|
244 |
{ |
|
245 |
min = info.iMinTime * mult; |
|
246 |
max = info.iMaxTime * mult; |
|
247 |
avg = (info.iTotalTime * mult) / info.iCount; |
|
248 |
RDebug::Printf("Data page-in media benchmarks on drive %d:",aLocDrvNo); |
|
249 |
RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg); |
|
250 |
} |
|
251 |
} |
|
252 |
} |
|
253 |
||
254 |
if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsDataOut) |
|
255 |
{ |
|
256 |
SPagingBenchmarkInfo info; |
|
257 |
r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetDataOutPagingBenchmark,(TAny*)aLocDrvNo,&info); |
|
258 |
if (r!=KErrNotSupported && r!=KErrNone) |
|
259 |
return r; |
|
260 |
if(r==KErrNone) |
|
261 |
{ |
|
262 |
if (info.iCount != 0) |
|
263 |
{ |
|
264 |
min = info.iMinTime * mult; |
|
265 |
max = info.iMaxTime * mult; |
|
266 |
avg = (info.iTotalTime * mult) / info.iCount; |
|
267 |
RDebug::Printf("Data page-out media benchmarks on drive %d:",aLocDrvNo); |
|
268 |
RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg); |
|
269 |
} |
|
270 |
} |
|
271 |
} |
|
272 |
||
273 |
} |
|
274 |
||
275 |
return KErrNone; |
|
276 |
} |
|
277 |
||
278 |
||
279 |
TInt PagingInfo::ResetAll(TInt aLocDrvNo, TMediaPagingStats aMediaStats) |
|
280 |
{ |
|
281 |
TInt r = ResetEvents(); |
|
282 |
if (r == KErrNone || r == KErrNotSupported) |
|
283 |
r = ResetConcurrency(aLocDrvNo,aMediaStats); |
|
284 |
if (r == KErrNone || r == KErrNotSupported) |
|
285 |
r = ResetBenchmarks(aLocDrvNo,aMediaStats); |
|
286 |
if (r == KErrNotSupported) |
|
287 |
r = KErrNone; |
|
288 |
return r; |
|
289 |
} |
|
290 |
||
291 |
||
292 |
TInt PagingInfo::PrintAll(TInt aLocDrvNo, TMediaPagingStats aMediaStats) |
|
293 |
{ |
|
294 |
TInt r = PrintEvents(); |
|
295 |
if (r == KErrNone || r == KErrNotSupported) |
|
296 |
r = PrintConcurrency(aLocDrvNo,aMediaStats); |
|
297 |
if (r == KErrNone || r == KErrNotSupported) |
|
298 |
r = PrintBenchmarks(aLocDrvNo,aMediaStats); |
|
299 |
if (r == KErrNotSupported) |
|
300 |
r = KErrNone; |
|
301 |
return r; |
|
302 |
} |
|
303 |
||
304 |