2

I would like to change numa group in running process via PS

all the time is take group 1 :( and cpu work 50%

this - I can do by hand but I don`t know how via PS

my problem is that I have processes that always get assigned to the same group, resulting in 50% of the cpu

enter image description here

Mathias when I add 2 I get this (in the powershell instruction the bitmask controlls number of cpus to in a processor group only - so if the process get's assigned to a group 0, the instruction only changes the number of cpus in this group)

enter image description here

Rafał Developer
  • 2,135
  • 9
  • 40
  • 72

2 Answers2

2

You need to set the ProcessorAffinity property on the corresponding process:

Get-Process vmmem |ForEach-Object {
  $_.ProcessorAffinity = [IntPtr]::new([long]-1) # -1 corresponds to all 64 bits set
}
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
2

This is not what I call an answer actually (I am not a C++ dev), however, here is a part of the way to probably achieve this :

$MethodDefinition = @'
    [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
    public static extern bool SetThreadGroupAffinity(......);
'@
$Kernel32 = Add-Type -MemberDefinition $MethodDefinition -Name "Kernel32" -PassThru

#Retrieve the Thread handle first
#Call by $Kernel32::SetThreadGroupAffinity(......)

MS docs SetThreadGroupAffinity, MS docs GoupAfffinity Structure

May be this one be useful too MS docs SetThreadAffinityMask

CFou
  • 978
  • 3
  • 13