[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3] xen/arm: Set correct per-cpu cpu_core_mask


  • To: Henry Wang <xin.wang2@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 21 May 2024 09:47:29 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QjoqvSVRSR9NDC874BgKN3oOL36ifj5ne8qhLOku9b0=; b=WDmamD3eGbTsunOWAUY50qky5mj6LkScyEnE1NeHKeVkenJf6teF/GhlapztPkY5PusghhGhMu4KmBbG/6+LB3IwPJhpsNiLIjZjhXBAzSsJuYpJcQ8UPx9+8udlTN1K11+aHw9yXhF6aa3hV1zlpwaPIXd0n+l+qJxGF5A4BQ1oq5mLZXUwAlsIQvvK29FQtw5lB43ijmc8wW/btOexGBxC3nHppZew+ljyCOWbWR3cFpy2N/FIqPVuaEuDBXgGGgZoPYLSmgDpYOts1ZV3FZxXmKhOliQGXuRXwoNTA/d4gDWpNik4CKjPLZmEIGtWvxrcU3dGNv3yxVDoK2IBfw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gLkCHtDzi7q3Fg/04gX0NJR3rM0mVDa17etC8rugbRLtgwRIwDYKm7QRsp1Nqb3ic7tDF//+vvqjT9m54suYoJMshqAOJ7HTVE84C5urfoTgboWb7UY4bESnMjds9nFQw3ITUM7Z+Hh+jOWDx81QwOUyH8Fu8DnXNDaNuBrYjYVgAJScOwI/lTrYuKviktsHOEqMsZSnivlou1KcidJOLO2HEN3tufkoscUnqZ4rkGAquubxuFQ2+VsX2NyqXpsdyfKLl6TTeHUuNW0P13zCO7SsjKMfI12DdAQ+76xex0HDP2oY7O1N1bJEXkvRWg7cw9JRv0F4gYe6NUsDMg5oeg==
  • Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Tue, 21 May 2024 07:47:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Henry.

On 20/05/2024 04:57, Henry Wang wrote:
> Hi All,
> 
> Gentle ping since it has been a couple of months, any comments on this 
> updated patch? Thanks!
Sorry for the late reply.

> 
> Kind regards,
> Henry
> 
> On 3/21/2024 11:57 AM, Henry Wang wrote:
>> In the common sysctl command XEN_SYSCTL_physinfo, the value of
>> cores_per_socket is calculated based on the cpu_core_mask of CPU0.
>> Currently on Arm this is a fixed value 1 (can be checked via xl info),
>> which is not correct. This is because during the Arm CPU online
>> process at boot time, setup_cpu_sibling_map() only sets the per-cpu
>> cpu_core_mask for itself.
>>
>> cores_per_socket refers to the number of cores that belong to the same
>> socket (NUMA node). Currently Xen on Arm does not support physical
>> CPU hotplug and NUMA, also we assume there is no multithread. Therefore
>> cores_per_socket means all possible CPUs detected from the device
>> tree. Setting the per-cpu cpu_core_mask in setup_cpu_sibling_map()
>> accordingly. Modify the in-code comment which seems to be outdated. Add
>> a warning to users if Xen is running on processors with multithread
>> support.
>>
>> Signed-off-by: Henry Wang <Henry.Wang@xxxxxxx>
>> Signed-off-by: Henry Wang <xin.wang2@xxxxxxx>
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

>> ---
>> v3:
>> - Use cpumask_copy() to set cpu_core_mask and drop the unnecessary
>>    cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, cpu)).
>> - In-code comment adjustments.
>> - Add a warning for multithread.
>> v2:
>> - Do not do the multithread check.
>> ---
>>   xen/arch/arm/smpboot.c | 18 +++++++++++++++---
>>   1 file changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
>> index a84e706d77..b6268be27a 100644
>> --- a/xen/arch/arm/smpboot.c
>> +++ b/xen/arch/arm/smpboot.c
>> @@ -66,7 +66,11 @@ static bool cpu_is_dead;
>>   
>>   /* ID of the PCPU we're running on */
>>   DEFINE_PER_CPU(unsigned int, cpu_id);
>> -/* XXX these seem awfully x86ish... */
>> +/*
>> + * Although multithread is part of the Arm spec, there are not many
>> + * processors support multithread and current Xen on Arm assumes there
NIT: s/support/supporting

>> + * is no multithread.
>> + */
>>   /* representing HT siblings of each logical CPU */
>>   DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_mask);
>>   /* representing HT and core siblings of each logical CPU */
>> @@ -85,9 +89,13 @@ static int setup_cpu_sibling_map(int cpu)
>>            !zalloc_cpumask_var(&per_cpu(cpu_core_mask, cpu)) )
>>           return -ENOMEM;
>>   
>> -    /* A CPU is a sibling with itself and is always on its own core. */
>> +    /*
>> +     * Currently we assume there is no multithread and NUMA, so
>> +     * a CPU is a sibling with itself, and the all possible CPUs
>> +     * are supposed to belong to the same socket (NUMA node).
>> +     */
>>       cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu));
>> -    cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, cpu));
>> +    cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map);
>>   
>>       return 0;
>>   }
>> @@ -277,6 +285,10 @@ void __init smp_init_cpus(void)
>>           warning_add("WARNING: HMP COMPUTING HAS BEEN ENABLED.\n"
>>                       "It has implications on the security and stability of 
>> the system,\n"
>>                       "unless the cpu affinity of all domains is 
>> specified.\n");
>> +
>> +    if ( system_cpuinfo.mpidr.mt == 1 )
>> +        warning_add("WARNING: MULTITHREADING HAS BEEN DETECTED ON THE 
>> PROCESSOR.\n"
>> +                    "It might impact the security of the system.\n");
>>   }
>>   
>>   unsigned int __init smp_get_max_cpus(void)
> 

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.