- Timestamp:
- Jun 21, 2009 10:14:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vm.h
r20750 r20752 926 926 struct TM s; 927 927 #endif 928 char padding[2 048]; /* multiple of 32 */928 char padding[2112]; /* multiple of 32 */ 929 929 } tm; 930 930 -
trunk/src/VBox/VMM/TM.cpp
r20750 r20752 575 575 STAM_REG(pVM, &pVM->tm.s.StatScheduleSetFF, STAMTYPE_COUNTER, "/TM/ScheduleSetFF", STAMUNIT_OCCURENCES, "The number of times the timer FF was set instead of doing scheduling."); 576 576 577 STAM_REG(pVM, &pVM->tm.s.StatTimerSetR3, STAMTYPE_PROFILE, "/TM/TimerSetR3", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerSet calls made in ring-3."); 578 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRZ, STAMTYPE_PROFILE, "/TM/TimerSetRZ", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerSet calls made in ring-0 / RC."); 577 STAM_REG(pVM, &pVM->tm.s.StatTimerSet, STAMTYPE_COUNTER, "/TM/TimerSet", STAMUNIT_OCCURENCES, "Calls"); 578 STAM_REG(pVM, &pVM->tm.s.StatTimerSetOpt, STAMTYPE_COUNTER, "/TM/TimerSet/Opt", STAMUNIT_OCCURENCES, "Optimized path taken."); 579 STAM_REG(pVM, &pVM->tm.s.StatTimerSetR3, STAMTYPE_PROFILE, "/TM/TimerSet/R3", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerSet calls made in ring-3."); 580 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRZ, STAMTYPE_PROFILE, "/TM/TimerSet/RZ", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerSet calls made in ring-0 / RC."); 581 STAM_REG(pVM, &pVM->tm.s.StatTimerSetStActive, STAMTYPE_COUNTER, "/TM/TimerSet/StActive", STAMUNIT_OCCURENCES, "ACTIVE"); 582 STAM_REG(pVM, &pVM->tm.s.StatTimerSetStExpDeliver, STAMTYPE_COUNTER, "/TM/TimerSet/StExpDeliver", STAMUNIT_OCCURENCES, "EXPIRED_DELIVER"); 583 STAM_REG(pVM, &pVM->tm.s.StatTimerSetStOther, STAMTYPE_COUNTER, "/TM/TimerSet/StOther", STAMUNIT_OCCURENCES, "Other states"); 584 STAM_REG(pVM, &pVM->tm.s.StatTimerSetStPendStop, STAMTYPE_COUNTER, "/TM/TimerSet/StPendStop", STAMUNIT_OCCURENCES, "PENDING_STOP"); 585 STAM_REG(pVM, &pVM->tm.s.StatTimerSetStPendStopSched, STAMTYPE_COUNTER, "/TM/TimerSet/StPendStopSched", STAMUNIT_OCCURENCES, "PENDING_STOP_SCHEDULE"); 586 STAM_REG(pVM, &pVM->tm.s.StatTimerSetStPendSched, STAMTYPE_COUNTER, "/TM/TimerSet/StPendSched", STAMUNIT_OCCURENCES, "PENDING_SCHEDULE"); 587 STAM_REG(pVM, &pVM->tm.s.StatTimerSetStPendResched, STAMTYPE_COUNTER, "/TM/TimerSet/StPendResched", STAMUNIT_OCCURENCES, "PENDING_RESCHEDULE"); 588 STAM_REG(pVM, &pVM->tm.s.StatTimerSetStStopped, STAMTYPE_COUNTER, "/TM/TimerSet/StStopped", STAMUNIT_OCCURENCES, "STOPPED"); 579 589 580 590 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRelative, STAMTYPE_COUNTER, "/TM/TimerSetRelative", STAMUNIT_OCCURENCES, "Calls"); 591 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRelativeOpt, STAMTYPE_COUNTER, "/TM/TimerSetRelative/Opt", STAMUNIT_OCCURENCES, "Optimized path taken."); 581 592 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRelativeR3, STAMTYPE_PROFILE, "/TM/TimerSetRelative/R3", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerSetRelative calls made in ring-3."); 582 593 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRelativeRZ, STAMTYPE_PROFILE, "/TM/TimerSetRelative/RZ", STAMUNIT_TICKS_PER_CALL, "Profiling TMTimerSetReltaive calls made in ring-0 / RC."); 583 594 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRelativeRacyVirtSync, STAMTYPE_COUNTER, "/TM/TimerSetRelative/RacyVirtSync", STAMUNIT_OCCURENCES, "Potentially racy virtual sync timer update."); 584 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRelativeOpt, STAMTYPE_COUNTER, "/TM/TimerSetRelative/Opt", STAMUNIT_OCCURENCES, "Optimized path taken.");585 595 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRelativeStActive, STAMTYPE_COUNTER, "/TM/TimerSetRelative/StActive", STAMUNIT_OCCURENCES, "ACTIVE"); 586 596 STAM_REG(pVM, &pVM->tm.s.StatTimerSetRelativeStExpDeliver, STAMTYPE_COUNTER, "/TM/TimerSetRelative/StExpDeliver", STAMUNIT_OCCURENCES, "EXPIRED_DELIVER"); -
trunk/src/VBox/VMM/TMInternal.h
r20750 r20752 482 482 /** TMTimerSet 483 483 * @{ */ 484 STAMCOUNTER StatTimerSet; 485 STAMCOUNTER StatTimerSetOpt; 484 486 STAMPROFILE StatTimerSetRZ; 485 487 STAMPROFILE StatTimerSetR3; 488 STAMCOUNTER StatTimerSetStStopped; 489 STAMCOUNTER StatTimerSetStExpDeliver; 490 STAMCOUNTER StatTimerSetStActive; 491 STAMCOUNTER StatTimerSetStPendStop; 492 STAMCOUNTER StatTimerSetStPendStopSched; 493 STAMCOUNTER StatTimerSetStPendSched; 494 STAMCOUNTER StatTimerSetStPendResched; 495 STAMCOUNTER StatTimerSetStOther; 486 496 /** @} */ 487 497 /** TMTimerSetRelative -
trunk/src/VBox/VMM/VMMAll/TMAll.cpp
r20751 r20752 790 790 791 791 /** 792 * Optimized TMTimerSet code path for starting an inactive timer. 793 * 794 * @returns VBox status code. 795 * 796 * @param pVM The VM handle. 797 * @param pTimer The timer handle. 798 * @param u64Expire The new expire time. 799 */ 800 static int tmTimerSetOptimizedStart(PVM pVM, PTMTIMER pTimer, uint64_t u64Expire) 801 { 802 Assert(!pTimer->offPrev); 803 Assert(!pTimer->offNext); 804 Assert(pTimer->enmState == TMTIMERSTATE_ACTIVE); 805 806 /* 807 * Calculate and set the expiration time. 808 */ 809 pTimer->u64Expire = u64Expire; 810 Log2(("tmTimerSetOptimizedStart: %p:{.pszDesc='%s', .u64Expire=%'RU64}\n", pTimer, R3STRING(pTimer->pszDesc), u64Expire)); 811 812 /* 813 * Link the timer into the active list. 814 */ 815 TMCLOCK const enmClock = pTimer->enmClock; 816 tmTimerActiveLink(&pVM->tm.s.CTX_SUFF(paTimerQueues)[enmClock], pTimer, u64Expire); 817 818 STAM_COUNTER_INC(&pVM->tm.s.StatTimerSetOpt); 819 tmUnlock(pVM); 820 return VINF_SUCCESS; 821 } 822 823 824 825 826 827 /** 792 828 * Arm a timer with a (new) expire time. 793 829 * … … 798 834 VMMDECL(int) TMTimerSet(PTMTIMER pTimer, uint64_t u64Expire) 799 835 { 800 STAM_PROFILE_START(&pTimer->CTX_SUFF(pVM)->tm.s.CTX_SUFF_Z(StatTimerSet), a); 836 PVM pVM = pTimer->CTX_SUFF(pVM); 837 STAM_PROFILE_START(&pVM->tm.s.CTX_SUFF_Z(StatTimerSet), a); 801 838 TMTIMER_ASSERT_CRITSECT(pTimer); 802 839 803 /** @todo find the most frequently used paths and make them skip tmSchedule and tmTimerTryWithLink. */ 840 #ifdef VBOX_WITH_STATISTICS 841 /* Gather optimization info. */ 842 STAM_COUNTER_INC(&pVM->tm.s.StatTimerSet); 843 TMTIMERSTATE enmOrgState = pTimer->enmState; 844 switch (enmOrgState) 845 { 846 case TMTIMERSTATE_STOPPED: STAM_COUNTER_INC(&pVM->tm.s.StatTimerSetStStopped); break; 847 case TMTIMERSTATE_EXPIRED_DELIVER: STAM_COUNTER_INC(&pVM->tm.s.StatTimerSetStExpDeliver); break; 848 case TMTIMERSTATE_ACTIVE: STAM_COUNTER_INC(&pVM->tm.s.StatTimerSetStActive); break; 849 case TMTIMERSTATE_PENDING_STOP: STAM_COUNTER_INC(&pVM->tm.s.StatTimerSetStPendStop); break; 850 case TMTIMERSTATE_PENDING_STOP_SCHEDULE: STAM_COUNTER_INC(&pVM->tm.s.StatTimerSetStPendStopSched); break; 851 case TMTIMERSTATE_PENDING_SCHEDULE: STAM_COUNTER_INC(&pVM->tm.s.StatTimerSetStPendSched); break; 852 case TMTIMERSTATE_PENDING_RESCHEDULE: STAM_COUNTER_INC(&pVM->tm.s.StatTimerSetStPendResched); break; 853 default: STAM_COUNTER_INC(&pVM->tm.s.StatTimerSetStOther); break; 854 } 855 #endif 856 857 /* 858 * The most common case is setting the timer again during the callback. 859 * The second most common case is starting a timer at some other time. 860 */ 861 #if 1 862 TMTIMERSTATE enmState = pTimer->enmState; 863 if ( enmState == TMTIMERSTATE_EXPIRED_DELIVER 864 || ( enmState == TMTIMERSTATE_STOPPED 865 && pTimer->pCritSect)) 866 { 867 /* Try take the TM lock and check the state again. */ 868 if (RT_SUCCESS_NP(tmTryLock(pVM))) 869 { 870 if (RT_LIKELY(tmTimerTry(pTimer, TMTIMERSTATE_ACTIVE, enmState))) 871 { 872 tmTimerSetOptimizedStart(pVM, pTimer, u64Expire); 873 STAM_PROFILE_STOP(&pTimer->CTX_SUFF(pVM)->tm.s.CTX_SUFF_Z(StatTimerSetRelative), a); 874 return VINF_SUCCESS; 875 } 876 tmUnlock(pVM); 877 } 878 } 879 #endif 880 881 /* 882 * Unoptimized code path. 883 */ 804 884 int cRetries = 1000; 805 885 do … … 820 900 Assert(!pTimer->offNext); 821 901 AssertMsg( pTimer->enmClock != TMCLOCK_VIRTUAL_SYNC 822 || p Timer->CTX_SUFF(pVM)->tm.s.fVirtualSyncTicking823 || u64Expire >= p Timer->CTX_SUFF(pVM)->tm.s.u64VirtualSync,824 ("%'RU64 < %'RU64 %s\n", u64Expire, p Timer->CTX_SUFF(pVM)->tm.s.u64VirtualSync, R3STRING(pTimer->pszDesc)));902 || pVM->tm.s.fVirtualSyncTicking 903 || u64Expire >= pVM->tm.s.u64VirtualSync, 904 ("%'RU64 < %'RU64 %s\n", u64Expire, pVM->tm.s.u64VirtualSync, R3STRING(pTimer->pszDesc))); 825 905 pTimer->u64Expire = u64Expire; 826 906 TM_SET_STATE(pTimer, TMTIMERSTATE_PENDING_SCHEDULE); 827 907 tmSchedule(pTimer); 828 STAM_PROFILE_STOP(&p Timer->CTX_SUFF(pVM)->tm.s.CTX_SUFF_Z(StatTimerSet), a);908 STAM_PROFILE_STOP(&pVM->tm.s.CTX_SUFF_Z(StatTimerSet), a); 829 909 return VINF_SUCCESS; 830 910 } … … 838 918 TM_SET_STATE(pTimer, TMTIMERSTATE_PENDING_SCHEDULE); 839 919 tmSchedule(pTimer); 840 STAM_PROFILE_STOP(&p Timer->CTX_SUFF(pVM)->tm.s.CTX_SUFF_Z(StatTimerSet), a);920 STAM_PROFILE_STOP(&pVM->tm.s.CTX_SUFF_Z(StatTimerSet), a); 841 921 return VINF_SUCCESS; 842 922 } … … 850 930 TM_SET_STATE(pTimer, TMTIMERSTATE_PENDING_RESCHEDULE); 851 931 tmSchedule(pTimer); 852 STAM_PROFILE_STOP(&p Timer->CTX_SUFF(pVM)->tm.s.CTX_SUFF_Z(StatTimerSet), a);932 STAM_PROFILE_STOP(&pVM->tm.s.CTX_SUFF_Z(StatTimerSet), a); 853 933 return VINF_SUCCESS; 854 934 } … … 862 942 TM_SET_STATE(pTimer, TMTIMERSTATE_PENDING_RESCHEDULE); 863 943 tmSchedule(pTimer); 864 STAM_PROFILE_STOP(&p Timer->CTX_SUFF(pVM)->tm.s.CTX_SUFF_Z(StatTimerSet), a);944 STAM_PROFILE_STOP(&pVM->tm.s.CTX_SUFF_Z(StatTimerSet), a); 865 945 return VINF_SUCCESS; 866 946 } … … 893 973 894 974 AssertMsgFailed(("Failed waiting for stable state. state=%d (%s)\n", pTimer->enmState, R3STRING(pTimer->pszDesc))); 895 STAM_PROFILE_STOP(&p Timer->CTX_SUFF(pVM)->tm.s.CTX_SUFF_Z(StatTimerSet), a);975 STAM_PROFILE_STOP(&pVM->tm.s.CTX_SUFF_Z(StatTimerSet), a); 896 976 return VERR_INTERNAL_ERROR; 897 977 } … … 1012 1092 * get the innermost locks. 1013 1093 */ 1014 bool fOwnTMLock = RT_SUCCESS (tmTryLock(pVM));1094 bool fOwnTMLock = RT_SUCCESS_NP(tmTryLock(pVM)); 1015 1095 #if 1 1016 1096 if ( fOwnTMLock … … 1168 1248 if (!fOwnTMLock) 1169 1249 { 1170 fOwnTMLock = RT_SUCCESS (tmTryLock(pVM));1250 fOwnTMLock = RT_SUCCESS_NP(tmTryLock(pVM)); 1171 1251 if ( !fOwnTMLock 1172 1252 && enmClock == TMCLOCK_VIRTUAL_SYNC 1173 1253 && !fOwnVirtSyncLock) 1174 fOwnVirtSyncLock = RT_SUCCESS (tmVirtualSyncTryLock(pVM));1254 fOwnVirtSyncLock = RT_SUCCESS_NP(tmVirtualSyncTryLock(pVM)); 1175 1255 } 1176 1256
Note:
See TracChangeset
for help on using the changeset viewer.