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

RE: [PATCH v6 1/5] xen/device-tree: Parse 'cpu-map' node for CPU topology exploration


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Date: Sun, 19 Jul 2026 00:43:25 +0000
  • Accept-language: ja-JP, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none
  • 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=dgzu3Bu1pfNzbm6mkbFKGzLJhXgLyCskZC6X/tBOrFc=; b=lbqeUtbRhCMi2o3hKjavhIK83fDnvhYx4wjmJJHkv164PqQQz7o+/71ku/vu3FsfCkvF0TSzKoeLGfxbNR2g2IZTFfjRCvN6JLMpO+YVfRyiR3dKTnvTzbUZGYcHcY10j9eWe39x/KHLq3KADDUra12CA8lHF2QDl3Vg8E0y7hwGyiJRiUPGlfoFCo1G+3yHbqnrKFaKhQMpZkzCgym5Ftt8B05vBOra2d/O2UeA+N612E2ztMjHO65UgdmGkRUrn0o/pzqrnW6azxRj5rqBanLPYXXtwEfxTVGeygRRd+W6NaZW/hI4qp2kt1UexZsEHsPilwDRcXkovoh0n3h+4w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lzoQhx5hLVi4r7Qa5axnDaaaNO/Q/t1cah913Uosgz1sZe7eOfEN1uQuljlzGR/ahrth+hcvPELWhaSFWx8iX+6ZlWebGhbBJvdfCDJamIj6M1q8iXBcaucLy7E4aNVgxwURTJK7BFiCuYnxSSGIQFC9voIDF9A+vmqey8ubkl2X0h2FwUvhacNmsBst+MGcHqlUoapCygUdMcKVaSX/GfAmDxr14M+79dbFolGpJpEa8If8vco+bJwhKCtQkp9jKNZ8aAajfs+i9+0RD99fqJyn2LMoySD4Wy34qySY3YioXMDGCbFo0008K6KMQV7cR/ByGKsebQlm8WVTIFwq5Q==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp;
  • Cc: "Mykyta_Poturai@xxxxxxxx" <Mykyta_Poturai@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Sun, 19 Jul 2026 00:44:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdE33lRSerj/u3kU6sfibELhxcvrZwIjgAgAPc8jA=
  • Thread-topic: [PATCH v6 1/5] xen/device-tree: Parse 'cpu-map' node for CPU topology exploration

Hello,

> > --- a/xen/common/Kconfig
> > +++ b/xen/common/Kconfig
> > @@ -140,6 +140,9 @@ config HAS_EX_TABLE
> >  config HAS_FAST_MULTIPLY
> >     bool
> >
> > +config HAS_GENERIC_CPU_TOPOLOGY
> > +   bool
> 
> You've got indentation right here and ...
> 
> > @@ -191,6 +194,25 @@ config VM_EVENT
> >  config NEEDS_LIBELF
> >     bool
> >
> > +config GENERIC_CPU_TOPOLOGY
> > +   bool
> 
> ... here. Why not ...
> 
> > +config DT_CPU_TOPOLOGY
> > +    bool "Device tree based CPU topology support (UNSUPPORTED)" if 
> > UNSUPPORTED
> > +    depends on HAS_GENERIC_CPU_TOPOLOGY && DEVICE_TREE_PARSE
> > +    select GENERIC_CPU_TOPOLOGY
> > +    help
> > +      Retrieve CPU topology information from the device tree to optimize
> > +      virtual CPU scheduling.
> > +
> > +config ACPI_CPU_TOPOLOGY
> > +    bool "ACPI based CPU topology support (UNSUPPORTED)" if UNSUPPORTED
> > +    depends on HAS_GENERIC_CPU_TOPOLOGY && ACPI
> > +    select GENERIC_CPU_TOPOLOGY
> > +    help
> > +      Retrieve CPU topology information from the ACPI PPTT to optimize
> > +      virtual CPU scheduling.
> 
> ... throughout here?

I will fix it.

> I'm also a little puzzled by the "if UNSUPPORTED" on the prompts. Imo that
> would better be normal "depends on UNSUPPORTED". The situation is
> different

Okay, I will replace it with "depends on UNSUPPORTED"

> in e.g. common/sched/Kconfig, where the default value may be Y (with the
> prompt being invisible making it impossible to turn off the option).
> 
> Also may I suggest s/virtual CPU/vCPU/ ?

Okay.
 
