qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Zhao Liu <zhao1.liu@intel.com>
To: Bibo Mao <maobibo@loongson.cn>
Cc: Song Gao <gaosong@loongson.cn>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	qemu-devel@nongnu.org, Xianglai Li <lixianglai@loongson.cn>,
	Igor Mammedov <imammedo@redhat.com>
Subject: Re: [PATCH v2 2/4] hw/loongarch/virt: Implement cpu plug interface
Date: Tue, 29 Oct 2024 21:37:18 +0800	[thread overview]
Message-ID: <ZyDlDjkO8ewhiE/m@intel.com> (raw)
In-Reply-To: <20241029095335.2219343-3-maobibo@loongson.cn>

(CC Igor since I want to refer his comment on hotplug design.)

Hi Bibo,

I have some comments about your hotplug design.

[snip]

> +static void virt_cpu_pre_plug(HotplugHandler *hotplug_dev,
> +                              DeviceState *dev, Error **errp)
> +{
> +    LoongArchVirtMachineState *lvms = LOONGARCH_VIRT_MACHINE(hotplug_dev);
> +    MachineState *ms = MACHINE(OBJECT(hotplug_dev));
> +    LoongArchCPU *cpu = LOONGARCH_CPU(dev);
> +    CPUState *cs = CPU(dev);
> +    CPUArchId *cpu_slot;
> +    Error *local_err = NULL;
> +    LoongArchCPUTopo topo;
> +    int arch_id, index = 0;

[snip]

> +    if (cpu->phy_id == UNSET_PHY_ID) {
> +        error_setg(&local_err, "CPU hotplug not supported");
> +        goto out;
> +    } else {
> +        /*
> +         * For non hot-add cpu, topo property is not set. And only physical id
> +         * property is set, setup topo information from physical id.
> +         *
> +         * Supposing arch_id is equal to cpu slot index
> +         */
> +        arch_id = cpu->phy_id;
> +        virt_get_topo_from_index(ms, &topo, arch_id);
> +        cpu->socket_id = topo.socket_id;
> +        cpu->core_id   = topo.core_id;
> +        cpu->thread_id = topo.thread_id;
> +        cpu_slot = virt_find_cpu_slot(ms, arch_id, &index);
> +    }

It seems you want to use "phy_id" (instead of topology IDs as for now)
as the parameter to plug CPU. And IIUC in previous patch, "phy_id" is
essentially the CPU index.

Igor has previously commented [1] on ARM's hotplug design that the
current QEMU should use the topology-id (socket-id/core-id/thread-id) as
the parameters, not the CPU index or the x86-like apic id.

So I think his comment can apply on loongarch, too.

From my own understanding, the CPU index lacks topological intuition,
and the APIC ID for x86 is even worse, as its sometimes even
discontinuous. Requiring the user to specify topology ids would allow
for clearer localization to CPU slots.

[1]: https://lore.kernel.org/qemu-devel/20240812101556.1a395712@imammedo.users.ipa.redhat.com/

> +    /*
> +     * update cpu_index calculation method since it is easily used as index
> +     * with possible_cpus array by function virt_cpu_index_to_props
> +     */
> +    cs->cpu_index = index;
> +    numa_cpu_pre_plug(cpu_slot, dev, &local_err);
> +    return ;
> +
> +out:
> +    error_propagate(errp, local_err);
> +}
> +

Thanks,
Zhao




  reply	other threads:[~2024-10-29 13:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29  9:53 [PATCH v2 0/4] hw/loongarch/virt: Add cpu hotplug support Bibo Mao
2024-10-29  9:53 ` [PATCH v2 1/4] hw/loongarch/virt: Add CPU topology support Bibo Mao
2024-10-29 13:19   ` Zhao Liu
2024-10-30  1:42     ` maobibo
2024-11-06 10:42       ` Igor Mammedov
2024-11-06 10:41     ` Igor Mammedov
2024-11-07  2:13       ` maobibo
2024-11-18 15:21         ` Igor Mammedov
2024-11-07 14:00       ` Zhao Liu
2024-11-22 14:09         ` Igor Mammedov
2024-10-29  9:53 ` [PATCH v2 2/4] hw/loongarch/virt: Implement cpu plug interface Bibo Mao
2024-10-29 13:37   ` Zhao Liu [this message]
2024-10-30  1:50     ` maobibo
2024-11-06 10:56       ` Igor Mammedov
2024-11-07  2:18         ` maobibo
2024-10-29  9:53 ` [PATCH v2 3/4] hw/loongarch/virt: Update the ACPI table for hotplug cpu Bibo Mao
2024-10-29  9:53 ` [PATCH v2 4/4] hw/loongarch/virt: Enable cpu hotplug feature on virt machine Bibo Mao
2024-10-29 13:48   ` Zhao Liu
2024-10-30  1:55     ` maobibo
2024-10-30  2:18       ` Zhao Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZyDlDjkO8ewhiE/m@intel.com \
    --to=zhao1.liu@intel.com \
    --cc=gaosong@loongson.cn \
    --cc=imammedo@redhat.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=lixianglai@loongson.cn \
    --cc=maobibo@loongson.cn \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).