kerneltest/e32test/defrag/t_ramdefrag.cpp
branchCompilerCompatibility
changeset 77 c4d65d91ad0c
parent 62 4a8fed1c0ef6
child 102 ef2a444a7410
child 110 c734af59ce98
child 132 e4a7b1cbe40c
equal deleted inserted replaced
74:741dcdf88ba9 77:c4d65d91ad0c
   573 	FSCachCleanUp();
   573 	FSCachCleanUp();
   574 	
   574 	
   575 	UpdateRamInfo();
   575 	UpdateRamInfo();
   576 	gEndRam = gFreeRam;
   576 	gEndRam = gFreeRam;
   577 	TESTDEBUG(test.Printf(_L("End RAM Free = 0x%x, End RAM Used = 0x%x\n"), gEndRam, gRamUsed));
   577 	TESTDEBUG(test.Printf(_L("End RAM Free = 0x%x, End RAM Used = 0x%x\n"), gEndRam, gRamUsed));
       
   578 
       
   579 	// Ensure any asynchronous clean up operations complete before we move on 
       
   580 	// to the next test.
       
   581 	UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
   578 	CheckRamDifference();
   582 	CheckRamDifference();
   579 	test.Printf(_L(" \n"));
   583 	test.Printf(_L(" \n"));
   580 	}
   584 	}
   581 
   585 
   582 //
   586 //
  1751 //!			to be moved for the allocation to succeed, Determine the "best" zone for fixed pages and allocate 1 more
  1755 //!			to be moved for the allocation to succeed, Determine the "best" zone for fixed pages and allocate 1 more
  1752 //!			than that. 
  1756 //!			than that. 
  1753 //!		7.	Allocate discardable pages by loading pages that are demand paged. 
  1757 //!		7.	Allocate discardable pages by loading pages that are demand paged. 
  1754 //! 		Check which zone the memory has been allocated to by checking the number of 
  1758 //! 		Check which zone the memory has been allocated to by checking the number of 
  1755 //! 		discardable pages before and after the allocation has taken place. 
  1759 //! 		discardable pages before and after the allocation has taken place. 
       
  1760 //!		8.	Allocate a contiguous fixed page into a zone which is full of movable or discardable pages.
       
  1761 //!		9.	Allocate a large 1MB aligned chunk with as few pages as possible availiable for page tables,
       
  1762 //!			then clear to every page in the chunk.  This is attempting to ensure that the chunk pages 
       
  1763 //!			that have page tables associated to them are remapped correctly if the chunk pages have to be
       
  1764 //!			moved so page table pages to map other pages in the chunk are allocated in the most preferable 
       
  1765 //! 		ram zones.
  1756 //! 
  1766 //! 
  1757 //! @SYMTestExpectedResults
  1767 //! @SYMTestExpectedResults
  1758 //! 	1.	The memory has been allocated to the most preferred zone with the least amount of 
  1768 //! 	1.	The memory has been allocated to the most preferred zone with the least amount of 
  1759 //! 		space accounting for the zone threshold for movable pages. 
  1769 //! 		space accounting for the zone threshold for movable pages. 
  1760 //!		2.	The new RAM zone is used and the movable page are allocated into it first then the other
  1770 //!		2.	The new RAM zone is used and the movable page are allocated into it first then the other
  1763 //!		4.	The fixed pages are allocatted to the most preferred zone with free, movable or discardable pages in it.
  1773 //!		4.	The fixed pages are allocatted to the most preferred zone with free, movable or discardable pages in it.
  1764 //!		5.	The fixed pages are allocatted to the most preferred zone with free, movable or discardable pages in it.
  1774 //!		5.	The fixed pages are allocatted to the most preferred zone with free, movable or discardable pages in it.
  1765 //! 	6.	Extra page is placed in the next preferable to the "best"zone 
  1775 //! 	6.	Extra page is placed in the next preferable to the "best"zone 
  1766 //!		7.	Memory is allocated to the most preferred zone with the least amount of 
  1776 //!		7.	Memory is allocated to the most preferred zone with the least amount of 
  1767 //! 		space accounting for the zone threshold for discardable pages. 
  1777 //! 		space accounting for the zone threshold for discardable pages. 
       
  1778 //!		8.	The fixed page is allocated as it has moved or discarded a page.
       
  1779 //!		9.	The chunk is cleared succesfully.
       
  1780 //!
  1768 //---------------------------------------------------------------------------------------------------------------------
  1781 //---------------------------------------------------------------------------------------------------------------------
  1769 TInt TestAllocStrategies()
  1782 TInt TestAllocStrategies()
  1770 	{
  1783 	{
  1771 	
  1784 	
  1772 	test.Start(_L("Test1: Check which zone a movable page has been allocated to "));	
  1785 	test.Start(_L("Test1: Check which zone a movable page has been allocated to "));	
  2466 		test.Printf(_L("Passed...\n"));
  2479 		test.Printf(_L("Passed...\n"));
  2467 		}
  2480 		}
  2468 	
  2481 	
  2469 skipTest8:
  2482 skipTest8:
  2470 	TestEnd();
  2483 	TestEnd();
       
  2484 
       
  2485 	test.Next(_L("Test9: Allocate a large 1MB aligned chunk and touch all its pages"));
       
  2486 	TestStart();
       
  2487 	gChunkArray1 = new RChunk;
       
  2488 	gChunkArraySize1 = 1;
       
  2489 
       
  2490 	GetAllPageInfo();
       
  2491 	const TUint KChunkBytes = 0x100000;
       
  2492 	const TUint KChunkMask = KChunkBytes - 1;
       
  2493 	TUint freeBytes = gTotalPageCount.iFreePages << gPageShift;
       
  2494 	TUint chunkSize = freeBytes & ~KChunkMask;
       
  2495 	// Fill as much memory as possible with fixed pages while still allowing the movable allocation to succeed.
       
  2496 	// This should help force the page table allocation for the chunk to need to move pages.
       
  2497 	TUint fixedSize = freeBytes - chunkSize;
       
  2498 	r = KErrNoMemory;
       
  2499 	while (r != KErrNone && fixedSize)
       
  2500 		{
       
  2501 		Ldd.FreeAllFixedPages();
       
  2502 		fixedSize -= gPageSize;
       
  2503 		test.Printf(_L("fixedSize 0x%x\n"), fixedSize);
       
  2504 		r = Ldd.AllocateFixed(fixedSize >> gPageShift);
       
  2505 		if (r != KErrNone)
       
  2506 			break;
       
  2507 		r = AllocMovable(gChunkArray1, gChunkArraySize1, gChunkArraySize1, chunkSize);
       
  2508 		}
       
  2509 	if (r == KErrNone)
       
  2510 		{
       
  2511 		// Touch every page in the chunk.
       
  2512 		memclr(gChunkArray1->Base(), chunkSize);
       
  2513 		}
       
  2514 	TestEnd();	// This will free any chunk and fixed pages.
  2471 
  2515 
  2472 	test.End();
  2516 	test.End();
  2473 	return KErrNone;
  2517 	return KErrNone;
  2474 	}
  2518 	}
  2475 
  2519 
  3802 		{
  3846 		{
  3803 		test.Printf(_L("Passed...\n"));	
  3847 		test.Printf(_L("Passed...\n"));	
  3804 		}
  3848 		}
  3805 	Ldd.FreeAllFixedPages();
  3849 	Ldd.FreeAllFixedPages();
  3806 	TestEnd();
  3850 	TestEnd();
       
  3851 
       
  3852 	PrintPageInfo();
  3807 
  3853 
  3808 	test.Next(_L("Test7: Defrag memory filled with discardable pages when the min cache size is reached\n"));
  3854 	test.Next(_L("Test7: Defrag memory filled with discardable pages when the min cache size is reached\n"));
  3809 	TestStart();
  3855 	TestStart();
  3810 	if (gPagedRom)
  3856 	if (gPagedRom)
  3811 		{
  3857 		{