All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [RFC] drm/amdkfd: Use logical cpu id for building vcrat
       [not found] ` <84019ce7-4bda-4740-81f7-bfeb06f11b13-9zgFLTTCnj2VNr1+fo7GR8DXdtEM2QSaEmlz1D7Bsj1Om+2sqEXiZ9VYi19F/pQSQQ4Iyu8u01E@public.gmane.org>
@ 2019-04-16  3:24   ` Kuehling, Felix
       [not found]     ` <87066753-b061-da00-9795-ca38ada81622-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Kuehling, Felix @ 2019-04-16  3:24 UTC (permalink / raw)
  To: Hillf Danton, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Deucher, Alexander,
	Mark Nutter <Mark.Nutter-5wv7dgnIgG8@public.gmane.org>,
	Koenig, Christian,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Catalin Marinas
	<catalin.marinas-5wv7dgnIgG8@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 2670 bytes --]

On x86 we use the apicid to associate caches with CPU cores. See the Thunk code in libhsakmt/src/topology.c (static void find_cpu_cache_siblings()). If we used a different way to identify CPU cores, I think that would break. This code in the Thunk is x86-specific as it uses the CPUID instruction. We don't have equivalent code for ARM. So for ARM it doesn't really matter much, how you count your CPU cores in the CRAT table.

I think eventually we want to get rid of that fragile CPUID code in the Thunk and get the cache information in kernel mode and report it to user mode through the KFD topology sysfs filesystem. Then we could also move away from using apicids as CPU IDs on x86.

It's not a high priority as I'm not aware of any applications that actually make use of the cache information.

Regards,
  Felix

On 2019-04-15 22:39, Hillf Danton wrote:
Hi folks

In commit d1c234e2cd, arm64 is granted to build kfd. Currently, it is physical
cpu id that is used for building the x86_64 vcrat, but logical cpu id is used
instead for arm64, though the function name requires apicid. Can we use the
physical id for both arches if it really has an up-hand over the logical one,
as the following tiny diff represents?

--- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c    2019-04-16 07:55:56.611685400 +0800
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 09:16:50.506126600 +0800
@@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const
       first_cpu_of_numa_node = cpumask_first(cpumask);
       if (first_cpu_of_numa_node >= nr_cpu_ids)
             return -1;
-#ifdef CONFIG_X86_64
-     return cpu_data(first_cpu_of_numa_node).apicid;
-#else
-     return first_cpu_of_numa_node;
-#endif
+    return cpu_physical_id(first_cpu_of_numa_node);
}
/* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor
--


Or is logical cpu id enough to do the work, with some cosmetic applied to the
function names(not included in the following simple diff yet)?

thanks
Hillf


--- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c    2019-04-16 07:55:56.611685400 +0800
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 09:18:24.546578400 +0800
@@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const
       first_cpu_of_numa_node = cpumask_first(cpumask);
       if (first_cpu_of_numa_node >= nr_cpu_ids)
             return -1;
-#ifdef CONFIG_X86_64
-     return cpu_data(first_cpu_of_numa_node).apicid;
-#else
       return first_cpu_of_numa_node;
-#endif
}
/* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor
--


[-- Attachment #1.2: Type: text/html, Size: 6865 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] drm/amdkfd: Use logical cpu id for building vcrat
       [not found]     ` <87066753-b061-da00-9795-ca38ada81622-5C7GfCeVMHo@public.gmane.org>
@ 2019-04-16  6:44       ` Christian König
       [not found]         ` <f9597352-4f96-9519-d03e-69f8c6c3c70b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Christian König @ 2019-04-16  6:44 UTC (permalink / raw)
  To: Kuehling, Felix, Hillf Danton,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Daniel Vetter
  Cc: Deucher, Alexander,
	Mark Nutter <Mark.Nutter-5wv7dgnIgG8@public.gmane.org>,
	Koenig, Christian,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Catalin Marinas
	<catalin.marinas-5wv7dgnIgG8@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 3480 bytes --]

