VirtualBox

Changeset 3355 in kBuild for trunk


Ignore:
Timestamp:
Jun 5, 2020 2:06:42 AM (4 years ago)
Author:
bird
Message:

kWorker,kmk: Correcting a few SetThreadGroupAffinity calls.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kWorker/Makefile.kmk

    r3192 r3355  
    7878       nt/ntunlink.c \
    7979       nt/kFsCache.c \
     80       win_get_processor_group_active_mask.c \
    8081       quote_argv.c \
    8182        is_console.c \
  • trunk/src/kWorker/kWorker.c

    r3347 r3355  
    5555#include "nt/kFsCache.h"
    5656#include "nt_fullpath.h"
     57#include "win_get_processor_group_active_mask.h"
    5758#include "quote_argv.h"
    5859#include "md5.h"
     
    1228412285
    1228512286
     12287/**
     12288 * Helper for main() argument handling that sets the processor group if
     12289 * possible.
     12290 */
     12291static void kwSetProcessorGroup(unsigned long uGroup)
     12292{
     12293    typedef BOOL (WINAPI *PFNSETTHREADGROUPAFFINITY)(HANDLE, const GROUP_AFFINITY*, GROUP_AFFINITY *);
     12294    HMODULE             const hmodKernel32 = GetModuleHandleW(L"KERNEL32.DLL");
     12295    PFNSETTHREADGROUPAFFINITY pfnSetThreadGroupAffinity;
     12296
     12297    pfnSetThreadGroupAffinity = (PFNSETTHREADGROUPAFFINITY)GetProcAddress(hmodKernel32, "SetThreadGroupAffinity");
     12298    if (pfnSetThreadGroupAffinity)
     12299    {
     12300        GROUP_AFFINITY OldAff = { 0,            0, 0, 0, 0 };
     12301        GROUP_AFFINITY NewAff = { 0, (WORD)uGroup, 0, 0, 0 };
     12302        NewAff.Mask = win_get_processor_group_active_mask((WORD)uGroup);
     12303        if (NewAff.Mask && (WORD)uGroup == uGroup)
     12304        {
     12305            if (!pfnSetThreadGroupAffinity(GetCurrentThread(), &NewAff, &OldAff))
     12306                kwErrPrintf("Failed to set processor group to %lu (%p): %u\n", uGroup, NewAff.Mask, GetLastError());
     12307        }
     12308        else if (GetLastError() == NO_ERROR)
     12309            kwErrPrintf("Cannot set processor group to %lu: No active processors in group!\n", uGroup);
     12310        else
     12311            kwErrPrintf("Cannot set processor group to %lu: GetLogicalProcessorInformationEx failed: %u\n",
     12312                        uGroup, GetLastError());
     12313    }
     12314    else
     12315    {
     12316        OSVERSIONINFOA VerInfo = {0};
     12317        if (VerInfo.dwMajorVersion > 6 || (VerInfo.dwMajorVersion == 6 && VerInfo.dwMinorVersion >= 1))
     12318            kwErrPrintf("Cannot set processor group to %lu: SetThreadGroupAffinity no found! (Windows version %lu.%lu)\n",
     12319                        uGroup, VerInfo.dwMajorVersion, VerInfo.dwMinorVersion);
     12320    }
     12321}
     12322
     12323
    1228612324int main(int argc, char **argv)
    1228712325{
     
    1251112549                    && *pszEnd == '\0'
    1251212550                    && uValue == (WORD)uValue)
    12513                 {
    12514                     typedef BOOL (WINAPI *PFNSETTHREADGROUPAFFINITY)(HANDLE, const GROUP_AFFINITY*, GROUP_AFFINITY *);
    12515                     PFNSETTHREADGROUPAFFINITY pfnSetThreadGroupAffinity;
    12516                     pfnSetThreadGroupAffinity = (PFNSETTHREADGROUPAFFINITY)GetProcAddress(GetModuleHandleW(L"KERNEL32.DLL"),
    12517                                                                                           "SetThreadGroupAffinity");
    12518                     if (pfnSetThreadGroupAffinity)
    12519                     {
    12520                         GROUP_AFFINITY NewAff = { ~(uintptr_t)0, (WORD)uValue, 0, 0, 0 };
    12521                         GROUP_AFFINITY OldAff = {             0,            0, 0, 0, 0 };
    12522                         if (!pfnSetThreadGroupAffinity(GetCurrentThread(), &NewAff, &OldAff))
    12523                             kwErrPrintf("Failed to set processor group to %lu: %u\n", uValue, GetLastError());
    12524                     }
    12525                     else
    12526                         kwErrPrintf("Cannot set processor group to %lu because SetThreadGroupAffinity was not found\n", uValue);
    12527                 }
     12551                    kwSetProcessorGroup(uValue);
    1252812552                else
    1252912553                    return kwErrPrintfRc(2, "Invalid --priority argument: %s\n", argv[i]);
  • trunk/src/kmk/kmkbuiltin/kSubmit.c

    r3313 r3355  
    588588                            if (iProcessorGroup >= 0 && g_pfnSetThreadGroupAffinity)
    589589                            {
    590                                 GROUP_AFFINITY NewAff = { ~(uintptr_t)0, (WORD)iProcessorGroup, 0, 0, 0 };
    591                                 GROUP_AFFINITY OldAff = {             0,                     0, 0, 0, 0 };
     590                                GROUP_AFFINITY OldAff = { 0,                                                    0, 0, 0, 0 };
     591                                GROUP_AFFINITY NewAff = { 0 /* == all active apparently */, (WORD)iProcessorGroup, 0, 0, 0 };
    592592                                if (!g_pfnSetThreadGroupAffinity(ProcInfo.hThread, &NewAff, &OldAff))
    593593                                    warnx(pCtx, "warning: Failed to set processor group to %d: %u\n",
  • trunk/src/kmk/w32/winchildren.c

    r3353 r3355  
    551551                        Info.BasicLimitInformation.LimitFlags &= ~JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
    552552                    if (!SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &Info, sizeof(Info)))
    553                         OSN(message, 0, _("SetInformationJobObject(%s,JobObjectExtendedLimitInformation,{%s},) failed: %u"),
    554                             pszJobName, win_job_object_mode, GetLastError());
     553                        OSSN(message, 0, _("SetInformationJobObject(%s,JobObjectExtendedLimitInformation,{%s},) failed: %u"),
     554                             pszJobName, win_job_object_mode, GetLastError());
    555555                }
    556556                else
     
    12831283        if (g_cProcessorGroups > 1)
    12841284        {
    1285             GROUP_AFFINITY Affinity = { 0, pWorker->iProcessorGroup, { 0, 0, 0 } };
     1285            GROUP_AFFINITY Affinity = { 0 /* == all active apparently */, pWorker->iProcessorGroup, { 0, 0, 0 } };
    12861286            fRet = g_pfnSetThreadGroupAffinity(ProcInfo.hThread, &Affinity, NULL);
    12871287            assert(fRet);
     
    24902490    if (g_cProcessorGroups > 1)
    24912491    {
    2492         GROUP_AFFINITY Affinity = { 0 /* == all active apparently */ , pWorker->iProcessorGroup, { 0, 0, 0 } };
     2492        GROUP_AFFINITY Affinity = { 0 /* == all active apparently */, pWorker->iProcessorGroup, { 0, 0, 0 } };
    24932493        BOOL fRet = g_pfnSetThreadGroupAffinity(GetCurrentThread(), &Affinity, NULL);
    24942494        assert(fRet); (void)fRet;
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