diff -r bbf8bed59bcb -r 2bb754abd467 kernel/eka/memmodel/epoc/flexible/mmu/mpager.cpp --- a/kernel/eka/memmodel/epoc/flexible/mmu/mpager.cpp Wed Jun 09 11:10:19 2010 +0300 +++ b/kernel/eka/memmodel/epoc/flexible/mmu/mpager.cpp Mon Jun 21 17:12:14 2010 +0300 @@ -458,8 +458,7 @@ case SPageInfo::EPagedOld: case SPageInfo::EPagedOldestClean: case SPageInfo::EPagedOldestDirty: - {// Update the list links point to the new page. - __NK_ASSERT_DEBUG(iYoungCount); + {// Update the list links to point to the new page. SDblQueLink* prevLink = aOldPageInfo.iLink.iPrev; #ifdef _DEBUG SDblQueLink* nextLink = aOldPageInfo.iLink.iNext; @@ -635,7 +634,10 @@ template class TSequentialColourSelector { public: - static const TUint KMaxSearchLength = _ALIGN_UP(maxObjects, KPageColourCount); + enum + { + KMaxSearchLength = _ALIGN_UP(maxObjects, KPageColourCount) + }; FORCE_INLINE TSequentialColourSelector(TUint aTargetLength) { @@ -1109,6 +1111,41 @@ } +TUint DPager::AllowAddFreePages(SPageInfo*& aPageInfo, TUint aNumPages) + { + if (iMinimumPageCount + iNumberOfFreePages == iMaximumPageCount) + {// The paging cache is already at the maximum size so steal a page + // so it can be returned to the system if required. + aPageInfo = StealOrAllocPage(EFalse, (Mmu::TRamAllocFlags)0); + __NK_ASSERT_DEBUG(aPageInfo->PagedState() == SPageInfo::EUnpaged); + return 1; + } + // The paging cache is not at its maximum so determine how many can be added to + // the paging cache without it growing past its maximum. + aPageInfo = NULL; + __NK_ASSERT_DEBUG(iMinimumPageCount + iNumberOfFreePages < iMaximumPageCount); + if (iMinimumPageCount + iNumberOfFreePages + aNumPages > iMaximumPageCount) + { + return iMaximumPageCount - (iMinimumPageCount + iNumberOfFreePages); + } + else + return aNumPages; + } + + +void DPager::AllowAddFreePage(SPageInfo*& aPageInfo) + { + if (iMinimumPageCount + iNumberOfFreePages == iMaximumPageCount) + {// The paging cache is already at the maximum size so steal a page + // so it can be returned to the system if required. + aPageInfo = StealOrAllocPage(EFalse, (Mmu::TRamAllocFlags)0); + __NK_ASSERT_DEBUG(aPageInfo->PagedState() == SPageInfo::EUnpaged); + return; + } + aPageInfo = NULL; + } + + void DPager::ReturnPageToSystem(SPageInfo& aPageInfo) { __NK_ASSERT_DEBUG(RamAllocLock::IsHeld()); @@ -1186,9 +1223,18 @@ TPhysAddr* end = aPages+aCount; while(aPagesaMaximumPageCount) + if(aMinimumPageCount > aMaximumPageCount) return KErrArgument; NKern::ThreadEnterCS(); @@ -2072,12 +2151,12 @@ // Make sure aMinimumPageCount is not less than absolute minimum we can cope with... iMinimumPageLimit = iMinYoungPages * (1 + iYoungOldRatio) / iYoungOldRatio + DPageReadRequest::ReservedPagesRequired(); - if(iMinimumPageLimit iMaximumPageCount) @@ -2091,7 +2170,7 @@ } // Increase iMinimumPageCount? - TInt r=KErrNone; + TInt r = KErrNone; while(aMinimumPageCount > iMinimumPageCount) { TUint newMin = MinU(aMinimumPageCount, iMinimumPageCount + iNumberOfFreePages); @@ -2101,7 +2180,7 @@ // have to add pages before we can increase minimum page count if(!TryGrowLiveList()) { - r=KErrNoMemory; + r = KErrNoMemory; break; } }