VirtualBox

Ignore:
Timestamp:
Feb 24, 2015 4:09:25 PM (10 years ago)
Author:
vboxsync
Message:

SUPDrvGip.cpp: Sync macro fix. Profiling in progress...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrvGip.cpp

    r54455 r54456  
    24002400static DECLCALLBACK(void) supdrvGipSyncAndInvariantTimer(PRTTIMER pTimer, void *pvUser, uint64_t iTick)
    24012401{
    2402     RTCCUINTREG        uFlags;
    2403     uint64_t           u64TSC;
    2404     uint64_t           u64NanoTS;
    2405     PSUPDRVDEVEXT      pDevExt = (PSUPDRVDEVEXT)pvUser;
    2406     PSUPGLOBALINFOPAGE pGip = pDevExt->pGip;
    2407 
    2408     uFlags    = ASMIntDisableFlags(); /* No interruptions please (real problem on S10). */
    2409     u64TSC    = ASMReadTSC();
    2410     u64NanoTS = RTTimeSystemNanoTS();
     2402    PSUPDRVDEVEXT      pDevExt   = (PSUPDRVDEVEXT)pvUser;
     2403    PSUPGLOBALINFOPAGE pGip      = pDevExt->pGip;
     2404    RTCCUINTREG        fOldFlags = ASMIntDisableFlags(); /* No interruptions please (real problem on S10). */
     2405    uint64_t           u64TSC    = ASMReadTSC();
     2406    uint64_t           u64NanoTS = RTTimeSystemNanoTS();
    24112407
    24122408    if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_PRACTICALLY_ZERO)
     
    24402436    supdrvGipUpdate(pDevExt, u64NanoTS, u64TSC, NIL_RTCPUID, iTick);
    24412437
    2442     ASMSetFlags(uFlags);
     2438    ASMSetFlags(fOldFlags);
    24432439}
    24442440
     
    24522448static DECLCALLBACK(void) supdrvGipAsyncTimer(PRTTIMER pTimer, void *pvUser, uint64_t iTick)
    24532449{
     2450    PSUPDRVDEVEXT   pDevExt   = (PSUPDRVDEVEXT)pvUser;
    24542451    RTCCUINTREG     fOldFlags = ASMIntDisableFlags(); /* No interruptions please (real problem on S10). */
    2455     PSUPDRVDEVEXT   pDevExt   = (PSUPDRVDEVEXT)pvUser;
    24562452    RTCPUID         idCpu     = RTMpCpuId();
    24572453    uint64_t        u64TSC    = ASMReadTSC();
     
    25142510{
    25152511    /** Padding to make sure the iCurSeqNo is in its own cache line. */
    2516     uint64_t                    au64CacheLinePaddingBefore[GIP_TSC_DELTA_CACHE_LINE_SIZE / sizeof(uint64_t) - 1];
     2512    uint64_t                    au64CacheLinePaddingBefore[GIP_TSC_DELTA_CACHE_LINE_SIZE / sizeof(uint64_t)];
    25172513    /** The current sequence number of this worker. */
    25182514    uint32_t volatile           iCurSeqNo;
     
    26122608    /** Padding to make sure the master variables live in its own cache lines. */
    26132609    uint64_t                    au64CacheLinePaddingBefore[GIP_TSC_DELTA_CACHE_LINE_SIZE / sizeof(uint64_t)];
     2610    /** The time the master spent in the MP worker.  */
     2611    uint64_t                    cElapsedMasterTscTicks;
    26142612    /** Pointer to the master's synchronization struct (on stack). */
    26152613    PSUPTSCDELTASYNC2 volatile  pSyncMaster;
     
    26332631    /** Pointer to the worker's synchronization struct (on stack). */
    26342632    PSUPTSCDELTASYNC2 volatile  pSyncWorker;
     2633    /** The time the worker spent in the MP worker.  */
     2634    uint64_t                    cElapsedWorkerTscTicks;
    26352635    /** Verification test TSC values for the worker. */
    26362636    uint64_t volatile           auVerifyWorkerTscs[32];
     
    28292829
    28302830#define TSCDELTA_MASTER_SYNC_BEFORE(a_pMySync, a_pOtherSync) \
    2831     do { \
     2831    if (true) { \
    28322832        if (RT_LIKELY(supdrvTscDeltaSync2_Before(a_pMySync, a_pOtherSync, true /*fMaster*/, &uFlags))) \
    28332833        { /*likely*/ } \
    28342834        else break; \
    2835     } while (0)
     2835    } else do {} while (0)
    28362836#define TSCDELTA_OTHER_SYNC_BEFORE(a_pMySync, a_pOtherSync) \
    2837     do { \
     2837    if (true) { \
    28382838        if (RT_LIKELY(supdrvTscDeltaSync2_Before(a_pMySync, a_pOtherSync, false /*fMaster*/, &uFlags))) \
    28392839        { /*likely*/ } \
    28402840        else break; \
    2841     } while (0)
     2841    } else do {} while (0)
    28422842
    28432843
     
    28682868
    28692869#define TSCDELTA_MASTER_SYNC_AFTER(a_pMySync, a_pOtherSync) \
    2870     do { \
    2871         if (supdrvTscDeltaSync2_After(a_pMySync, a_pOtherSync, uFlags)) \
     2870    if (true) { \
     2871        if (RT_LIKELY(supdrvTscDeltaSync2_After(a_pMySync, a_pOtherSync, uFlags))) \
    28722872        { /* likely */ } \
    28732873        else break; \
    2874     } while (0)
     2874    } else do {} while (0)
    28752875
    28762876#define TSCDELTA_MASTER_KICK_OTHER_OUT_OF_AFTER(a_pMySync, a_pOtherSync) \
    2877     do {\
     2877    if (true) { \
    28782878        /* \
    2879          * Tell the woker that we're done processing the data and ready for the next round. \
     2879         * Tell the worker that we're done processing the data and ready for the next round. \
    28802880         */ \
    2881         if (!ASMAtomicCmpXchgU32(&(a_pOtherSync)->uSyncVar, GIP_TSC_DELTA_SYNC2_READY, GIP_TSC_DELTA_SYNC2_GO)) \
     2881        if (RT_LIKELY(ASMAtomicCmpXchgU32(&(a_pOtherSync)->uSyncVar, GIP_TSC_DELTA_SYNC2_READY, GIP_TSC_DELTA_SYNC2_GO))) \
     2882        { /* likely */ } \
     2883        else break; \
     2884    } else do {} while (0)
     2885
     2886#define TSCDELTA_OTHER_SYNC_AFTER(a_pMySync, a_pOtherSync) \
     2887    if (true) { \
     2888        /* \
     2889         * Tell the master that we're done collecting data and wait for the next round to start. \
     2890         */ \
     2891        if (RT_LIKELY(ASMAtomicCmpXchgU32(&(a_pOtherSync)->uSyncVar, GIP_TSC_DELTA_SYNC2_READY, GIP_TSC_DELTA_SYNC2_GO))) \
     2892        { /* likely */ } \
     2893        else \
    28822894        { \
    28832895            ASMSetFlags(uFlags); \
    28842896            break; \
    28852897        } \
    2886     } while (0)
    2887 
    2888 #define TSCDELTA_OTHER_SYNC_AFTER(a_pMySync, a_pOtherSync) \
    2889     do { \
    2890         /* \
    2891          * Tell the master that we're done collecting data and wait for the next round to start. \
    2892          */ \
    2893         if (!ASMAtomicCmpXchgU32(&(a_pOtherSync)->uSyncVar, GIP_TSC_DELTA_SYNC2_READY, GIP_TSC_DELTA_SYNC2_GO)) \
    2894         { \
    2895             ASMSetFlags(uFlags); \
    2896             break; \
    2897         } \
    2898         if (supdrvTscDeltaSync2_After(a_pMySync, a_pOtherSync, uFlags)) \
     2898        if (RT_LIKELY(supdrvTscDeltaSync2_After(a_pMySync, a_pOtherSync, uFlags))) \
    28992899        { /* likely */ } \
    29002900        else break; \
    2901     } while (0)
     2901    }  else do {} while (0)
    29022902/** @} */
    29032903
     
    31193119    pArgs->M2.cHits     += cHits;
    31203120
     3121#if 1
    31213122    /*
    31223123     * Check and see if we can quit a little early.  If the result is already
     
    31473148        }
    31483149    }
     3150#endif
    31493151}
    31503152
     
    36233625     * This should normally be the case.
    36243626     */
     3627#if 1
    36253628    rc = supdrvTscDeltaVerify(pArgs, &MySync, pOtherSync, fIsMaster, GIP_TSC_DELTA_INITIAL_MASTER_VALUE);
     3629#else
     3630    rc = VERR_OUT_OF_RANGE;
     3631#endif
    36263632    if (RT_SUCCESS(rc))
    36273633    {
     
    36663672             * Success? If so, stop trying.
    36673673             */
     3674#if 1
    36683675            if (pGipCpuWorker->i64TSCDelta != INT64_MAX)
     3676#else
     3677            if (pGipCpuWorker->i64TSCDelta != INT64_MAX && iTry >= 11)
     3678#endif
    36693679            {
    36703680                if (fIsMaster)
     
    37013711    }
    37023712
     3713    /*
     3714     * Collect some runtime stats.
     3715     */
     3716    if (fIsMaster)
     3717        pArgs->cElapsedMasterTscTicks = ASMReadTSC() - MySync.uTscStart;
     3718    else
     3719        pArgs->cElapsedWorkerTscTicks = ASMReadTSC() - MySync.uTscStart;
    37033720    return 0;
    37043721}
     
    38483865                if (RT_SUCCESS(rc))
    38493866                {
     3867#if 0
     3868                    SUPR0Printf("mponpair ticks: %9llu %9llu  max: %9llu\n", pArgs->cElapsedMasterTscTicks,
     3869                                pArgs->cElapsedWorkerTscTicks, pArgs->cMaxTscTicks);
     3870#endif
    38503871#if 0
    38513872                    SUPR0Printf("rcVerify=%d iVerifyBadTscDiff=%lld cMinVerifyTscTicks=%lld cMaxVerifyTscTicks=%lld\n",
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette