Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\mmu\paging_info.cpp
22 #include "paging_info.h"
25 const TUint8* BenchmarkNames[] =
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",
41 __ASSERT_COMPILE(sizeof(BenchmarkNames)/sizeof(TUint8*) == EMaxPagingBm);
44 TInt PagingInfo::ResetConcurrency(TInt aLocDrvNo, TMediaPagingStats aMediaStats)
46 TInt r = UserSvr::HalFunction(EHalGroupVM, EVMHalResetConcurrencyInfo, NULL, NULL);
47 if (r!=KErrNotSupported && r!=KErrNone)
50 r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalResetConcurrencyInfo,(TAny*)aLocDrvNo,(TAny*)aMediaStats);
51 if(r==KErrNotSupported)
57 TInt PagingInfo::PrintConcurrency(TInt aLocDrvNo, TMediaPagingStats aMediaStats)
59 SPagingConcurrencyInfo info;
60 TInt r = UserSvr::HalFunction(EHalGroupVM, EVMHalGetConcurrencyInfo, &info, NULL);
61 if (r!=KErrNotSupported && r!=KErrNone)
65 RDebug::Printf("Concurrency info:");
66 RDebug::Printf(" Max waiting threads == %d", info.iMaxWaitingCount);
67 RDebug::Printf(" Max paging threads == %d", info.iMaxPagingCount);
71 if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsRom)
73 SMediaROMPagingConcurrencyInfo info;
74 r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetROMConcurrencyInfo,(TAny*)aLocDrvNo,&info);
75 if (r!=KErrNotSupported && r!=KErrNone)
79 RDebug::Printf("ROM paging media concurrency stats on drive %d:",aLocDrvNo);
80 RDebug::Printf(" Total page-in issued whilst processing other page-ins : %d",info.iTotalConcurrentReqs);
81 RDebug::Printf(" Total page-in issued with at least one queue not empty : %d",info.iTotalReqIssuedNonEmptyQ);
82 RDebug::Printf(" Max pending page-in in the main queue : %d",info.iMaxReqsInPending);
83 RDebug::Printf(" Max pending page-in in the deferred queue : %d",info.iMaxReqsInDeferred);
84 RDebug::Printf(" Total page-in first-time deferred during this session : %d",info.iTotalFirstTimeDeferrals);
85 RDebug::Printf(" Total page-in re-deferred during this session : %d",info.iTotalReDeferrals);
86 RDebug::Printf(" Maximum deferrals of any single page-in : %d",info.iMaxDeferrals);
87 RDebug::Printf(" Total times the main queue was emptied during asynchronous request : %d",info.iTotalSynchEmptiedMainQ);
88 RDebug::Printf(" Total page-in serviced from main queue during asynchronous request : %d",info.iTotalSynchServicedFromMainQ);
89 RDebug::Printf(" Total page-in deferred from main queue during asynchronous request : %d",info.iTotalSynchDeferredFromMainQ);
90 RDebug::Printf(" Total page-in DFC run with an empty main queue : %d",info.iTotalRunDry);
91 RDebug::Printf(" Total dry runs of paging DFC avoided : %d",info.iTotalDryRunsAvoided);
95 if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsCode)
97 SMediaCodePagingConcurrencyInfo infoCode;
98 r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetCodeConcurrencyInfo,(TAny*)aLocDrvNo,&infoCode);
101 RDebug::Printf("Media Code Paging concurrency stats on drive %d", aLocDrvNo);
102 RDebug::Printf(" Total page-in issued whilst processing other page in requests : %d", infoCode.iTotalConcurrentReqs);
103 RDebug::Printf(" Total page-in issued with at least one queue not empty : %d", infoCode.iTotalReqIssuedNonEmptyQ);
104 RDebug::Printf(" Max pending page-in in the main queue : %d", infoCode.iMaxReqsInPending);
105 RDebug::Printf(" Max pending page-in requests in the deferred queue : %d", infoCode.iMaxReqsInDeferred);
106 RDebug::Printf(" Total page-in first-time deferred : %d", infoCode.iTotalFirstTimeDeferrals);
107 RDebug::Printf(" Total page-in re-deferred during this session (from deferred queue): %d", infoCode.iTotalReDeferrals);
108 RDebug::Printf(" Max number of deferrals of any single page in : %d", infoCode.iMaxDeferrals);
109 RDebug::Printf(" Total pagein serviced from main queue during asynchronous request : %d", infoCode.iTotalSynchServicedFromMainQ);
110 RDebug::Printf(" Total pagein deferred from main queue during asynchronous request : %d", infoCode.iTotalSynchDeferredFromMainQ);
114 if (r == KErrNotSupported)
120 TInt PagingInfo::ResetEvents()
122 return UserSvr::HalFunction(EHalGroupVM,EVMHalResetEventInfo,0,0);
126 TInt PagingInfo::PrintEvents()
129 TPckg<SVMEventInfo> infoBuf(info);
130 TInt r = UserSvr::HalFunction(EHalGroupVM,EVMHalGetEventInfo,&infoBuf,0);
133 RDebug::Printf("Event info:");
134 RDebug::Printf(" Page fault events: %Ld", info.iPageFaultCount);
135 RDebug::Printf(" Page in events: %Ld", info.iPageInReadCount);
140 TInt PagingInfo::ResetBenchmarks(TInt aLocDrvNo, TMediaPagingStats aMediaStats)
143 for (TInt i = 0 ; r == KErrNone && i < EMaxPagingBm ; ++i)
145 r = UserSvr::HalFunction(EHalGroupVM, EVMHalResetPagingBenchmark, (TAny*)i, NULL);
146 if (r!=KErrNotSupported && r!=KErrNone)
150 r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalResetPagingBenchmark,(TAny*)aLocDrvNo,(TAny*)aMediaStats);
151 if(r==KErrNotSupported)
157 TInt PagingInfo::PrintBenchmarks(TInt aLocDrvNo, TMediaPagingStats aMediaStats)
159 RDebug::Printf("Paging benchmarks:");
160 RDebug::Printf(" Name: Count: Min (us): Max(us): Avg(us):");
166 TInt r = HAL::Get(HAL::EFastCounterFrequency, freq);
170 TReal mult = 1000000.0 / freq;
172 for (TInt i = 0 ; i < EMaxPagingBm ; ++i)
174 SPagingBenchmarkInfo info;
175 r = UserSvr::HalFunction(EHalGroupVM, EVMHalGetPagingBenchmark, (TAny*)i, &info);
176 if (r!=KErrNotSupported && r!=KErrNone)
183 if (info.iCount != 0)
185 min = info.iMinTime * mult;
186 max = info.iMaxTime * mult;
187 avg = (info.iTotalTime * mult) / info.iCount;
189 const TUint8* name = BenchmarkNames[i];
190 RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", name, info.iCount, min, max, avg);
196 if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsRom)
198 SPagingBenchmarkInfo info;
199 r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetROMPagingBenchmark,(TAny*)aLocDrvNo,&info);
200 if (r!=KErrNotSupported && r!=KErrNone)
204 if (info.iCount != 0)
206 min = info.iMinTime * mult;
207 max = info.iMaxTime * mult;
208 avg = (info.iTotalTime * mult) / info.iCount;
209 RDebug::Printf("ROM paging media benchmarks on drive %d:",aLocDrvNo);
210 RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg);
215 if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsCode)
217 SPagingBenchmarkInfo info;
218 r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetCodePagingBenchmark,(TAny*)aLocDrvNo,&info);
219 if (r!=KErrNotSupported && r!=KErrNone)
223 if (info.iCount != 0)
225 min = info.iMinTime * mult;
226 max = info.iMaxTime * mult;
227 avg = (info.iTotalTime * mult) / info.iCount;
228 RDebug::Printf("Code paging media benchmarks on drive %d:",aLocDrvNo);
229 RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg);
234 if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsDataIn)
236 SPagingBenchmarkInfo info;
237 r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetDataInPagingBenchmark,(TAny*)aLocDrvNo,&info);
238 if (r!=KErrNotSupported && r!=KErrNone)
242 if (info.iCount != 0)
244 min = info.iMinTime * mult;
245 max = info.iMaxTime * mult;
246 avg = (info.iTotalTime * mult) / info.iCount;
247 RDebug::Printf("Data page-in media benchmarks on drive %d:",aLocDrvNo);
248 RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg);
253 if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsDataOut)
255 SPagingBenchmarkInfo info;
256 r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetDataOutPagingBenchmark,(TAny*)aLocDrvNo,&info);
257 if (r!=KErrNotSupported && r!=KErrNone)
261 if (info.iCount != 0)
263 min = info.iMinTime * mult;
264 max = info.iMaxTime * mult;
265 avg = (info.iTotalTime * mult) / info.iCount;
266 RDebug::Printf("Data page-out media benchmarks on drive %d:",aLocDrvNo);
267 RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg);
278 TInt PagingInfo::ResetAll(TInt aLocDrvNo, TMediaPagingStats aMediaStats)
280 TInt r = ResetEvents();
281 if (r == KErrNone || r == KErrNotSupported)
282 r = ResetConcurrency(aLocDrvNo,aMediaStats);
283 if (r == KErrNone || r == KErrNotSupported)
284 r = ResetBenchmarks(aLocDrvNo,aMediaStats);
285 if (r == KErrNotSupported)
291 TInt PagingInfo::PrintAll(TInt aLocDrvNo, TMediaPagingStats aMediaStats)
293 TInt r = PrintEvents();
294 if (r == KErrNone || r == KErrNotSupported)
295 r = PrintConcurrency(aLocDrvNo,aMediaStats);
296 if (r == KErrNone || r == KErrNotSupported)
297 r = PrintBenchmarks(aLocDrvNo,aMediaStats);
298 if (r == KErrNotSupported)