VirtualBox

Changeset 87647 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Feb 8, 2021 10:18:17 PM (4 years ago)
Author:
vboxsync
Message:

IPRT/time: Added RTTimeNanoTSWorkerName for introspection. Maded the worker selection code easier to read.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/time/timesup.cpp

    r87626 r87647  
    204204# else
    205205            if (pGip->u32Mode == SUPGIPMODE_ASYNC_TSC)
    206                 pfnWorker = pGip->fGetGipCpu & SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS
    207                           ? RTTimeNanoTSLFenceAsyncUseIdtrLim
    208                           : pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS
    209                           ? RTTimeNanoTSLFenceAsyncUseRdtscp
    210                           : pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL
    211                           ? RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl
    212                           : pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID_EXT_0B
    213                           ? RTTimeNanoTSLFenceAsyncUseApicIdExt0B
    214                           : pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID_EXT_8000001E
    215                           ? RTTimeNanoTSLFenceAsyncUseApicIdExt8000001E
    216                           : pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID
    217                           ? RTTimeNanoTSLFenceAsyncUseApicId
    218                           : rtTimeNanoTSInternalFallback;
    219            else
    220                pfnWorker = pGip->fGetGipCpu & SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS
    221                          ? pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_PRACTICALLY_ZERO
    222                            ? RTTimeNanoTSLFenceSyncInvarNoDelta
    223                            : RTTimeNanoTSLFenceSyncInvarWithDeltaUseIdtrLim
    224                          : pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS
    225                          ?   pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_PRACTICALLY_ZERO
    226                            ? RTTimeNanoTSLFenceSyncInvarNoDelta
    227                            : RTTimeNanoTSLFenceSyncInvarWithDeltaUseRdtscp
    228                          : pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID_EXT_0B
    229                          ? pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ROUGHLY_ZERO
    230                            ? RTTimeNanoTSLFenceSyncInvarNoDelta
    231                            : RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicIdExt0B
    232                          : pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID_EXT_8000001E
    233                          ? pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ROUGHLY_ZERO
    234                            ? RTTimeNanoTSLFenceSyncInvarNoDelta
    235                            : RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicIdExt8000001E
    236                          : pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID
    237                          ? pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ROUGHLY_ZERO
    238                            ? RTTimeNanoTSLFenceSyncInvarNoDelta
    239                            : RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicId
    240                          : rtTimeNanoTSInternalFallback;
     206            {
     207                if (     pGip->fGetGipCpu & SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS)
     208                    pfnWorker = RTTimeNanoTSLFenceAsyncUseIdtrLim;
     209                else if (pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS)
     210                    pfnWorker = RTTimeNanoTSLFenceAsyncUseRdtscp;
     211                else if (pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL)
     212                    pfnWorker = RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl;
     213                else if (pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID_EXT_0B)
     214                    pfnWorker = RTTimeNanoTSLFenceAsyncUseApicIdExt0B;
     215                else if (pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID_EXT_8000001E)
     216                    pfnWorker = RTTimeNanoTSLFenceAsyncUseApicIdExt8000001E;
     217                else if (pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID)
     218                    pfnWorker = RTTimeNanoTSLFenceAsyncUseApicId;
     219                else
     220                    pfnWorker = rtTimeNanoTSInternalFallback;
     221            }
     222            else
     223            {
     224                if (pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_PRACTICALLY_ZERO)
     225                    pfnWorker = RTTimeNanoTSLFenceSyncInvarNoDelta;
     226                else if (pGip->fGetGipCpu & SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS)
     227                    pfnWorker = RTTimeNanoTSLFenceSyncInvarWithDeltaUseIdtrLim;
     228                else if (pGip->fGetGipCpu & SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS)
     229                    pfnWorker = RTTimeNanoTSLFenceSyncInvarWithDeltaUseRdtscp;
     230                else if (pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID_EXT_0B)
     231                    pfnWorker = RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicIdExt0B;
     232                else if (pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID_EXT_8000001E)
     233                    pfnWorker = RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicIdExt8000001E;
     234                else if (pGip->fGetGipCpu & SUPGIPGETCPU_APIC_ID)
     235                    pfnWorker = RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicId;
     236                else
     237                    pfnWorker = rtTimeNanoTSInternalFallback;
     238            }
    241239# endif
    242240        }
     
    247245                    ? RTTIMENANO_WORKER_LEGACY_ASYNC
    248246                    : pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ROUGHLY_ZERO
    249                     ? RTTIMENANO_WORKER_LEGACY_SYNC_INVAR_NO_DELTA :  RTTIMENANO_WORKER_LEGACY_SYNC_INVAR_WITH_DELTA;
     247                    ? RTTIMENANO_WORKER_LEGACY_SYNC_INVAR_NO_DELTA : RTTIMENANO_WORKER_LEGACY_SYNC_INVAR_WITH_DELTA;
    250248# elif defined(IN_RING0)
    251249            pfnWorker = pGip->u32Mode == SUPGIPMODE_ASYNC_TSC
     
    310308}
    311309
     310# if defined(IN_RING3) || defined(IN_RING0)
     311RTDECL(const char *) RTTimeNanoTSWorkerName(void)
     312{
     313    static const struct { PFNTIMENANOTSINTERNAL pfnWorker; const char *pszName; } s_aWorkersAndNames[] =
     314    {
     315#  define ENTRY(a_fn) { a_fn, #a_fn }
     316        ENTRY(RTTimeNanoTSLegacySyncInvarNoDelta),
     317        ENTRY(RTTimeNanoTSLFenceSyncInvarNoDelta),
     318#  ifdef IN_RING3
     319        ENTRY(RTTimeNanoTSLegacyAsyncUseApicId),
     320        ENTRY(RTTimeNanoTSLegacyAsyncUseApicIdExt0B),
     321        ENTRY(RTTimeNanoTSLegacyAsyncUseApicIdExt8000001E),
     322        ENTRY(RTTimeNanoTSLegacyAsyncUseRdtscp),
     323        ENTRY(RTTimeNanoTSLegacyAsyncUseRdtscpGroupChNumCl),
     324        ENTRY(RTTimeNanoTSLegacyAsyncUseIdtrLim),
     325        ENTRY(RTTimeNanoTSLegacySyncInvarWithDeltaUseApicId),
     326        ENTRY(RTTimeNanoTSLegacySyncInvarWithDeltaUseApicIdExt0B),
     327        ENTRY(RTTimeNanoTSLegacySyncInvarWithDeltaUseApicIdExt8000001E),
     328        ENTRY(RTTimeNanoTSLegacySyncInvarWithDeltaUseRdtscp),
     329        ENTRY(RTTimeNanoTSLegacySyncInvarWithDeltaUseIdtrLim),
     330        ENTRY(RTTimeNanoTSLFenceAsyncUseApicId),
     331        ENTRY(RTTimeNanoTSLFenceAsyncUseApicIdExt0B),
     332        ENTRY(RTTimeNanoTSLFenceAsyncUseApicIdExt8000001E),
     333        ENTRY(RTTimeNanoTSLFenceAsyncUseRdtscp),
     334        ENTRY(RTTimeNanoTSLFenceAsyncUseRdtscpGroupChNumCl),
     335        ENTRY(RTTimeNanoTSLFenceAsyncUseIdtrLim),
     336        ENTRY(RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicId),
     337        ENTRY(RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicIdExt0B),
     338        ENTRY(RTTimeNanoTSLFenceSyncInvarWithDeltaUseApicIdExt8000001E),
     339        ENTRY(RTTimeNanoTSLFenceSyncInvarWithDeltaUseRdtscp),
     340        ENTRY(RTTimeNanoTSLFenceSyncInvarWithDeltaUseIdtrLim),
     341#  else
     342        ENTRY(RTTimeNanoTSLegacyAsync),
     343        ENTRY(RTTimeNanoTSLegacySyncInvarWithDelta),
     344        ENTRY(RTTimeNanoTSLFenceAsync),
     345        ENTRY(RTTimeNanoTSLFenceSyncInvarWithDelta),
     346#  endif
     347        ENTRY(rtTimeNanoTSInternalFallback),
     348#  undef ENTRY
     349    };
     350    PFNTIMENANOTSINTERNAL pfnWorker = g_pfnWorker;
     351    if (pfnWorker == rtTimeNanoTSInternalRediscover)
     352    {
     353        RTTimeNanoTS();
     354        pfnWorker = g_pfnWorker;
     355    }
     356
     357    for (unsigned i = 0; i < RT_ELEMENTS(s_aWorkersAndNames); i++)
     358        if (s_aWorkersAndNames[i].pfnWorker == pfnWorker)
     359            return s_aWorkersAndNames[i].pszName;
     360    AssertFailed();
     361    return NULL;
     362}
     363# endif /* IN_RING3 || IN_RING0 */
     364
    312365#endif /* !IN_GUEST && !RT_NO_GIP */
    313366
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