> It's not a high priority as I'm not aware of any applications that 
> actually make use of the cache information.
>
Which raises the question why we have done this in the first place? When 
nobody is using it could we just remove the interface?

Regards,
Christian.

Am 16.04.19 um 05:24 schrieb Kuehling, Felix:
>
> On x86 we use the apicid to associate caches with CPU cores. See the 
> Thunk code in libhsakmt/src/topology.c (static void 
> find_cpu_cache_siblings()). If we used a different way to identify CPU 
> cores, I think that would break. This code in the Thunk is 
> x86-specific as it uses the CPUID instruction. We don't have 
> equivalent code for ARM. So for ARM it doesn't really matter much, how 
> you count your CPU cores in the CRAT table.
>
> I think eventually we want to get rid of that fragile CPUID code in 
> the Thunk and get the cache information in kernel mode and report it 
> to user mode through the KFD topology sysfs filesystem. Then we could 
> also move away from using apicids as CPU IDs on x86.
>
> It's not a high priority as I'm not aware of any applications that 
> actually make use of the cache information.
>
> Regards,
>   Felix
>
> On 2019-04-15 22:39, Hillf Danton wrote:
>>
>> Hi folks
>>
>> In commit d1c234e2cd, arm64 is granted to build kfd. Currently, it is 
>> physical
>>
>> cpu id that is used for building the x86_64 vcrat, but logical cpu id 
>> is used
>>
>> instead for arm64, though the function name requires apicid. Can we 
>> use the
>>
>> physical id for both arches if it really has an up-hand over the 
>> logical one,
>>
>> as the following tiny diff represents?
>>
>> --- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 
>> 2019-04-16 07:55:56.611685400 +0800
>>
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 
>> 09:16:50.506126600 +0800
>>
>> @@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const
>>
>> first_cpu_of_numa_node = cpumask_first(cpumask);
>>
>>        if (first_cpu_of_numa_node >= nr_cpu_ids)
>>
>>              return -1;
>>
>> -#ifdef CONFIG_X86_64
>>
>> -     return cpu_data(first_cpu_of_numa_node).apicid;
>>
>> -#else
>>
>> -     return first_cpu_of_numa_node;
>>
>> -#endif
>>
>> +    return cpu_physical_id(first_cpu_of_numa_node);
>>
>> }
>>
>> /* kfd_numa_node_to_apic_id - Returns the APIC ID of the first 
>> logical processor
>>
>> --
>>
>> Or is logical cpu id enough to do the work, with some cosmetic 
>> applied to the
>>
>> function names(not included in the following simple diff yet)?
>>
>> thanks
>>
>> Hillf
>>
>> --- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 
>> 2019-04-16 07:55:56.611685400 +0800
>>
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 
>> 09:18:24.546578400 +0800
>>
>> @@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const
>>
>> first_cpu_of_numa_node = cpumask_first(cpumask);
>>
>>        if (first_cpu_of_numa_node >= nr_cpu_ids)
>>
>>              return -1;
>>
>> -#ifdef CONFIG_X86_64
>>
>> -     return cpu_data(first_cpu_of_numa_node).apicid;
>>
>> -#else
>>
>>        return first_cpu_of_numa_node;
>>
>> -#endif
>>
>> }
>>
>> /* kfd_numa_node_to_apic_id - Returns the APIC ID of the first 
>> logical processor
>>
>> --
>>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[-- Attachment #1.2: Type: text/html, Size: 8801 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] drm/amdkfd: Use logical cpu id for building vcrat
       [not found]         ` <f9597352-4f96-9519-d03e-69f8c6c3c70b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2019-04-16 18:21           ` Kuehling, Felix
  0 siblings, 0 replies; 4+ messages in thread
From: Kuehling, Felix @ 2019-04-16 18:21 UTC (permalink / raw)
  To: Koenig, Christian, Hillf Danton,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Daniel Vetter
  Cc: Deucher, Alexander,
	Mark Nutter <Mark.Nutter-5wv7dgnIgG8@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Catalin Marinas
	<catalin.marinas-5wv7dgnIgG8@public.gmane.org>

On 2019-04-16 2:44 a.m., Christian König wrote:
>>
>> It's not a high priority as I'm not aware of any applications that 
>> actually make use of the cache information.
>>
> Which raises the question why we have done this in the first place? 
> When nobody is using it could we just remove the interface?

The interface for cache information in the topology has existed since 
KFD was first introduced for APUs. On APUs the information is contained 
in the CRAT table. I see no reason not to report available information 
to user mode. If you wanted to remove it, you'd need to prove that 
nobody is using it. My statement was much weaker than that.

Furthermore, the cache information on CPUs is currently generated in 
user mode anyway. Changing the way we count CPU cores would break that 
existing user mode code, so we can't do that. That said, there is no 
kernel code to remove here. All I was saying was, that it's not a high 
priority to add the kernel code to populate CPU cache information in 
kernel mode.

Regards,
   Felix


>
> Regards,
> Christian.
>
> Am 16.04.19 um 05:24 schrieb Kuehling, Felix:
>>
>> On x86 we use the apicid to associate caches with CPU cores. See the 
>> Thunk code in libhsakmt/src/topology.c (static void 
>> find_cpu_cache_siblings()). If we used a different way to identify 
>> CPU cores, I think that would break. This code in the Thunk is 
>> x86-specific as it uses the CPUID instruction. We don't have 
>> equivalent code for ARM. So for ARM it doesn't really matter much, 
>> how you count your CPU cores in the CRAT table.
>>
>> I think eventually we want to get rid of that fragile CPUID code in 
>> the Thunk and get the cache information in kernel mode and report it 
>> to user mode through the KFD topology sysfs filesystem. Then we could 
>> also move away from using apicids as CPU IDs on x86.
>>
>> It's not a high priority as I'm not aware of any applications that 
>> actually make use of the cache information.
>>
>> Regards,
>>   Felix
>>
>> On 2019-04-15 22:39, Hillf Danton wrote:
>>>
>>> Hi folks
>>>
>>> In commit d1c234e2cd, arm64 is granted to build kfd. Currently, it 
>>> is physical
>>>
>>> cpu id that is used for building the x86_64 vcrat, but logical cpu 
>>> id is used
>>>
>>> instead for arm64, though the function name requires apicid. Can we 
>>> use the
>>>
>>> physical id for both arches if it really has an up-hand over the 
>>> logical one,
>>>
>>> as the following tiny diff represents?
>>>
>>> --- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 
>>> 2019-04-16 07:55:56.611685400 +0800
>>>
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 
>>> 09:16:50.506126600 +0800
>>>
>>> @@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const
>>>
>>> first_cpu_of_numa_node = cpumask_first(cpumask);
>>>
>>>        if (first_cpu_of_numa_node >= nr_cpu_ids)
>>>
>>>              return -1;
>>>
>>> -#ifdef CONFIG_X86_64
>>>
>>> -     return cpu_data(first_cpu_of_numa_node).apicid;
>>>
>>> -#else
>>>
>>> -     return first_cpu_of_numa_node;
>>>
>>> -#endif
>>>
>>> +    return cpu_physical_id(first_cpu_of_numa_node);
>>>
>>> }
>>>
>>> /* kfd_numa_node_to_apic_id - Returns the APIC ID of the first 
>>> logical processor
>>>
>>> --
>>>
>>> Or is logical cpu id enough to do the work, with some cosmetic 
>>> applied to the
>>>
>>> function names(not included in the following simple diff yet)?
>>>
>>> thanks
>>>
>>> Hillf
>>>
>>> --- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 
>>> 2019-04-16 07:55:56.611685400 +0800
>>>
>>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 
>>> 09:18:24.546578400 +0800
>>>
>>> @@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const
>>>
>>> first_cpu_of_numa_node = cpumask_first(cpumask);
>>>
>>>        if (first_cpu_of_numa_node >= nr_cpu_ids)
>>>
>>>              return -1;
>>>
>>> -#ifdef CONFIG_X86_64
>>>
>>> -     return cpu_data(first_cpu_of_numa_node).apicid;
>>>
>>> -#else
>>>
>>>        return first_cpu_of_numa_node;
>>>
>>> -#endif
>>>
>>> }
>>>
>>> /* kfd_numa_node_to_apic_id - Returns the APIC ID of the first 
>>> logical processor
>>>
>>> --
>>>
>>
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC] drm/amdkfd: Use logical cpu id for building vcrat
@ 2019-04-16  2:39 Hillf Danton
  0 siblings, 0 replies; 4+ messages in thread
From: Hillf Danton @ 2019-04-16  2:39 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Mark Nutter <Mark.Nutter-5wv7dgnIgG8@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Catalin Marinas
	<catalin.marinas-5wv7dgnIgG8@public.gmane.org>,
	Felix Kuehling
	<Felix.Kuehling-5C7GfCeVMHo@public.gmane.org>,
	Alex Deucher
	<alexander.deucher-5C7GfCeVMHo@public.gmane.org>,
	Christian Koenig
	<christian.koenig-5C7GfCeVMHo@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1730 bytes --]

Hi folks

In commit d1c234e2cd, arm64 is granted to build kfd. Currently, it is physical
cpu id that is used for building the x86_64 vcrat, but logical cpu id is used
instead for arm64, though the function name requires apicid. Can we use the
physical id for both arches if it really has an up-hand over the logical one,
as the following tiny diff represents?

--- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c	2019-04-16 07:55:56.611685400 +0800
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c	2019-04-16 09:16:50.506126600 +0800
@@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const
	first_cpu_of_numa_node = cpumask_first(cpumask);
	if (first_cpu_of_numa_node >= nr_cpu_ids)
		return -1;
-#ifdef CONFIG_X86_64
-	return cpu_data(first_cpu_of_numa_node).apicid;
-#else
-	return first_cpu_of_numa_node;
-#endif
+	return cpu_physical_id(first_cpu_of_numa_node);
}
 /* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor
--


Or is logical cpu id enough to do the work, with some cosmetic applied to the 
function names(not included in the following simple diff yet)?

thanks
Hillf


--- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c	2019-04-16 07:55:56.611685400 +0800
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c	2019-04-16 09:18:24.546578400 +0800
@@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const
	first_cpu_of_numa_node = cpumask_first(cpumask);
	if (first_cpu_of_numa_node >= nr_cpu_ids)
		return -1;
-#ifdef CONFIG_X86_64
-	return cpu_data(first_cpu_of_numa_node).apicid;
-#else
	return first_cpu_of_numa_node;
-#endif
}
 /* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor
--


[-- Attachment #1.2: Type: text/html, Size: 5271 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-16 18:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <84019ce7-4bda-4740-81f7-bfeb06f11b13@BY2NAM03FT064.eop-NAM03.prod.protection.outlook.com>
     [not found] ` <84019ce7-4bda-4740-81f7-bfeb06f11b13-9zgFLTTCnj2VNr1+fo7GR8DXdtEM2QSaEmlz1D7Bsj1Om+2sqEXiZ9VYi19F/pQSQQ4Iyu8u01E@public.gmane.org>
2019-04-16  3:24   ` [RFC] drm/amdkfd: Use logical cpu id for building vcrat Kuehling, Felix
     [not found]     ` <87066753-b061-da00-9795-ca38ada81622-5C7GfCeVMHo@public.gmane.org>
2019-04-16  6:44       ` Christian König
     [not found]         ` <f9597352-4f96-9519-d03e-69f8c6c3c70b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-04-16 18:21           ` Kuehling, Felix
2019-04-16  2:39 Hillf Danton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.