> > --- /dev/null
> > +++ b/xen/common/cpu-topology.c
> > @@ -0,0 +1,65 @@
> > +/* SPDX-License-Identifier: GPL-2.0-or-later */
> > +
> > +#include <xen/acpi.h>
> > +#include <xen/cpu-topology.h>
> > +#include <xen/cpumask.h>
> > +#include <xen/dt-cpu-topology.h>
> > +#include <xen/init.h>
> > +
> > +static void __init free_topology_table(void)
> > +{
> > +    unsigned int cpu;
> > +
> > +    for ( cpu = 0; cpu < nr_cpu_ids; cpu++ )
> > +    {
> > +        free_cpumask_var(cpu_topology[cpu].thread_sibling);
> > +        free_cpumask_var(cpu_topology[cpu].core_sibling);
> > +        free_cpumask_var(cpu_topology[cpu].cluster_sibling);
> > +    }
> > +
> > +    XFREE(cpu_topology);
> 
> XVFREE(), as it wants to be ...
> 
> > +}
> > +
> > +void __init init_cpu_topology(void)
> > +{
> > +    unsigned int cpu;
> > +    int ret;
> > +
> > +    cpu_topology = xzalloc_array(struct cpu_topology, nr_cpu_ids);
> 
> --- xvzalloc_array() here.

Okay.

> > +    if ( !cpu_topology )
> > +    {
> > +        printk(XENLOG_ERR "Failed to allocate memory for cpu_topology 
> > table\n");
> 
> Is this really an error (irrespective of whether this then also needs
> logging)? There may not be any topology information to retrieve, in which
> case the allocation failure is benign.

Okay, I will remove this line.

> > +        return;
> > +    }
> > +
> > +    for ( cpu = 0; cpu < nr_cpu_ids; cpu++ )
> > +    {
> > +        if ( !zalloc_cpumask_var(&cpu_topology[cpu].thread_sibling) ||
> > +             !zalloc_cpumask_var(&cpu_topology[cpu].core_sibling) ||
> > +             !zalloc_cpumask_var(&cpu_topology[cpu].cluster_sibling) )
> > +        {
> > +            free_topology_table();
> > +            printk(XENLOG_ERR "Failed to allocate memory for cpu_topology 
> > table\n");
> 
> Same here then obviously. Also please respect line length constraints. Don't
> split format strings, but splitting XENLOG_* off the string literal is fine.

Okay.

> > +#ifdef CONFIG_GENERIC_CPU_TOPOLOGY
> > +struct cpu_topology;
> 
> Why would this be needed?

I will remove the line.

> > +struct cpu_topology *__ro_after_init cpu_topology;
> 
> This includes the same effect.

Okay.

> > +#define INVALID_TOPO_ID (~0U)
> > +
> > +struct cpu_map {
> > +    unsigned int thread_id;
> > +    unsigned int core_id;
> > +    unsigned int cluster_id;
> > +    unsigned int package_id;
> > +};
> > +
> > +static struct cpu_map __initdata cpu_map[NR_CPUS] = {
> > +    [0 ... NR_CPUS - 1] = {INVALID_TOPO_ID, INVALID_TOPO_ID,
> > +                           INVALID_TOPO_ID, INVALID_TOPO_ID}
> 
> I think it would be nice if this properly used designated initializers
> throughout. A trailing comma (twice) would also be nice.

I will replace it with:

static struct cpu_map __initdata cpu_map[NR_CPUS] = {
    [0 ... NR_CPUS - 1] = {
        .thread_id = INVALID_TOPO_ID,
        .core_id = INVALID_TOPO_ID,
        .cluster_id = INVALID_TOPO_ID,
        .package_id = INVALID_TOPO_ID,
    },
};

> > +static struct dt_device_node *__init dt_find_child_node_by_name(
> > +    const struct dt_device_node *dt,
> > +    const char *name)
> > +{
> > +    struct dt_device_node *np;
> 
> Is there a reason this cannot be pointer-to-const?

I will make it const.

> > --- a/xen/drivers/acpi/Makefile
> > +++ b/xen/drivers/acpi/Makefile
> > @@ -10,3 +10,4 @@ obj-$(CONFIG_PM_OP) += pm-op.o
> >
> >  obj-$(CONFIG_X86) += hwregs.o
> >  obj-$(CONFIG_X86) += reboot.o
> > +obj-$(CONFIG_ACPI_CPU_TOPOLOGY) += topology.init.o
> 
> As before, I'd prefer if this was appended to the earlier group of objects.

Okay.

Thank you,
Hirokazu Takahashi.

 


Rackspace

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