VirtualBox

Changeset 3627 in kBuild for trunk


Ignore:
Timestamp:
Oct 22, 2024 11:33:19 PM (6 months ago)
Author:
bird
Message:

kmk/winchildren.c: Skip the g_pfnSetThreadGroupAffinity stuff on windows 11 and later, just reset the g_pfnSetProcessDefaultCpuSetMasks and g_pfnSetThreadSelectedCpuSetMasks upon startup so the system is free to schedule things in whichever groups it thinks makes sense.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/w32/winchildren.c

    r3617 r3627  
    357357/** Kernel32!SetThreadGroupAffinity */
    358358static BOOL (WINAPI        *g_pfnSetThreadGroupAffinity)(HANDLE, CONST GROUP_AFFINITY *, GROUP_AFFINITY *);
     359/** Kernel32!SetThreadSelectedCpuSetMasks (windows 11+).   */
     360static BOOL (WINAPI        *g_pfnSetThreadSelectedCpuSetMasks)(HANDLE, PGROUP_AFFINITY, USHORT);
     361/** Kernel32!SetProcessDefaultCpuSetMasks (windows 11+).   */
     362static BOOL (WINAPI        *g_pfnSetProcessDefaultCpuSetMasks)(HANDLE, PGROUP_AFFINITY, USHORT);
    359363/** NTDLL!NtQueryInformationProcess */
    360364static NTSTATUS (NTAPI     *g_pfnNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
     365
    361366/** Set if the windows host is 64-bit. */
    362367static BOOL                 g_f64BitHost = (K_ARCH_BITS == 64);
     
    470475        *(FARPROC *)&g_pfnSetThreadGroupAffinity           = GetProcAddress(hmod, "SetThreadGroupAffinity");
    471476        *(FARPROC *)&g_pfnGetLogicalProcessorInformationEx = GetProcAddress(hmod, "GetLogicalProcessorInformationEx");
    472         /*(FARPROC *)&g_pfnGetSystemCpuSetInformation       = GetProcAddress(hmod, "GetSystemCpuSetInformation"); / * W10 */
    473         /*(FARPROC *)&g_pfnSetThreadSelectedCpuSetMasks     = GetProcAddress(hmod, "SetThreadSelectedCpuSetMasks"); / * W11 */
     477        *(FARPROC *)&g_pfnSetThreadSelectedCpuSetMasks      = GetProcAddress(hmod, "SetThreadSelectedCpuSetMasks"); /* W11 */
     478        *(FARPROC *)&g_pfnSetProcessDefaultCpuSetMasks      = GetProcAddress(hmod, "SetProcessDefaultCpuSetMasks"); /* W11 */
    474479        if (   g_pfnSetThreadGroupAffinity
    475480            && g_pfnGetActiveProcessorCount
     
    511516                    free(pInfo);
    512517            }
     518
     519            /* Iff this is windows 11 or later, the default policy should be that
     520               threads can be scheduled in any CPU group, so reset any prior crap
     521               to make sure this remains the case for us and our children.
     522
     523               This means we can skip g_pfnSetThreadGroupAffinity the calls later. */
     524            if (g_pfnSetProcessDefaultCpuSetMasks)
     525                g_pfnSetProcessDefaultCpuSetMasks(GetCurrentProcess(), NULL, 0);
     526            if (g_pfnSetThreadSelectedCpuSetMasks)
     527                g_pfnSetThreadSelectedCpuSetMasks(GetCurrentThread(), NULL, 0);
    513528
    514529            MkWinChildInitCpuGroupAllocator(&g_ProcessorGroupAllocator);
     
    13761391         */
    13771392#ifdef MKWINCHILD_DO_SET_PROCESSOR_GROUP
    1378         if (g_cProcessorGroups > 1)
     1393        if (g_cProcessorGroups > 1 && !g_pfnSetProcessDefaultCpuSetMasks)
    13791394        {
    13801395            GROUP_AFFINITY Affinity = { 0, pWorker->iProcessorGroup, { 0, 0, 0 } };
     
    25962611     *       the correct active processor mask.
    25972612     */
    2598     if (g_cProcessorGroups > 1)
     2613    if (g_cProcessorGroups > 1 && !g_pfnSetProcessDefaultCpuSetMasks)
    25992614    {
    26002615        BOOL           fRet;
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