-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
windows with multiple processor groups, cpu.Percent(percpu=true) returns cpus of any one processor group only. #887
Comments
Thanks for your research, I hope to be able to exploit NtQuerySystemInformationEx, the calling convention is different compared to NtQuerySystemInformation, with two more parameters, an input buffer and its length. We will need to get all processor groups with GetLogicalProcessorInformationEx and call NtQuerySystemInformationEx for each of them (InputBuffer will be the group number a I understand it). In fact I already started investigating this function for #628 to get the number of physical cores without WMI, and it's not straighforward to use in Go. This document gives some information. |
NtQuerySystemInformationEx is available from version >= 6.1 (windows 7). A reference usage: https://github.com/r3p3r/WindowsInternals/blob/05638d4d28cfb1bdfe7d7d1d1331d5be541f91a3/CpuSet/CpuSet.cpp#L180-L182 https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions |
Hello, @Lomanic and @msays2000, what is the status of this issue, do you know if there are any plans to fix it? |
Describe the bug
In a windows instance having 36 cpu i.e having 36 * 2 logical cpus, windows groups CPU's into batch of 64 logical cpu in a processor group. In this example, it will have
gopsutil's cpu.Percent(percpu=true) randomly picks a processor group only and surfaces its result. In above example, if you run once it will log per cpu results showing 64 cpu's. It you stop and run again it will show the other processor group of 8 cpus.
To Reproduce
Expected behavior
Expected is it should return total cpu info of 72 logical cores consistently.
Actual is it returns either 64 or 8 cpus.
Environment (please complete the following information):
Additional context
Noticed the bug is calling an API that is probably not CPU processor group aware.
https://github.com/shirou/gopsutil/blob/master/cpu/cpu_windows.go#L188-L193
In https://github.com/shirou/gopsutil/blob/master/internal/common/common_windows.go#L64
ProcNtQuerySystemInformation = ModNt.NewProc("NtQuerySystemInformation")
Probably we should make use of NtQuerySystemInformationEx
This function gets a wide range of system properties but allows for refining the query by specifying such things as a processor group.
The text was updated successfully, but these errors were encountered: