<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>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.</p>
<p>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.<br>
</p>
<p>It's not a high priority as I'm not aware of any applications that actually make use of the cache information.</p>
<p>Regards,<br>
Felix<br>
</p>
<div class="moz-cite-prefix">On 2019-04-15 22:39, Hillf Danton wrote:<br>
</div>
<blockquote type="cite" cite="mid:84019ce7-4bda-4740-81f7-bfeb06f11b13@BY2NAM03FT064.eop-NAM03.prod.protection.outlook.com">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.5pt;
font-family:DengXian;}
.MsoChpDefault
{mso-style-type:export-only;}
/* Page Definitions */
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi folks</span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">In commit d1c234e2cd, arm64 is granted to build kfd. Currently, it is physical</span></p>
<p class="MsoNormal"><span lang="EN-US">cpu id that is used for building the x86_64 vcrat, but logical cpu id is used</span></p>
<p class="MsoNormal"><span lang="EN-US">instead for arm64, though the function name requires apicid. Can we use the</span></p>
<p class="MsoNormal"><span lang="EN-US">physical id for both arches if it really has an up-hand over the logical one,</span></p>
<p class="MsoNormal"><span lang="EN-US">as the following tiny diff represents?</span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">--- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 07:55:56.611685400 +0800</span></p>
<p class="MsoNormal"><span lang="EN-US">+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 09:16:50.506126600 +0800</span></p>
<p class="MsoNormal"><span lang="EN-US">@@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const</span></p>
<p class="MsoNormal"><span lang="EN-US"> first_cpu_of_numa_node = cpumask_first(cpumask);</span></p>
<p class="MsoNormal"><span lang="EN-US"> if (first_cpu_of_numa_node >= nr_cpu_ids)</span></p>
<p class="MsoNormal"><span lang="EN-US"> return -1;</span></p>
<p class="MsoNormal"><span lang="EN-US">-#ifdef CONFIG_X86_64</span></p>
<p class="MsoNormal"><span lang="EN-US">- return cpu_data(first_cpu_of_numa_node).apicid;</span></p>
<p class="MsoNormal"><span lang="EN-US">-#else</span></p>
<p class="MsoNormal"><span lang="EN-US">- return first_cpu_of_numa_node;</span></p>
<p class="MsoNormal"><span lang="EN-US">-#endif</span></p>
<p class="MsoNormal"><span lang="EN-US">+ return cpu_physical_id(first_cpu_of_numa_node);</span></p>
<p class="MsoNormal"><span lang="EN-US">}</span></p>
<p class="MsoNormal"><span lang="EN-US">/* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor</span></p>
<p class="MsoNormal"><span lang="EN-US">--</span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Or is logical cpu id enough to do the work, with some cosmetic applied to the
</span></p>
<p class="MsoNormal"><span lang="EN-US">function names(not included in the following simple diff yet)?</span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">thanks</span></p>
<p class="MsoNormal"><span lang="EN-US">Hillf</span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">--- linux-5.1-rc4/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 07:55:56.611685400 +0800</span></p>
<p class="MsoNormal"><span lang="EN-US">+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 2019-04-16 09:18:24.546578400 +0800</span></p>
<p class="MsoNormal"><span lang="EN-US">@@ -1405,11 +1405,7 @@ static int kfd_cpumask_to_apic_id(const</span></p>
<p class="MsoNormal"><span lang="EN-US"> first_cpu_of_numa_node = cpumask_first(cpumask);</span></p>
<p class="MsoNormal"><span lang="EN-US"> if (first_cpu_of_numa_node >= nr_cpu_ids)</span></p>
<p class="MsoNormal"><span lang="EN-US"> return -1;</span></p>
<p class="MsoNormal"><span lang="EN-US">-#ifdef CONFIG_X86_64</span></p>
<p class="MsoNormal"><span lang="EN-US">- return cpu_data(first_cpu_of_numa_node).apicid;</span></p>
<p class="MsoNormal"><span lang="EN-US">-#else</span></p>
<p class="MsoNormal"><span lang="EN-US"> return first_cpu_of_numa_node;</span></p>
<p class="MsoNormal"><span lang="EN-US">-#endif</span></p>
<p class="MsoNormal"><span lang="EN-US">}</span></p>
<p class="MsoNormal"><span lang="EN-US">/* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor</span></p>
<p class="MsoNormal"><span lang="EN-US">--</span><span style="font-size:12.0pt" lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</blockquote>
</body>
</html>