Commit 1312c664 authored by Roderick Colenbrander's avatar Roderick Colenbrander Committed by Alexandre Julliard

ntdll: Report physical cores once with proper thread mask.

parent c6a71b91
......@@ -1333,17 +1333,16 @@ static inline BOOL logical_proc_info_add_by_id(SYSTEM_LOGICAL_PROCESSOR_INFORMAT
if (pdata) {
DWORD i;
if(rel == RelationProcessorPackage){
for(i=0; i<*len; i++)
for (i=0; i<*len; i++)
{
if (rel == RelationProcessorPackage && (*pdata)[i].Relationship == rel && (*pdata)[i].u.Reserved[1] == id)
{
if ((*pdata)[i].Relationship!=rel || (*pdata)[i].u.Reserved[1]!=id)
continue;
(*pdata)[i].ProcessorMask |= mask;
return TRUE;
}
}else
i = *len;
else if (rel == RelationProcessorCore && (*pdata)[i].Relationship == rel && (*pdata)[i].u.Reserved[1] == id)
return TRUE;
}
while(*len == *pmax_len)
{
......@@ -1369,6 +1368,10 @@ static inline BOOL logical_proc_info_add_by_id(SYSTEM_LOGICAL_PROCESSOR_INFORMAT
dataex->u.Processor.GroupMask[0].Mask |= mask;
return TRUE;
}
else if (rel == RelationProcessorCore && dataex->Relationship == rel && dataex->u.Processor.Reserved[1] == id)
{
return TRUE;
}
ofs += dataex->Size;
}
......@@ -1554,6 +1557,9 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
for(i=beg; i<=end; i++)
{
DWORD phys_core = 0;
ULONG_PTR thread_mask = 0;
if(i > 8*sizeof(ULONG_PTR))
{
FIXME("skipping logical processor %d\n", i);
......@@ -1574,15 +1580,35 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
return STATUS_NO_MEMORY;
}
sprintf(name, core_info, i, "core_id");
/* Sysfs enumerates logical cores (and not physical cores), but Windows enumerates
* by physical core. Upon enumerating a logical core in sysfs, we register a physical
* core and all its logical cores. In order to not report physical cores multiple
* times, we pass a unique physical core ID to logical_proc_info_add_by_id and let
* that call figure out any duplication.
* Obtain a unique physical core ID from the first element of thread_siblings_list.
* This list provides logical cores sharing the same physical core. The IDs are based
* on kernel cpu core numbering as opposed to a hardware core ID like provided through
* 'core_id', so are suitable as a unique ID.
*/
sprintf(name, core_info, i, "thread_siblings_list");
f = fopen(name, "r");
if(f)
{
fscanf(f, "%u", &r);
fscanf(f, "%d%c", &phys_core, &op);
fclose(f);
}
else phys_core = i;
/* Mask of logical threads sharing same physical core in kernel core numbering. */
sprintf(name, core_info, i, "thread_siblings");
f = fopen(name, "r");
if(f)
{
fscanf(f, "%lx", &thread_mask);
fclose(f);
}
else r = i;
if(!logical_proc_info_add_by_id(data, dataex, &len, max_len, RelationProcessorCore, r, (ULONG_PTR)1 << i))
else thread_mask = 1<<i;
if(!logical_proc_info_add_by_id(data, dataex, &len, max_len, RelationProcessorCore, phys_core, thread_mask))
{
fclose(fcpu_list);
return STATUS_NO_MEMORY;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment