qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: maobibo <maobibo@loongson.cn>
Cc: Zhao Liu <zhao1.liu@intel.com>, 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>
Subject: Re: [PATCH v2 2/4] hw/loongarch/virt: Implement cpu plug interface
Date: Wed, 6 Nov 2024 11:56:44 +0100	[thread overview]
Message-ID: <20241106115644.3c7458b9@imammedo.users.ipa.redhat.com> (raw)
In-Reply-To: <6e53ba79-041a-3294-3656-9f5d5c41ad19@loongson.cn>

On Wed, 30 Oct 2024 09:50:56 +0800
maobibo <maobibo@loongson.cn> wrote:

> Hi Zhao,
> 
> On 2024/10/29 下午9:37, Zhao Liu wrote:
> > (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.  
> Yes, I agree. This piece of code is for cold-plug CPUs which is added 
> during VM power-on stage, not hot-plugged cpu. For hot-plugged cpu, 
> value of cpu->phy_id is UNSET_PHY_ID.
> 
> Topology-id (socket-id/core-id/thread-id) is not set for cold-plug CPUs.
> For cold-plug CPUs topology-id is calculated from archid.

that's basically copying what x86 does.

When possible_cpus are initialized, it has all topo info.
So instead of copying bad example of acpid_id, I'd suggest
in a loop that creates cold-plugged cpus, fetch topo ids
from possible_cpus[] and set them instead of phy_id.

> 
> Regards
> Bibo
> 
> > 
> >  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-11-06 10:57 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
2024-10-30  1:50     ` maobibo
2024-11-06 10:56       ` Igor Mammedov [this message]
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=20241106115644.3c7458b9@imammedo.users.ipa.redhat.com \
    --to=imammedo@redhat.com \
    --cc=gaosong@loongson.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=lixianglai@loongson.cn \
    --cc=maobibo@loongson.cn \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhao1.liu@intel.com \
    /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).