Changeset 5064 in vbox
- Timestamp:
- Sep 26, 2007 6:37:49 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/gvm.h
r5031 r5064 64 64 struct GMMPERVM s; 65 65 #endif 66 uint8_t padding[ 64];66 uint8_t padding[256]; 67 67 } gmm; 68 68 -
trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
r5035 r5064 603 603 * Initializes the per-VM data for the GMM. 604 604 * 605 * This is called from within the GVMM lock (from GVMMR0CreateVM) 606 * and should only initialize the data members so GMMR0CleanupVM 607 * can deal with them. We reserve no memory or anything here, 608 * that's done later in GMMR0InitVM. 609 * 605 610 * @param pGVM Pointer to the Global VM structure. 606 611 */ 607 612 GMMR0DECL(void) GMMR0InitPerVMData(PGVM pGVM) 608 613 { 609 pGVM->gmm.s.cRAMPages = 0; 610 pGVM->gmm.s.cPrivatePages = 0; 611 pGVM->gmm.s.cSharedPages = 0; 612 pGVM->gmm.s.enmPolicy = GMMOCPOLICY_TBD; 613 pGVM->gmm.s.enmPriority = GMMPRIORITY_NORMAL; 614 AssertCompile(RT_SIZEOFMEMB(GVM,gmm.s) <= RT_SIZEOFMEMB(GVM,gmm.padding)); 615 AssertRelease(RT_SIZEOFMEMB(GVM,gmm.s) <= RT_SIZEOFMEMB(GVM,gmm.padding)); 616 617 //pGVM->gmm.s.cBasePages = 0; 618 //pGVM->gmm.s.cPrivatePages = 0; 619 //pGVM->gmm.s.cSharedPages = 0; 620 pGVM->gmm.s.enmPolicy = GMMOCPOLICY_INVALID; 621 pGVM->gmm.s.enmPriority = GMMPRIORITY_INVALID; 622 pGVM->gmm.s.fMayAllocate = false; 614 623 } 615 624 … … 623 632 { 624 633 LogFlow(("GMMR0CleanupVM: pGVM=%p:{.pVM=%p, .hSelf=%#x}\n", pGVM, pGVM->pVM, pGVM->hSelf)); 634 635 /* 636 * The policy is 'INVALID' until the initial reservation 637 * request has been serviced. 638 */ 639 if ( pGVM->gmm.s.enmPolicy <= GMMOCPOLICY_INVALID 640 || pGVM->gmm.s.enmPolicy >= GMMOCPOLICY_END) 641 { 642 } 643 625 644 626 645 PGMM pGMM; 627 646 GMM_GET_VALID_INSTANCE_VOID(pGMM); 628 647 629 int rc = 648 int rc = RTSemFastMutexRequest(pGMM->Mtx); 630 649 AssertRC(rc); 631 650 632 651 /* 633 * If it's the last VM around, we can skip walking all the chunk looking 652 * If it's the last VM around, we can skip walking all the chunk looking 634 653 * for the pages owned by this VM and instead flush the whole shebang. 635 654 * … … 637 656 * references behind (shouldn't happen of course, but you never know). 638 657 */ 639 if (pGMM->cActiveVMs == 1) 640 { 641 658 pGMM->cActiveVMs--; 659 if (!pGMM->cActiveVMs) 660 { 661 662 642 663 } 643 else if ( pGVM->gmm.s.cPrivatePages)664 else if (0)//pGVM->gmm.s.cPrivatePages) 644 665 { 645 666 /* … … 654 675 * longer needed. 655 676 */ 656 677 657 678 } 658 679 … … 660 681 661 682 /* trash the data */ 662 pGVM->gmm.s.cRAMPages = 0;663 pGVM->gmm.s.cPrivatePages = 0;664 pGVM->gmm.s.cSharedPages = 0;683 // pGVM->gmm.s.cBasePages = 0; 684 // pGVM->gmm.s.cPrivatePages = 0; 685 // pGVM->gmm.s.cSharedPages = 0; 665 686 pGVM->gmm.s.enmPolicy = GMMOCPOLICY_INVALID; 666 687 pGVM->gmm.s.enmPriority = GMMPRIORITY_INVALID; … … 717 738 cShared++; 718 739 719 /* 740 /* 720 741 * Did it add up? 721 742 */ … … 724 745 || pChunk->cShared != cShared)) 725 746 { 726 SUPR0Printf("GMM: Chunk %p/%#x has bogus stats - free=%d/%d private=%d/%d shared=%d/%d\n", 747 SUPR0Printf("GMM: Chunk %p/%#x has bogus stats - free=%d/%d private=%d/%d shared=%d/%d\n", 727 748 pChunk->cFree, cFree, pChunk->cPrivate, cPrivate, pChunk->cShared, cShared); 728 749 pChunk->cFree = cFree; … … 736 757 737 758 738 759 /** 760 * The initial resource reservations. 761 * 762 * This will make memory reservations according to policy and priority. If there isn't 763 * sufficient resources available to sustain the VM this function will fail and all 764 * future allocations requests will fail as well. 765 * 766 * @returns VBox status code. 767 * @retval VERR_GMM_NOT_SUFFICENT_MEMORY 768 * @retval VERR_GMM_ 769 * 770 * @param pVM Pointer to the shared VM structure. 771 * @param cBasePages The number of pages of RAM. This is *only* the RAM, it does 772 * not take additional pages for the ROMs and MMIO2 into account. 773 * These allocations will have to be reported when the initialization 774 * process has completed. 775 * @param cShadowPages The max number of pages that will be allocated for shadow pageing structures. 776 * @param enmPolicy The OC policy to use on this VM. 777 * @param enmPriority The priority in an out-of-memory situation. 778 */ 779 GMMR0DECL(int) GMMR0InitialReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, GMMOCPOLICY enmPolicy, GMMPRIORITY enmPriority) 780 { 781 LogFlow(("GMMR0InitialReservation: pVM=%p cBasePages=%#llx cShadowPages=%#x enmPolicy=%d enmPriority=%d\n", 782 pVM, cBasePages, cShadowPages, enmPolicy, enmPriority)); 783 784 /* 785 * Validate, get basics and take the semaphore. 786 */ 787 PGMM pGMM; 788 GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR); 789 PGVM pGVM = GVMMR0ByVM(pVM); 790 if (!pVM) 791 return VERR_INVALID_PARAMETER; 792 793 int rc = RTSemFastMutexRequest(pGMM->Mtx); 794 AssertRC(rc); 795 796 797 pGMM->cActiveVMs++; 798 799 800 801 RTSemFastMutexRelease(pGMM->Mtx); 802 LogFlow(("GMMR0InitialReservation: returns %Rrc\n", rc)); 803 return rc; 804 } 805 806 807 /** 808 * This updates the memory reservation with the additional MMIO2 and ROM pages. 809 * 810 * @returns VBox status code. 811 * @retval VERR_GMM_NOT_SUFFICENT_MEMORY 812 * 813 * @param pVM Pointer to the shared VM structure. 814 * @param cExtraPages The number of pages that makes up ROM ranges outside the normal 815 * RAM and MMIO2 memory. 816 * @param cMisc Miscellaneous fixed commitments like the heap, VM structure and such. 817 */ 818 GMMR0DECL(int) GMMR0ReservationUpdate(PVM pVM, uint64_t cExtraPages) 819 { 820 LogFlow(("GMMR0ReservationUpdate: pVM=%p cExtraPages=%#llx\n", pVM, cExtraPages)); 821 822 /* 823 * Validate, get basics and take the semaphore. 824 */ 825 PGMM pGMM; 826 GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR); 827 PGVM pGVM = GVMMR0ByVM(pVM); 828 if (!pVM) 829 return VERR_INVALID_PARAMETER; 830 831 int rc = RTSemFastMutexRequest(pGMM->Mtx); 832 AssertRC(rc); 833 834 835 836 RTSemFastMutexRelease(pGMM->Mtx); 837 LogFlow(("GMMR0ReservationUpdate: returns %Rrc\n", rc)); 838 return rc; 839 } 840 841 842 -
trunk/src/VBox/VMM/VMMR0/GMMR0Internal.h
r5033 r5064 22 22 #include <VBox/gmm.h> 23 23 24 /** 25 * The allocation sizes. 26 */ 27 typedef struct GMMVMSIZES 28 { 29 /** The number of pages of base memory. 30 * This is the sum of RAM, ROMs and handy pages. */ 31 uint64_t cBasePages; 32 /** The number of pages for the shadow pool. (Can be sequeezed for memory.) */ 33 uint32_t cShadowPages; 34 /** The number of pages for fixed allocations like MMIO2 and the hyper heap. */ 35 uint32_t cFixedPages; 36 } GMMVMSIZES; 37 typedef GMMVMSIZES *PGMMVMSIZES; 38 24 39 25 40 /** … … 28 43 typedef struct GMMPERVM 29 44 { 30 /** The ram size, in pages. */ 31 uint64_t cRAMPages; 32 /** The number of private pages. */ 45 /** The reservations. */ 46 GMMVMSIZES Reserved; 47 /** The actual allocations. */ 48 GMMVMSIZES Allocated; 49 /** The current number of private pages. */ 33 50 uint64_t cPrivatePages; 34 /** The number of shared pages. */51 /** The current number of shared pages. */ 35 52 uint64_t cSharedPages; 53 /** The current number of ballooned pages. */ 54 uint64_t cBalloonedPages; 55 /** The max number of pages that can be ballooned. */ 56 uint64_t cMaxBalloonedPages; 36 57 /** The current over-comitment policy. */ 37 58 GMMOCPOLICY enmPolicy; 38 59 /** The VM priority for arbitrating VMs in an out-of-memory situation. */ 39 60 GMMPRIORITY enmPriority; 61 /** Whether the VM is allowed to allocate memory or not. 62 * This is used when the reservation update request fails or when the VM has 63 * been told to suspend/save/die in an out-of-memory case. */ 64 bool fMayAllocate; 40 65 } GMMPERVM; 41 66 /** Pointer to the per-VM GMM data. */
Note:
See TracChangeset
for help on using the changeset viewer.