equal
deleted
inserted
replaced
76 __KTRACE_OPT(KMMU, Kern::Printf("ClearMovableFromZone: ID %x ", aZone.iId)); |
76 __KTRACE_OPT(KMMU, Kern::Printf("ClearMovableFromZone: ID %x ", aZone.iId)); |
77 |
77 |
78 TUint offset = 0; |
78 TUint offset = 0; |
79 TPhysAddr newAddr; |
79 TPhysAddr newAddr; |
80 TBool zoneActive = EFalse; |
80 TBool zoneActive = EFalse; |
|
81 const TUint moveDisFlags = (aBestEffort)? 0 : M::EMoveDisBlockRest | M::EMoveDisMoveDirty; |
81 TInt ret = iRamAllocator->NextAllocatedPage(&aZone, offset, EPageMovable); |
82 TInt ret = iRamAllocator->NextAllocatedPage(&aZone, offset, EPageMovable); |
82 |
83 |
83 // if not best effort mode keep moving pages unless someone allocates into |
84 // if not best effort mode keep moving pages unless someone allocates into |
84 // the zone or an unmovable page is hit. |
85 // the zone or an unmovable page is hit. |
85 // If in best effort mode then attempt to move all allocated pages in |
86 // If in best effort mode then attempt to move all allocated pages in |
99 zoneActive)) |
100 zoneActive)) |
100 { |
101 { |
101 __KTRACE_OPT(KMMU, Kern::Printf("ClearMovableFromZone: memory too low or zone active addr %x", addr)); |
102 __KTRACE_OPT(KMMU, Kern::Printf("ClearMovableFromZone: memory too low or zone active addr %x", addr)); |
102 return KErrNoMemory; |
103 return KErrNoMemory; |
103 } |
104 } |
104 TInt moved = M::MovePage(addr, newAddr, aZone.iId, !aBestEffort); |
105 TInt moved = M::MovePage(addr, newAddr, aZone.iId, moveDisFlags); |
105 if (moved != KErrNone) |
106 if (moved != KErrNone) |
106 {// Couldn't move the page so stop as we can't clear the zone |
107 {// Couldn't move the page so stop as we can't clear the zone |
107 if (!aBestEffort) |
108 if (!aBestEffort) |
108 { |
109 { |
109 __KTRACE_OPT(KMMU, Kern::Printf("ClearMovableFromZone exit: move fail zone %x addr %x", aZone.iId, addr)); |
110 __KTRACE_OPT(KMMU, Kern::Printf("ClearMovableFromZone exit: move fail zone %x addr %x", aZone.iId, addr)); |
142 __KTRACE_OPT(KMMU, Kern::Printf("ClearDiscardableFromZone: ID %x ", aZone.iId)); |
143 __KTRACE_OPT(KMMU, Kern::Printf("ClearDiscardableFromZone: ID %x ", aZone.iId)); |
143 |
144 |
144 TUint offset = 0; |
145 TUint offset = 0; |
145 TBool zoneActive = EFalse; |
146 TBool zoneActive = EFalse; |
146 TInt ret = iRamAllocator->NextAllocatedPage(&aZone, offset, EPageDiscard); |
147 TInt ret = iRamAllocator->NextAllocatedPage(&aZone, offset, EPageDiscard); |
|
148 const TUint moveDisFlags = (aBestEffort)? 0 : M::EMoveDisBlockRest | M::EMoveDisMoveDirty; |
147 |
149 |
148 |
150 |
149 while ( aZone.iAllocPages[EPageDiscard] != 0 && ret == KErrNone && |
151 while ( aZone.iAllocPages[EPageDiscard] != 0 && ret == KErrNone && |
150 (!aMaxDiscard || *aMaxDiscard)) |
152 (!aMaxDiscard || *aMaxDiscard)) |
151 { |
153 { |
167 { |
169 { |
168 __KTRACE_OPT(KMMU, Kern::Printf("ClearDiscardableFromZone: memory too low or zone active addr %x", addr)); |
170 __KTRACE_OPT(KMMU, Kern::Printf("ClearDiscardableFromZone: memory too low or zone active addr %x", addr)); |
169 return KErrNoMemory; |
171 return KErrNoMemory; |
170 } |
172 } |
171 |
173 |
172 TInt discardRet = M::DiscardPage(addr, aZone.iId, !aBestEffort); |
174 TInt discardRet = M::DiscardPage(addr, aZone.iId, moveDisFlags); |
173 if (discardRet == KErrNone) |
175 if (discardRet == KErrNone) |
174 {// Page was discarded successfully. |
176 {// Page was discarded successfully. |
175 if (aMaxDiscard) |
177 if (aMaxDiscard) |
176 (*aMaxDiscard)--; |
178 (*aMaxDiscard)--; |
177 } |
179 } |
403 __KTRACE_OPT(KMMU, Kern::Printf("ClaimZone success - zone%x", zone->iId)); |
405 __KTRACE_OPT(KMMU, Kern::Printf("ClaimZone success - zone%x", zone->iId)); |
404 #ifdef BTRACE_RAM_ALLOCATOR |
406 #ifdef BTRACE_RAM_ALLOCATOR |
405 BTrace4(BTrace::ERamAllocator, BTrace::ERamAllocClaimZone, zone->iId); |
407 BTrace4(BTrace::ERamAllocator, BTrace::ERamAllocClaimZone, zone->iId); |
406 #endif |
408 #endif |
407 |
409 |
408 #ifdef BTRACE_KERNEL_MEMORY |
410 #if defined(BTRACE_KERNEL_MEMORY) && !defined(__MEMMODEL_FLEXIBLE__) |
409 TUint size = zone->iPhysPages << M::PageShift(); |
411 TUint size = zone->iPhysPages << M::PageShift(); |
410 BTrace8(BTrace::EKernelMemory, BTrace::EKernelMemoryDrvPhysAlloc, size, zone->iPhysBase); |
412 BTrace8(BTrace::EKernelMemory, BTrace::EKernelMemoryDrvPhysAlloc, size, zone->iPhysBase); |
411 Epoc::DriverAllocdPhysRam += size; |
413 Epoc::DriverAllocdPhysRam += size; |
412 #endif |
414 #endif |
413 |
415 |