CacheAwareScheduling: What is it and how does Windows benefit?


  1. Posts : 46
    many
       #1

    CacheAwareScheduling: What is it and how does Windows benefit?


    When doing some searching in the kernel of Windows 10 I came accross a registry value called CacheAwareScheduling.
    Google came up with some studies to the effects of cache aware scheduling in realtime OS environments.

    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\kernel
    CacheAwareScheduling dword 1

    So I entered it into the registry with a value of 1 and rebooted. But I cannot see much difference using task manager, performance monitor and other tools. Should have some effect on multi core platforms. Using tweaked balanced power scheme.

    My question is what does CacheAwareScheduling do in Windows 10? Anyone?

    Best wishes.
      My Computer


  2. Posts : 46
    many
    Thread Starter
       #2

    Old post but some additional info. These values give perfect performance:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel]
    "CacheAwareScheduling"=dword:00000002 ; testing (0,1,2,4) don't know the default, MS internal use only?
    "KernelSEHOPEnabled"=dword:00000000 ; testing (0,1), block exploits that use the Structured Exception Handler overwrite technique
    "MaxDynamicTickDuration"=dword:000003e8 ; 1000 uS (Don't use: bcdedit /set disabledynamictick yes)
    "MaximumSharedReadyQueueSize"=dword:00000001 ;w12r2 has 1
    "SerializeTimerExpiration"=dword:00000002 ;w12r2 has 2

    Cheers
    Last edited by tweakradje; 05 Jan 2022 at 16:56.
      My Computer


  3. Posts : 4
    Win10 Pro
       #3

    tweakradje said:
    Old post but some additional info. These values give perfect performance:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel]
    "CacheAwareScheduling"=dword:00000002 ; testing (0,1,2,4) don't know the default, MS internal use only?
    "KernelSEHOPEnabled"=dword:00000000 ; testing (0,1), block exploits that use the Structured Exception Handler overwrite technique
    "MaxDynamicTickDuration"=dword:000003e8 ; 1000 uS (Don't use: bcdedit /set disabledynamictick yes)
    "MaximumSharedReadyQueueSize"=dword:00000001 ;w12r2 has 1
    "SerializeTimerExpiration"=dword:00000002 ;w12r2 has 2

    Cheers
    [Defaults] Windows 10 Pro 21H2 - Build: 10.0.19044.1645
    CacheAwareScheduling = 7 ( Its not Internal use only, its writeable per Registry. )
    MaxDynamicTickDuration = Hex: 54f820d4
    MaxDynamicTickDurationSize = Hex: ffffffff
    *MinDynamicTickDuration = Decimal: 1000; Hex: 3E8
    MaximumSharedReadyQueueSize = Decimal: 260; Hex: 104
    SerializeTimerExpiration = 1

    I tested SerializeTimerExpiration 2, didnt work. Value of 2 sets SerializeTimerExpiration to 0.
    *There is Min,too.
    There are much much more Settings.

    Greetings
    St1cky
      My Computer


  4. Posts : 46
    many
    Thread Starter
       #4

    St1cky said:
    [Defaults] Windows 10 Pro 21H2 - Build: 10.0.19044.1645
    CacheAwareScheduling = 7 ( Its not Internal use only, its writeable per Registry. )
    MaxDynamicTickDuration = Hex: 54f820d4
    MaxDynamicTickDurationSize = Hex: ffffffff
    *MinDynamicTickDuration = Decimal: 1000; Hex: 3E8
    MaximumSharedReadyQueueSize = Decimal: 260; Hex: 104
    SerializeTimerExpiration = 1I tested SerializeTimerExpiration 2, didnt work. Value of 2 sets SerializeTimerExpiration to 0.
    So:CacheAwareScheduling has values 0 1 2 3 4 5 6 7 (3 bit flags non documented)
    MaxDynamicTickDuration 1000 basicaly disables DynamicTick, since Min value (non registry) is the same
    SerializeTimerExpiration 0=def/auto 1=force 2=off (win internals), but 2 falls back to 0 in win10
    MaximumSharedReadyQueueSize if I set 256 I get BSOD, 128 works

    Is it possible for you to list all these kernel values on your running system (while you are at it)?
    Allthough Windows 10 is pretty optimized on this it would be nice to know running values.

    Cheers
    Last edited by tweakradje; 10 May 2022 at 05:13.
      My Computer


  5. Posts : 4
    Win10 Pro
       #5

    tweakradje said:
    So:CacheAwareScheduling has values 0 1 2 3 4 5 6 7 (3 bit flags non documented)
    MaxDynamicTickDuration 1000 basicaly disables DynamicTick, since Min value (non registry) is the same
    SerializeTimerExpiration 0=def/auto 1=force 2=off (win internals), but 2 falls back to 0 in win10
    MaximumSharedReadyQueueSize if I set 256 I get BSOD, 128 works

    Is it possible for you to list all these kernel values on your running system (while you are at it)?
    Allthough Windows 10 is pretty optimized on this it would be nice to know running values.

    Cheers
    Correct, DWORD: MinDynamicTickDuration cannot be changed via the registry, only via debugger.
    I didnt tested max value of MaximumSharedReadyQueueSize.

    I believe it might be possible to list all values. But the values ​​and names are not the same names as in the registry. Some DWORDs are not associated with a name or it is not readable, more of a guessing game.

    Not all settings can be changed via the registry atleast some of them require special combinations or you need the deactived some locks. As I found out, some locks are unlocked by default.

    Example: Here, there is a DWORD called KiForceIdleDisabled, but here the prefix already helps us, the next point would be to find out what the registry keyword is, somehow some values ​​are not linked, which could be a problem with IDA. Possibilities would be: "ForceIdleDisabled","IdleForceDisable" etc.

    This DWORD is no power setting recognizable by the prefix and I had a different value before that when I tested some other things. Now it's back to 0. Of course, in this example, this DWORD could be linked to power settings.

    Idle Strings:
    Code:
    ActiveIdleLevel
    ActiveIdleThreshold
    ActiveIdleTimeout
    DisableIdleStatesAtBoot
    Enlightened Idle
    ForceIdleGracePeriod
    ForceIdleResetReason
    HalProcessorIdle
    Idle
    IdleAllowScaling
    IdleDemoteThreshold
    IdleDisable
    IdleDurationExpirationTimeout
    IdleIntervalCountBucketLimitsInMs
    IdleIntervalCountBuckets
    IdleMaxDurationInUs
    IdleMinDurationInUs
    IdlePhaseWatchdog
    IdleProcessorsRequireQosManagement
    IdlePromoteThreshold
    IdleScanInterval
    IdleStateCount
    IdleStateMax
    IdleStateTimeout
    IdleTimeCheck
    IdleTotalDurationInUs
    LatencyToleranceIdleResiliency
    PdcIdlePhaseDefaultWatchdogTimeoutSeconds
    PoCpuIdledSinceLastCallImprecise
    PoFxCompleteIdleCondition
    PoFxCompleteIdleCondition
    PoFxCompleteIdleState
    PoFxCompleteIdleState
    PoFxIdleComponent
    PoFxIdleComponent
    PoFxSetDeviceIdleTimeout
    PoFxSetDeviceIdleTimeout
    PoGetProcessorIdleAccounting
    PoRegisterDeviceForIdleDetection
    Power-IdleStatesMax-Enabled
    SystemIdle
    WorkerFactoryThreadIdleTimeout
    Some Code of DynamicTick:
    Code:
    __int64 __fastcall KiSetupTimeIncrement(unsigned __int64 a1, unsigned int a2)
    {
      unsigned int v3; // er9
      unsigned int v4; // eax
      unsigned int v5; // ecx
      unsigned __int64 v6; // rax
      LARGE_INTEGER v7; // rax
      LARGE_INTEGER v8; // rbx
      LARGE_INTEGER v9; // rdi
      unsigned __int64 v10; // rax
      __int64 result; // rax
      char v12; // [rsp+30h] [rbp+8h] BYREF
      char v13; // [rsp+38h] [rbp+10h] BYREF
      LARGE_INTEGER PerformanceFrequency; // [rsp+40h] [rbp+18h] BYREF
    
      PerformanceFrequency.QuadPart = 0i64;
      v12 = 0;
      v3 = 156250; // Minimum Timer Resolution
      v4 = a2;
      if ( a2 <= 5000 ) // Maximum Timer Resolution ?
        v4 = 5000;
      v5 = KiMinDynamicTickDuration;
      KeMinimumIncrement = v4;
      if ( a1 < 156250 )
        v3 = a1;
      KeMaximumIncrement = v3;
      if ( a2 > KiMinDynamicTickDuration )
      {
        v5 = a2;
        KiMinDynamicTickDuration = a2;
      }
      v6 = KiMaxDynamicTickDuration;
      if ( a1 < KiMaxDynamicTickDuration )
      {
        v6 = a1;
        KiMaxDynamicTickDuration = a1;
      }
      if ( v6 < v5 )
        KiMaxDynamicTickDuration = v5;
      KiTickOffset = v3;
      v13 = 0;
      KiMaximumIncrementReciprocal = RtlpComputeFraction(1u, v3, &v13);
      KeNumberProcessorsGroup0[1] = -v13;
      v7 = KeQueryPerformanceCounter(&PerformanceFrequency);
      v8 = PerformanceFrequency;
      KeTimeAdjustmentFrequency = PerformanceFrequency.QuadPart;
      v9 = v7;
      v10 = RtlGenerateQpcToIncrementConstants(PerformanceFrequency.LowPart, &v12);
      MEMORY[0xFFFFF78000000300] = v8.QuadPart;
      MEMORY[0xFFFFF78000000360] = v10;
      MEMORY[0xFFFFF78000000369] = v12;
      MEMORY[0xFFFFF78000000358] = v10;
      MEMORY[0xFFFFF78000000368] = v12;
      MEMORY[0xFFFFF78000000348] = v9.QuadPart;
      MEMORY[0xFFFFF78000000350] = v9.QuadPart;
      result = 0x989680u / KeMaximumIncrement;
      KiBalanceSetManagerPeriod = 0x989680u / KeMaximumIncrement;
      KiBalanceSetManagerCount = 0x989680u / KeMaximumIncrement;
      return result;
    }
    Last edited by St1cky; 10 May 2022 at 15:13.
      My Computer


  6. Posts : 4
    Win10 Pro
       #6

    tweakradje said:
    So:CacheAwareScheduling has values 0 1 2 3 4 5 6 7 (3 bit flags non documented)
    MaxDynamicTickDuration 1000 basicaly disables DynamicTick, since Min value (non registry) is the same
    SerializeTimerExpiration 0=def/auto 1=force 2=off (win internals), but 2 falls back to 0 in win10
    MaximumSharedReadyQueueSize if I set 256 I get BSOD, 128 works

    Is it possible for you to list all these kernel values on your running system (while you are at it)?
    Allthough Windows 10 is pretty optimized on this it would be nice to know running values.

    Cheers
    Here are all Values:
    GitHub - St1ckys/Win10: 22H2 - ALL VALUES OF NTOS
      My Computer


  7. Posts : 46
    many
    Thread Starter
       #7

    St1cky said:
    Thanks for your work!

    Cheers
      My Computer


  8. Posts : 4
    Win10 Pro
       #8

    tweakradje said:
    Thanks for your work!

    Cheers
    No Problem :)
    Have you figured out what the different Cache Aware settings do?

    At first glance, there are 5 functions where different bits of CacheAw. be checked.
    And you're right, it's 3 bits. To find out more about it, I would have to connect via Live Kernel Debug and set breakpoints, which I might do now to see exactly what is happening.

    The 5 functions are:
    KeSelectIdealProcessor
    KiChooseTargetProcessor
    KiSearchForNewThreadOnNode
    KiSelectIdleProcessor
    KiSwapThread

    Greetings

    - - - Updated - - -

    KeSelectIdealProcessor Checks if Bit 2 is set ( 100b <- 2,1,0 ), but only if a4 is 1. What will happen after all drivers are loaded in the boot process ) ( 0101010101 .. )

    KiChooseTargetProcessor Checks if Bit 0 is 0, if yes it skippes the if statement. ( On default it executes it and overwrites some other values in memory.)

    KiSearchForNewThreadOnNode & KiSwapThread Checks if Bit 1 is 0, if yes it skippes the if statement. ( On default it overwrites v7(v48) what was 3 to 1.) ( Vmware uses 4 cores )
    SO if Bit 1 is 0, it will not overwrite v7 (3) with 1.

    KiSearchForNewThreadOnNode and KiSwapThread, override 3 with 1. What number of cores could be -1.

    If the assumption is correct, bit 1 could represent that all cores are used or not for Scheduling/Threading.


    - - - Updated - - -

    KiSearchForNewThreadOnNode & KiSwapThread No Vmware was set to 4 CPUs instead of 4 Cores rofl. My mistake, with 8 cores, v7(v48) is FFh what is 11111111binary, could be 8 Cores or 255.

    And i think with Default 7, it could overwrite it with 1 again, i didnt checked since it takes somehow ages for me to load Vmware Kernel Debug. Checking maybe other time again.

    I would test 101bin -> 5Hex, for difference.
      My Computer


  9. Posts : 46
    many
    Thread Starter
       #9

    St1cky said:
    No Problem :)
    I would test 101bin -> 5Hex, for difference.
    Very interesting work. I have been running 3 for a long time. Switching to 5 looks to give a smoother experience.
    I will keep you updated. Gonna try 5 on multiple PC's.

    Cheers
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:40.
Find Us




Windows 10 Forums