[PATCH 1/5] kernel32: Fix return type of GetMaximumProcessorGroupCount
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/kernel32/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index b31d73bc5a5..9041b00d512 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -638,7 +638,7 @@ DWORD WINAPI GetMaximumProcessorCount(WORD group) /*********************************************************************** * GetMaximumProcessorGroupCount (KERNEL32.@) */ -DWORD WINAPI GetMaximumProcessorGroupCount(void) +WORD WINAPI GetMaximumProcessorGroupCount(void) { FIXME("semi-stub, always returning 1\n"); return 1; -- 2.31.1
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/kernel32/process.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 9041b00d512..7020a388cda 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -609,8 +609,20 @@ HRESULT WINAPI RegisterApplicationRecoveryCallback(APPLICATION_RECOVERY_CALLBACK */ WORD WINAPI GetActiveProcessorGroupCount(void) { - FIXME("semi-stub, always returning 1\n"); - return 1; + WORD groups; + DWORD size = 0; + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info; + + TRACE("()\n"); + + if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0; + if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0; + if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size)) return 0; + + groups = info->Group.ActiveGroupCount; + + HeapFree(GetProcessHeap(), 0, info); + return groups; } /*********************************************************************** -- 2.31.1
Alex Henrie <alexhenrie24(a)gmail.com> wrote:
WORD WINAPI GetActiveProcessorGroupCount(void) { - FIXME("semi-stub, always returning 1\n"); - return 1; + WORD groups; + DWORD size = 0; + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info; + + TRACE("()\n"); + + if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0; + if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0; + if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size)) return 0;
Memory is leaked here.
+ + groups = info->Group.ActiveGroupCount; + + HeapFree(GetProcessHeap(), 0, info); + return groups; }
After looking at the ntdll implementation it seems, that it should be possible to avoid memory allocation and use buffer of a fixed size. -- Dmitry.
On Mon, May 24, 2021 at 12:58 AM Dmitry Timoshkov <dmitry(a)baikal.ru> wrote:
Alex Henrie <alexhenrie24(a)gmail.com> wrote:
WORD WINAPI GetActiveProcessorGroupCount(void) { - FIXME("semi-stub, always returning 1\n"); - return 1; + WORD groups; + DWORD size = 0; + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info; + + TRACE("()\n"); + + if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0; + if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0; + if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size)) return 0;
Memory is leaked here.
Fixed in v2, thanks.
+ + groups = info->Group.ActiveGroupCount; + + HeapFree(GetProcessHeap(), 0, info); + return groups; }
After looking at the ntdll implementation it seems, that it should be possible to avoid memory allocation and use buffer of a fixed size.
That may be true now, but I don't know if that's what Alexandre wants because if Wine supports an arbitrary number of processor groups in the future, the fixed-size buffer to hold information about 65,534 of them would require a lot of memory. -Alex
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/kernel32/process.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 7020a388cda..3ad63cf5371 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -630,9 +630,28 @@ WORD WINAPI GetActiveProcessorGroupCount(void) */ DWORD WINAPI GetActiveProcessorCount(WORD group) { - DWORD cpus = system_info.NumberOfProcessors; + DWORD cpus = 0; + DWORD size = 0; + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info; - FIXME("(0x%x): semi-stub, returning %u\n", group, cpus); + TRACE("(0x%x)\n", group); + + if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0; + if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0; + if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size)) return 0; + + if (group == ALL_PROCESSOR_GROUPS) + { + for (group = 0; group < info->Group.ActiveGroupCount; group++) + cpus += info->Group.GroupInfo[group].ActiveProcessorCount; + } + else + { + if (group < info->Group.ActiveGroupCount) + cpus = info->Group.GroupInfo[group].ActiveProcessorCount; + } + + HeapFree(GetProcessHeap(), 0, info); return cpus; } -- 2.31.1
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/kernel32/process.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 3ad63cf5371..863f2c67413 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -660,9 +660,28 @@ DWORD WINAPI GetActiveProcessorCount(WORD group) */ DWORD WINAPI GetMaximumProcessorCount(WORD group) { - DWORD cpus = system_info.NumberOfProcessors; + DWORD cpus = 0; + DWORD size = 0; + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info; + + TRACE("(0x%x)\n", group); - FIXME("(0x%x): semi-stub, returning %u\n", group, cpus); + if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0; + if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0; + if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size)) return 0; + + if (group == ALL_PROCESSOR_GROUPS) + { + for (group = 0; group < info->Group.ActiveGroupCount; group++) + cpus += info->Group.GroupInfo[group].MaximumProcessorCount; + } + else + { + if (group < info->Group.ActiveGroupCount) + cpus = info->Group.GroupInfo[group].MaximumProcessorCount; + } + + HeapFree(GetProcessHeap(), 0, info); return cpus; } -- 2.31.1
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> --- dlls/kernel32/process.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 863f2c67413..f88a613c7b4 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -690,8 +690,20 @@ DWORD WINAPI GetMaximumProcessorCount(WORD group) */ WORD WINAPI GetMaximumProcessorGroupCount(void) { - FIXME("semi-stub, always returning 1\n"); - return 1; + WORD groups; + DWORD size = 0; + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info; + + TRACE("()\n"); + + if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, &size)) return 0; + if (!(info = HeapAlloc(GetProcessHeap(), 0, size))) return 0; + if (!GetLogicalProcessorInformationEx(RelationGroup, info, &size)) return 0; + + groups = info->Group.MaximumGroupCount; + + HeapFree(GetProcessHeap(), 0, info); + return groups; } /*********************************************************************** -- 2.31.1
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=91061 Your paranoid android. === debiant2 (64 bit WoW report) === kernel32: change.c:350: Test failed: should be ready
participants (3)
-
Alex Henrie -
Dmitry Timoshkov -
Marvin