sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\mmu\paging_info.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "paging_info.h" sl@0: sl@0: sl@0: const TUint8* BenchmarkNames[] = sl@0: { sl@0: (const TUint8*)"Read rom page", sl@0: (const TUint8*)"Read code page", sl@0: (const TUint8*)"Decompress", sl@0: (const TUint8*)"Set code page free", sl@0: (const TUint8*)"Set code page old", sl@0: (const TUint8*)"Read media", sl@0: (const TUint8*)"Fixup code page", sl@0: (const TUint8*)"Read data page", sl@0: (const TUint8*)"Write data page", sl@0: (const TUint8*)"Del notify data page", sl@0: (const TUint8*)"Read media data page", sl@0: (const TUint8*)"Write media data page", sl@0: }; sl@0: sl@0: __ASSERT_COMPILE(sizeof(BenchmarkNames)/sizeof(TUint8*) == EMaxPagingBm); sl@0: sl@0: sl@0: TInt PagingInfo::ResetConcurrency(TInt aLocDrvNo, TMediaPagingStats aMediaStats) sl@0: { sl@0: TInt r = UserSvr::HalFunction(EHalGroupVM, EVMHalResetConcurrencyInfo, NULL, NULL); sl@0: if (r!=KErrNotSupported && r!=KErrNone) sl@0: return r; sl@0: if(aLocDrvNo>=0) sl@0: r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalResetConcurrencyInfo,(TAny*)aLocDrvNo,(TAny*)aMediaStats); sl@0: if(r==KErrNotSupported) sl@0: r = KErrNone; sl@0: return r; sl@0: } sl@0: sl@0: sl@0: TInt PagingInfo::PrintConcurrency(TInt aLocDrvNo, TMediaPagingStats aMediaStats) sl@0: { sl@0: SPagingConcurrencyInfo info; sl@0: TInt r = UserSvr::HalFunction(EHalGroupVM, EVMHalGetConcurrencyInfo, &info, NULL); sl@0: if (r!=KErrNotSupported && r!=KErrNone) sl@0: return r; sl@0: if (r == KErrNone) sl@0: { sl@0: RDebug::Printf("Concurrency info:"); sl@0: RDebug::Printf(" Max waiting threads == %d", info.iMaxWaitingCount); sl@0: RDebug::Printf(" Max paging threads == %d", info.iMaxPagingCount); sl@0: } sl@0: if(aLocDrvNo>=0) sl@0: { sl@0: if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsRom) sl@0: { sl@0: SMediaROMPagingConcurrencyInfo info; sl@0: r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetROMConcurrencyInfo,(TAny*)aLocDrvNo,&info); sl@0: if (r!=KErrNotSupported && r!=KErrNone) sl@0: return r; sl@0: if(r==KErrNone) sl@0: { sl@0: RDebug::Printf("ROM paging media concurrency stats on drive %d:",aLocDrvNo); sl@0: RDebug::Printf(" Total page-in issued whilst processing other page-ins : %d",info.iTotalConcurrentReqs); sl@0: RDebug::Printf(" Total page-in issued with at least one queue not empty : %d",info.iTotalReqIssuedNonEmptyQ); sl@0: RDebug::Printf(" Max pending page-in in the main queue : %d",info.iMaxReqsInPending); sl@0: RDebug::Printf(" Max pending page-in in the deferred queue : %d",info.iMaxReqsInDeferred); sl@0: RDebug::Printf(" Total page-in first-time deferred during this session : %d",info.iTotalFirstTimeDeferrals); sl@0: RDebug::Printf(" Total page-in re-deferred during this session : %d",info.iTotalReDeferrals); sl@0: RDebug::Printf(" Maximum deferrals of any single page-in : %d",info.iMaxDeferrals); sl@0: RDebug::Printf(" Total times the main queue was emptied during asynchronous request : %d",info.iTotalSynchEmptiedMainQ); sl@0: RDebug::Printf(" Total page-in serviced from main queue during asynchronous request : %d",info.iTotalSynchServicedFromMainQ); sl@0: RDebug::Printf(" Total page-in deferred from main queue during asynchronous request : %d",info.iTotalSynchDeferredFromMainQ); sl@0: RDebug::Printf(" Total page-in DFC run with an empty main queue : %d",info.iTotalRunDry); sl@0: RDebug::Printf(" Total dry runs of paging DFC avoided : %d",info.iTotalDryRunsAvoided); sl@0: } sl@0: } sl@0: sl@0: if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsCode) sl@0: { sl@0: SMediaCodePagingConcurrencyInfo infoCode; sl@0: r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetCodeConcurrencyInfo,(TAny*)aLocDrvNo,&infoCode); sl@0: if(r==KErrNone) sl@0: { sl@0: RDebug::Printf("Media Code Paging concurrency stats on drive %d", aLocDrvNo); sl@0: RDebug::Printf(" Total page-in issued whilst processing other page in requests : %d", infoCode.iTotalConcurrentReqs); sl@0: RDebug::Printf(" Total page-in issued with at least one queue not empty : %d", infoCode.iTotalReqIssuedNonEmptyQ); sl@0: RDebug::Printf(" Max pending page-in in the main queue : %d", infoCode.iMaxReqsInPending); sl@0: RDebug::Printf(" Max pending page-in requests in the deferred queue : %d", infoCode.iMaxReqsInDeferred); sl@0: RDebug::Printf(" Total page-in first-time deferred : %d", infoCode.iTotalFirstTimeDeferrals); sl@0: RDebug::Printf(" Total page-in re-deferred during this session (from deferred queue): %d", infoCode.iTotalReDeferrals); sl@0: RDebug::Printf(" Max number of deferrals of any single page in : %d", infoCode.iMaxDeferrals); sl@0: RDebug::Printf(" Total pagein serviced from main queue during asynchronous request : %d", infoCode.iTotalSynchServicedFromMainQ); sl@0: RDebug::Printf(" Total pagein deferred from main queue during asynchronous request : %d", infoCode.iTotalSynchDeferredFromMainQ); sl@0: } sl@0: } sl@0: } sl@0: if (r == KErrNotSupported) sl@0: r = KErrNone; sl@0: return r; sl@0: } sl@0: sl@0: sl@0: TInt PagingInfo::ResetEvents() sl@0: { sl@0: return UserSvr::HalFunction(EHalGroupVM,EVMHalResetEventInfo,0,0); sl@0: } sl@0: sl@0: sl@0: TInt PagingInfo::PrintEvents() sl@0: { sl@0: SVMEventInfo info; sl@0: TPckg infoBuf(info); sl@0: TInt r = UserSvr::HalFunction(EHalGroupVM,EVMHalGetEventInfo,&infoBuf,0); sl@0: if(r!=KErrNone) sl@0: return r; sl@0: RDebug::Printf("Event info:"); sl@0: RDebug::Printf(" Page fault events: %Ld", info.iPageFaultCount); sl@0: RDebug::Printf(" Page in events: %Ld", info.iPageInReadCount); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: TInt PagingInfo::ResetBenchmarks(TInt aLocDrvNo, TMediaPagingStats aMediaStats) sl@0: { sl@0: TInt r = KErrNone; sl@0: for (TInt i = 0 ; r == KErrNone && i < EMaxPagingBm ; ++i) sl@0: { sl@0: r = UserSvr::HalFunction(EHalGroupVM, EVMHalResetPagingBenchmark, (TAny*)i, NULL); sl@0: if (r!=KErrNotSupported && r!=KErrNone) sl@0: return r; sl@0: } sl@0: if(aLocDrvNo>=0) sl@0: r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalResetPagingBenchmark,(TAny*)aLocDrvNo,(TAny*)aMediaStats); sl@0: if(r==KErrNotSupported) sl@0: r = KErrNone; sl@0: return r; sl@0: } sl@0: sl@0: sl@0: TInt PagingInfo::PrintBenchmarks(TInt aLocDrvNo, TMediaPagingStats aMediaStats) sl@0: { sl@0: RDebug::Printf("Paging benchmarks:"); sl@0: RDebug::Printf(" Name: Count: Min (us): Max(us): Avg(us):"); sl@0: sl@0: TInt freq = 0; sl@0: TReal min; sl@0: TReal max; sl@0: TReal avg; sl@0: TInt r = HAL::Get(HAL::EFastCounterFrequency, freq); sl@0: if (r != KErrNone) sl@0: return r; sl@0: sl@0: TReal mult = 1000000.0 / freq; sl@0: sl@0: for (TInt i = 0 ; i < EMaxPagingBm ; ++i) sl@0: { sl@0: SPagingBenchmarkInfo info; sl@0: r = UserSvr::HalFunction(EHalGroupVM, EVMHalGetPagingBenchmark, (TAny*)i, &info); sl@0: if (r!=KErrNotSupported && r!=KErrNone) sl@0: return r; sl@0: if (r == KErrNone) sl@0: { sl@0: min = 0.0; sl@0: max = 0.0; sl@0: avg = 0.0; sl@0: if (info.iCount != 0) sl@0: { sl@0: min = info.iMinTime * mult; sl@0: max = info.iMaxTime * mult; sl@0: avg = (info.iTotalTime * mult) / info.iCount; sl@0: } sl@0: const TUint8* name = BenchmarkNames[i]; sl@0: RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", name, info.iCount, min, max, avg); sl@0: } sl@0: } sl@0: sl@0: if(aLocDrvNo>=0) sl@0: { sl@0: if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsRom) sl@0: { sl@0: SPagingBenchmarkInfo info; sl@0: r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetROMPagingBenchmark,(TAny*)aLocDrvNo,&info); sl@0: if (r!=KErrNotSupported && r!=KErrNone) sl@0: return r; sl@0: if(r==KErrNone) sl@0: { sl@0: if (info.iCount != 0) sl@0: { sl@0: min = info.iMinTime * mult; sl@0: max = info.iMaxTime * mult; sl@0: avg = (info.iTotalTime * mult) / info.iCount; sl@0: RDebug::Printf("ROM paging media benchmarks on drive %d:",aLocDrvNo); sl@0: RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg); sl@0: } sl@0: } sl@0: } sl@0: sl@0: if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsCode) sl@0: { sl@0: SPagingBenchmarkInfo info; sl@0: r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetCodePagingBenchmark,(TAny*)aLocDrvNo,&info); sl@0: if (r!=KErrNotSupported && r!=KErrNone) sl@0: return r; sl@0: if(r==KErrNone) sl@0: { sl@0: if (info.iCount != 0) sl@0: { sl@0: min = info.iMinTime * mult; sl@0: max = info.iMaxTime * mult; sl@0: avg = (info.iTotalTime * mult) / info.iCount; sl@0: RDebug::Printf("Code paging media benchmarks on drive %d:",aLocDrvNo); sl@0: RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg); sl@0: } sl@0: } sl@0: } sl@0: sl@0: if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsDataIn) sl@0: { sl@0: SPagingBenchmarkInfo info; sl@0: r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetDataInPagingBenchmark,(TAny*)aLocDrvNo,&info); sl@0: if (r!=KErrNotSupported && r!=KErrNone) sl@0: return r; sl@0: if(r==KErrNone) sl@0: { sl@0: if (info.iCount != 0) sl@0: { sl@0: min = info.iMinTime * mult; sl@0: max = info.iMaxTime * mult; sl@0: avg = (info.iTotalTime * mult) / info.iCount; sl@0: RDebug::Printf("Data page-in media benchmarks on drive %d:",aLocDrvNo); sl@0: RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg); sl@0: } sl@0: } sl@0: } sl@0: sl@0: if(aMediaStats==EMediaPagingStatsAll || aMediaStats==EMediaPagingStatsDataOut) sl@0: { sl@0: SPagingBenchmarkInfo info; sl@0: r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetDataOutPagingBenchmark,(TAny*)aLocDrvNo,&info); sl@0: if (r!=KErrNotSupported && r!=KErrNone) sl@0: return r; sl@0: if(r==KErrNone) sl@0: { sl@0: if (info.iCount != 0) sl@0: { sl@0: min = info.iMinTime * mult; sl@0: max = info.iMaxTime * mult; sl@0: avg = (info.iTotalTime * mult) / info.iCount; sl@0: RDebug::Printf("Data page-out media benchmarks on drive %d:",aLocDrvNo); sl@0: RDebug::Printf(" %-30s %6d %9.1f %9.1f %9.1f", "Page-in latency", info.iCount, min, max, avg); sl@0: } sl@0: } sl@0: } sl@0: sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: TInt PagingInfo::ResetAll(TInt aLocDrvNo, TMediaPagingStats aMediaStats) sl@0: { sl@0: TInt r = ResetEvents(); sl@0: if (r == KErrNone || r == KErrNotSupported) sl@0: r = ResetConcurrency(aLocDrvNo,aMediaStats); sl@0: if (r == KErrNone || r == KErrNotSupported) sl@0: r = ResetBenchmarks(aLocDrvNo,aMediaStats); sl@0: if (r == KErrNotSupported) sl@0: r = KErrNone; sl@0: return r; sl@0: } sl@0: sl@0: sl@0: TInt PagingInfo::PrintAll(TInt aLocDrvNo, TMediaPagingStats aMediaStats) sl@0: { sl@0: TInt r = PrintEvents(); sl@0: if (r == KErrNone || r == KErrNotSupported) sl@0: r = PrintConcurrency(aLocDrvNo,aMediaStats); sl@0: if (r == KErrNone || r == KErrNotSupported) sl@0: r = PrintBenchmarks(aLocDrvNo,aMediaStats); sl@0: if (r == KErrNotSupported) sl@0: r = KErrNone; sl@0: return r; sl@0: } sl@0: sl@0: