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

Re: [PATCH v3] xen/arm: Fix sibling mask setup to only include online CPUs


  • To: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Thu, 26 Nov 2026 10:23:55 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=valinux.co.jp 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=arcselector10001; 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=D3g3Gp7BxPOcXA7SVg0zjOOfyI1U03rv7zyB3iD6oXE=; b=vcAUGD2//QKXgIJcf2vShq3J7yhj+0F96RI4vP7jV7bnKQ7Ul63BocWiGjgj3Pu6Zji5OLEeXnTlSrFF7xZog6Se26yDT9M065KZ8v3zf+J+gSWtOiu2VKbxu23fGTRiBQ9/Qt5fWARQgvbZ6u/UE+v6EK2ZXrBJr8kaMJLmkIinRPIQSFd7uZbWNMNYPMk7GLPQNp4GLhpuIA0z737XvXbf9MazP5Y1v2JgUKyaEiGC3tLI1hT4auWfGebZiv423PwpocvuBzXyyCVYVKBNswvKHVusitwpq4zNni9muOybKCGZEdPwgP4XdqY+hHNaM3bOauXj1bl07SdCQZA4MQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MRWXoCHlp58YhMTd6fM1zYP6plkLs5ACkzxwC8Cc9c8/CIPQNmGAC7jz7N17ZihwoG+IEkzPEOzcSQOYs3yLJi3Bx20DrBJo3FdJPV5Du8dKpkXZfVK+jlpXqQl4G0qDCSg75p8EFjhSbtsViXCvNhXI4WU87fgvy6uOecB43WnAHXnyNoO4+3ncGiQt5jg0bYzxeGGUzD8CcA+t89DAnVLYp82b+xJFLsi6Kk40gaNcj3MTWukjuxtRJqS1cY4CUrjkP9w263Z2BQi5gT3wxgwz4eSnhSBcqqfgTNot2HSzQm3xYAHq7pM552wKJC0eFIz/lBDL+IdtkcBIyVQfPw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: <jbeulich@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Thu, 26 Nov 2026 09:25:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 26-Nov-26 05:43, Hirokazu Takahashi wrote:
> Populate the CPU sibling map only with CPUs that are brought
> online. Currently, all CPUs in cpu_possible_map are added,
> which leaves CPUs that failed to boot in the sibling masks and
> may lead the scheduler to make incorrect decisions.
Please mention the removal part as well which you added in this revision.

> 
> Fixes: 701190abb3d5 ("xen/arm: Set correct per-cpu cpu_core_mask")
> Signed-off-by: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
> ---
> Changes in v3:
> - Remove the CPU from sibling maps when it goes down, introducing
>   remove_siblinginfo() to match x86 Xen.
> - Change the cpu parameter type of set_cpu_sibling_map() to
>   'unsigned int' to align with x86 Xen. Also use 'unsigned int'
>   for the cpu parameters of remove_siblinginfo() and
>   remove_cpu_sibling_map().
> - Minor code cleanups.
> 
> Changes in v2:
> - Rename init_cpu_sibling_map() to set_cpu_sibling_map() to align
>   with x86.
> - Use BUG_ON() in set_cpu_sibling_map() to verify that per-cpu
>   cpu_sibling_mask and cpu_core_mask are allocated.
> 
>  xen/arch/arm/smpboot.c | 39 +++++++++++++++++++++++++++++++++++----
>  1 file changed, 35 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> index 8c9072f3c1..c4c9f535e3 100644
> --- a/xen/arch/arm/smpboot.c
> +++ b/xen/arch/arm/smpboot.c
> @@ -91,18 +91,44 @@ static int setup_cpu_sibling_map(int cpu)
>           !zalloc_cpumask_var(&per_cpu(cpu_core_mask, cpu)) )
>          return -ENOMEM;
>  
> +    return 0;
> +}
> +
> +static void set_cpu_sibling_map(unsigned int cpu)
> +{
> +    unsigned int sibling;
> +
> +    BUG_ON(!per_cpu(cpu_sibling_mask, cpu));
> +    BUG_ON(!per_cpu(cpu_core_mask, cpu));
> +
>      /*
>       * Currently we assume there is no multithread and NUMA, so
> -     * a CPU is a sibling with itself, and the all possible CPUs
> +     * a CPU is a sibling with itself, and the all online CPUs
>       * are supposed to belong to the same socket (NUMA node).
>       */
>      cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu));
> -    cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map);
> +    cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_online_map);
> +    cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, cpu));
>  
> -    return 0;
> +    for_each_online_cpu(sibling)
> +        cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, sibling));
>  }
>  
> -static void remove_cpu_sibling_map(int cpu)
> +static void remove_siblinginfo(unsigned int cpu)
> +{
> +    unsigned int sibling;
> +
> +    for_each_cpu(sibling, per_cpu(cpu_core_mask, cpu))
> +        cpumask_clear_cpu(cpu, per_cpu(cpu_core_mask, sibling));
> +
> +    for_each_cpu(sibling, per_cpu(cpu_sibling_mask, cpu))
> +        cpumask_clear_cpu(cpu, per_cpu(cpu_sibling_mask, sibling));
On ARM a CPU is a sbiling with itself only, so this loop is redundant. Please 
drop.

> +
> +    cpumask_clear(per_cpu(cpu_sibling_mask, cpu));
> +    cpumask_clear(per_cpu(cpu_core_mask, cpu));
> +}
> +
> +static void remove_cpu_sibling_map(unsigned int cpu)
We try not to add unrelated changes to the patch that is meant to do something
else (here s/int/unsigned int/). If at all, it should be mentioned in the commit
msg.

With that:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

~Michal




 


Rackspace

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