Commit 440a06f7 authored by Anastasios Simeonidis's avatar Anastasios Simeonidis Committed by Alexandre Julliard

ntdll: Implement relationship filtering for create_logical_proc_info on linux.

Also calculate all_cpus_mask on first pass. Signed-off-by: 's avatarAnastasios Simeonidis <symeonidis@csd.auth.gr> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 9885b0ac
......@@ -1704,9 +1704,6 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
char op, name[MAX_PATH];
ULONG_PTR all_cpus_mask = 0;
if (relation != RelationAll)
FIXME("Relationship filtering not implemented: 0x%x\n", relation);
/* On systems with a large number of CPU cores (32 or 64 depending on 32-bit or 64-bit),
* we have issues parsing processor information:
* - ULONG_PTR masks as used in data structures can't hold all cores. Requires splitting
......@@ -1743,6 +1740,8 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
continue;
}
if(relation == RelationAll || relation == RelationProcessorPackage)
{
sprintf(name, core_info, i, "physical_package_id");
f = fopen(name, "r");
if(f)
......@@ -1756,6 +1755,7 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
fclose(fcpu_list);
return STATUS_NO_MEMORY;
}
}
/* 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
......@@ -1767,6 +1767,19 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
* on kernel cpu core numbering as opposed to a hardware core ID like provided through
* 'core_id', so are suitable as a unique ID.
*/
if(relation == RelationAll || relation == RelationProcessorCore ||
relation == RelationNumaNode || relation == RelationGroup)
{
/* Mask of logical threads sharing same physical core in kernel core numbering. */
sprintf(name, core_info, i, "thread_siblings");
if(!sysfs_parse_bitmap(name, &thread_mask))
thread_mask = 1<<i;
/* Needed later for NumaNode and Group. */
all_cpus_mask |= thread_mask;
if(relation == RelationAll || relation == RelationProcessorCore)
{
sprintf(name, core_info, i, "thread_siblings_list");
f = fopen(name, "r");
if(f)
......@@ -1776,16 +1789,16 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
}
else phys_core = i;
/* Mask of logical threads sharing same physical core in kernel core numbering. */
sprintf(name, core_info, i, "thread_siblings");
if(!sysfs_parse_bitmap(name, &thread_mask))
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;
}
}
}
if (relation == RelationAll || relation == RelationCache)
{
for(j=0; j<4; j++)
{
CACHE_DESCRIPTOR cache;
......@@ -1844,25 +1857,13 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
}
}
}
}
fclose(fcpu_list);
if(data){
for(i=0; i<len; i++){
if((*data)[i].Relationship == RelationProcessorCore){
all_cpus_mask |= (*data)[i].ProcessorMask;
}
}
}else{
for(i = 0; i < len; ){
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *infoex = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)(((char *)*dataex) + i);
if(infoex->Relationship == RelationProcessorCore){
all_cpus_mask |= infoex->u.Processor.GroupMask[0].Mask;
}
i += infoex->Size;
}
}
num_cpus = count_bits(all_cpus_mask);
if(relation == RelationAll || relation == RelationNumaNode)
{
fnuma_list = fopen("/sys/devices/system/node/online", "r");
if(!fnuma_list)
{
......@@ -1902,8 +1903,9 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
}
fclose(fnuma_list);
}
}
if(dataex)
if(dataex && (relation == RelationAll || relation == RelationGroup))
logical_proc_info_add_group(dataex, &len, max_len, num_cpus, all_cpus_mask);
if(data)
......
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