VirtualBox

Changeset 24021 in vbox


Ignore:
Timestamp:
Oct 23, 2009 11:29:18 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53864
Message:

Use KeSetSystemAffinityThread in RTThreadPreemptDisable/Enable.
Removed IPI hacks as queuing a DPC when the target CPU is not running at DISPATCH_LEVEL immediately interrupts it.

Location:
trunk/src/VBox/Runtime/r0drv/nt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp

    r23546 r24021  
    5454
    5555/** ExSetTimerResolution, introduced in W2K. */
    56 PFNMYEXSETTIMERRESOLUTION   g_pfnrtNtExSetTimerResolution;
     56PFNMYEXSETTIMERRESOLUTION       g_pfnrtNtExSetTimerResolution;
    5757/** KeFlushQueuedDpcs, introduced in XP. */
    58 PFNMYKEFLUSHQUEUEDDPCS      g_pfnrtNtKeFlushQueuedDpcs;
    59 /** HalRequestIpi, introduced in ??. */
    60 PFNHALREQUESTIPI            g_pfnrtNtHalRequestIpi;
    61 /** HalSendSoftwareInterrupt */
    62 PFNHALSENDSOFTWAREINTERRUPT g_pfnrtNtHalSendSoftwareInterrupt;
    63 /** SendIpi handler based on Windows version */
    64 PFNRTSENDIPI                g_pfnrtSendIpi;
    65 /** KeIpiGenericCall - Windows Server 2003+ only */
    66 PFNRTKEIPIGENERICCALL       g_pfnrtKeIpiGenericCall;
     58PFNMYKEFLUSHQUEUEDDPCS          g_pfnrtNtKeFlushQueuedDpcs;
     59/** KeSetSystemAffinityThread - Windows 2000+ */
     60PFNRTKESETSYSTEMAFFINITYTHREAD  g_pfnrtKeSetSystemAffinityThread;
     61
    6762
    6863/** Offset of the _KPRCB::QuantumEnd field. 0 if not found. */
     
    9186    g_pfnrtNtExSetTimerResolution = NULL;
    9287    g_pfnrtNtKeFlushQueuedDpcs = NULL;
    93     g_pfnrtNtHalRequestIpi = NULL;
    94     g_pfnrtNtHalSendSoftwareInterrupt = NULL;
    95     g_pfnrtKeIpiGenericCall = NULL;
     88        g_pfnrtKeSetSystemAffinityThread = NULL;
    9689#else
    9790    /*
     
    10598    g_pfnrtNtKeFlushQueuedDpcs = (PFNMYKEFLUSHQUEUEDDPCS)MmGetSystemRoutineAddress(&RoutineName);
    10699
    107     RtlInitUnicodeString(&RoutineName, L"HalRequestIpi");
    108     g_pfnrtNtHalRequestIpi = (PFNHALREQUESTIPI)MmGetSystemRoutineAddress(&RoutineName);
    109 
    110     RtlInitUnicodeString(&RoutineName, L"HalSendSoftwareInterrupt");
    111     g_pfnrtNtHalSendSoftwareInterrupt = (PFNHALSENDSOFTWAREINTERRUPT)MmGetSystemRoutineAddress(&RoutineName);
    112 
    113     RtlInitUnicodeString(&RoutineName, L"KeIpiGenericCall");
    114     g_pfnrtKeIpiGenericCall = (PFNRTKEIPIGENERICCALL)MmGetSystemRoutineAddress(&RoutineName);
     100    RtlInitUnicodeString(&RoutineName, L"KeSetSystemAffinityThread");
     101    g_pfnrtKeSetSystemAffinityThread = (PFNRTKESETSYSTEMAFFINITYTHREAD)MmGetSystemRoutineAddress(&RoutineName);
    115102#endif
    116103
     
    123110    BOOLEAN fChecked = PsGetVersion(&MajorVersion, &MinorVersion, &BuildNumber, NULL);
    124111
    125     g_pfnrtSendIpi = rtMpSendIpiDummy;
    126 #ifndef IPRT_TARGET_NT4
    127     if (    g_pfnrtNtHalRequestIpi
    128         &&  MajorVersion == 6
    129         &&  MinorVersion == 0)
    130     {
    131         /* Vista or Windows Server 2008 */
    132         g_pfnrtSendIpi = rtMpSendIpiVista;
    133     }
    134     else
    135     if (    g_pfnrtNtHalSendSoftwareInterrupt
    136         &&  MajorVersion == 6
    137         &&  MinorVersion == 1)
    138     {
    139         /* Windows 7 or Windows Server 2008 R2 */
    140         g_pfnrtSendIpi = rtMpSendIpiWin7;
    141     }
    142     /* Windows XP should send always send an IPI -> VERIFY */
    143 #endif
    144112    KIRQL OldIrql;
    145113    KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); /* make sure we stay on the same cpu */
  • TabularUnified trunk/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h

    r23546 r24021  
    4141typedef ULONG (__stdcall *PFNMYEXSETTIMERRESOLUTION)(ULONG, BOOLEAN);
    4242typedef VOID (__stdcall *PFNMYKEFLUSHQUEUEDDPCS)(VOID);
    43 typedef VOID (__stdcall *PFNHALREQUESTIPI)(KAFFINITY TargetSet);
    44 typedef VOID (__stdcall *PFNHALSENDSOFTWAREINTERRUPT)(ULONG ProcessorNumber, KIRQL Irql);
    45 typedef int (__stdcall *PFNRTSENDIPI)(RTCPUID idCpu);
    46 typedef ULONG_PTR (__stdcall *PFNRTKEIPIGENERICCALL)(PKIPI_BROADCAST_WORKER BroadcastFunction, ULONG_PTR  Context);
     43typedef VOID (__stdcall *PFNRTKESETSYSTEMAFFINITYTHREAD)(KAFFINITY);
    4744
    4845/*******************************************************************************
     
    5249extern PFNMYEXSETTIMERRESOLUTION    g_pfnrtNtExSetTimerResolution;
    5350extern PFNMYKEFLUSHQUEUEDDPCS       g_pfnrtNtKeFlushQueuedDpcs;
    54 extern PFNHALREQUESTIPI             g_pfnrtNtHalRequestIpi;
    55 extern PFNHALSENDSOFTWAREINTERRUPT  g_pfnrtNtHalSendSoftwareInterrupt;
    56 extern PFNRTSENDIPI                 g_pfnrtSendIpi;
    57 extern PFNRTKEIPIGENERICCALL        g_pfnrtKeIpiGenericCall;
     51extern PFNRTKESETSYSTEMAFFINITYTHREAD g_pfnrtKeSetSystemAffinityThread;
    5852extern uint32_t                     g_offrtNtPbQuantumEnd;
    5953extern uint32_t                     g_cbrtNtPbQuantumEnd;
    6054extern uint32_t                     g_offrtNtPbDpcQueueDepth;
    61 
    62 
    63 int rtMpSendIpiVista(RTCPUID idCpu);
    64 int rtMpSendIpiWin7(RTCPUID idCpu);
    65 int rtMpSendIpiDummy(RTCPUID idCpu);
    6655
    6756RT_C_DECLS_END
  • TabularUnified trunk/src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp

    r24014 r24021  
    347347}
    348348
    349 #ifndef IPRT_TARGET_NT4
    350 
    351 ULONG_PTR rtMpIpiGenericCall(ULONG_PTR  Argument)
    352 {
    353     return 0;
    354 }
    355 
    356 int rtMpSendIpiVista(RTCPUID idCpu)
    357 {
    358     g_pfnrtKeIpiGenericCall(rtMpIpiGenericCall, 0);
    359 ////    g_pfnrtNtHalRequestIpi(1 << idCpu);
    360     return VINF_SUCCESS;
    361 }
    362 
    363 int rtMpSendIpiWin7(RTCPUID idCpu)
    364 {
    365     g_pfnrtKeIpiGenericCall(rtMpIpiGenericCall, 0);
    366 ////    g_pfnrtNtHalSendSoftwareInterrupt(idCpu, DISPATCH_LEVEL);
    367     return VINF_SUCCESS;
    368 }
    369 #endif /* IPRT_TARGET_NT4 */
    370 
    371 int rtMpSendIpiDummy(RTCPUID idCpu)
    372 {
    373     return VERR_NOT_IMPLEMENTED;
    374 }
    375 
    376349RTDECL(int) RTMpPokeCpu(RTCPUID idCpu)
    377350{
     
    380353              ? VERR_CPU_NOT_FOUND
    381354              : VERR_CPU_OFFLINE;
    382 
    383     int rc = g_pfnrtSendIpi(idCpu);
    384     if (rc == VINF_SUCCESS)
    385         return rc;
    386355
    387356    /* Fallback. */
     
    407376
    408377    /* Assuming here that high importance DPCs will be delivered immediately; or at least an IPI will be sent immediately.
    409      * @note: not true on at least Vista & Windows 7
     378     * @note: seems to be true on Vista
    410379     */
    411380    BOOLEAN bRet = KeInsertQueueDpc(&aPokeDpcs[idCpu], 0, 0);
  • TabularUnified trunk/src/VBox/Runtime/r0drv/nt/thread-r0drv-nt.cpp

    r24014 r24021  
    170170    Assert(KeGetCurrentIrql() <= DISPATCH_LEVEL);
    171171
     172#ifndef IPRT_TARGET_NT4
     173    Assert(g_pfnrtKeSetSystemAffinityThread);
     174    g_pfnrtKeSetSystemAffinityThread((KAFFINITY)1 << KeGetCurrentProcessorNumber());
     175#else
    172176    KeRaiseIrql(DISPATCH_LEVEL, &pState->uchOldIrql);
     177#endif
    173178    RT_ASSERT_PREEMPT_CPUID_DISABLE(pState);
    174179}
     
    180185
    181186    RT_ASSERT_PREEMPT_CPUID_RESTORE(pState);
     187#ifndef IPRT_TARGET_NT4
     188    Assert(g_pfnrtKeSetSystemAffinityThread);
     189    g_pfnrtKeSetSystemAffinityThread(KeQueryActiveProcessors());
     190#else
    182191    KeLowerIrql(pState->uchOldIrql);
     192#endif
    183193    pState->uchOldIrql = 255;
    184194}
Note: See TracChangeset for help on using the changeset viewer.

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