From: Igor Mammedov <imammedo@redhat.com>
To: Gu Zheng <guz.fnst@cn.fujitsu.com>
Cc: chen.fan.fnst@cn.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com,
tangchen@cn.fujitsu.com, qemu-devel@nongnu.org, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 4/5] pc: add cpu hotplug handler to PC_MACHINE
Date: Mon, 15 Sep 2014 10:11:27 +0200 [thread overview]
Message-ID: <20140915101127.4d6af59f@nial.usersys.redhat.com> (raw)
In-Reply-To: <541663C4.2000307@cn.fujitsu.com>
On Mon, 15 Sep 2014 11:57:56 +0800
Gu Zheng <guz.fnst@cn.fujitsu.com> wrote:
> Hi Igor,
>
> On 09/12/2014 10:28 PM, Igor Mammedov wrote:
>
> > On Fri, 12 Sep 2014 11:02:09 +0800
> > Gu Zheng <guz.fnst@cn.fujitsu.com> wrote:
> >
> >> Hi Igor,
> >> On 09/10/2014 09:55 PM, Igor Mammedov wrote:
> >>
> >>> On Wed, 3 Sep 2014 17:06:16 +0800
> >>> Gu Zheng <guz.fnst@cn.fujitsu.com> wrote:
> >>>
> >>>> Add cpu hotplug handler to PC_MACHINE, which will perform the acpi
> >>>> cpu hotplug callback via hotplug_handler API.
> >>>>
> >>>> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> >>>> ---
> >>>> hw/i386/pc.c | 26 +++++++++++++++++++++++++-
> >>>> qom/cpu.c | 1 -
> >>>> 2 files changed, 25 insertions(+), 2 deletions(-)
> >>>>
> >>>> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> >>>> index 8fa8d2f..c2956f9 100644
> >>>> --- a/hw/i386/pc.c
> >>>> +++ b/hw/i386/pc.c
> >>>> @@ -1607,11 +1607,34 @@ out:
> >>>> error_propagate(errp, local_err);
> >>>> }
> >>>>
> >>>> +static void pc_cpu_plug(HotplugHandler *hotplug_dev,
> >>>> + DeviceState *dev, Error **errp)
> >>>> +{
> >>>> + HotplugHandlerClass *hhc;
> >>>> + Error *local_err = NULL;
> >>>> + PCMachineState *pcms = PC_MACHINE(hotplug_dev);
> >>>> +
> >>>> + if (dev->hotplugged) {
> >>> for startup CPUs we set gpe_cpu status bits in AcpiCpuHotplug_init()
> >>> and for hotpluged in AcpiCpuHotplug_add() which is duplicating
> >>> essentially the same code.
> >>>
> >>> Could you drop above check and make AcpiCpuHotplug_init() take care
> >>> about startup CPUs as well, keeping bit setting in one place.
> >>
> >> Yeah, with the above change, code will be more neat, but I think it is not
> >> a serious problem.:)
> >> And pcms->acpi_dev is set when PC hardware initialisation (e.g. pc_init1),
> >> for start up cpus, the plug handler is not valid, so the check is needed
> >> here to avoid trigger error by start cpu.
> >
> > then check for !pcms->acpi_dev and exit if it not set (i.e. as pc_dimm_plug() does)
> > since there isn't acpi hardware to update for startup CPUs either.
> >
> > may be something along this lines:
> >
> > if (!pcms->acpi_dev) {
> > if (dev->hotplugged) error_setg(&local_err, "CPU hotplug is not supported without ACPI");
> > goto out;
> > }
>
> This is more neat, thanks.
>
> >
> >>
> >>>
> >>>> + if (!pcms->acpi_dev) {
> >>>> + error_setg(&local_err,
> >>>> + "cpu hotplug is not enabled: missing acpi device");
> >>>> + goto out;
> >>>> + }
> >>>> +
> >>>> + hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);
> >>>> + hhc->plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err);
> >>>> +out:
> >>>> + error_propagate(errp, local_err);
> >>>> + }
> >>>> +}
> >>>> +
> >>>> static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
> >>>> DeviceState *dev, Error **errp)
> >>>> {
> >>>> if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> >>>> pc_dimm_plug(hotplug_dev, dev, errp);
> >>>> + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> >>>> + pc_cpu_plug(hotplug_dev, dev, errp);
> >>>> }
> >>>> }
> >>>>
> >>>> @@ -1620,7 +1643,8 @@ static HotplugHandler *pc_get_hotpug_handler(MachineState *machine,
> >>>> {
> >>>> PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
> >>>>
> >>>> - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> >>>> + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)
> >>>> + || object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> >>>> return HOTPLUG_HANDLER(machine);
> >>>> }
> >>>>
> >>>> diff --git a/qom/cpu.c b/qom/cpu.c
> >>>> index b32dd0a..af8e83f 100644
> >>>> --- a/qom/cpu.c
> >>>> +++ b/qom/cpu.c
> >>>> @@ -304,7 +304,6 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
> >>>> if (dev->hotplugged) {
> >>>> cpu_synchronize_post_init(cpu);
> >>>> notifier_list_notify(&cpu_added_notifiers, dev);
> >>>> - cpu_resume(cpu);
> >>>> }
> >>>> }
> >>>>
> >>>
> >>> I don't see what sets PCMachine as hotplug_handler for CPU,
> >>> maybe series is missing a patch?
> >>
> >> Previous memory hotplug has built the frame work, here just adding the case
> >> to handle CPU.
> > You still need to set hotplug handler for CPU device or ICCBus
> > grep for qbus_set_hotplug_handler()
>
> Current implementation is the same as bus-less device's (e.g. memory), via the
> machine's get_hotplug_handler method to discover a hotplug handler controller,
> and it works fine.
I'm sorry, I've forgot about default machine hotplug handler.
> Shall we still need to set hotplug handler ICCBus, which seems duplicated?
> Or switch to set hotplug handler to ICCBus, and drop current implementation?
Taking in account that we should access RTC device from handler,
machine's hotplug handler serves purpose just fine.
>
> Thanks,
> Gu
>
> >
> >>
> >> static void pc_machine_device_plug_cb(HotplugHandler *hotplug_dev,
> >> DeviceState *dev, Error **errp)
> >> {
> >> if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> >> pc_dimm_plug(hotplug_dev, dev, errp);
> >> + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
> >> + pc_cpu_plug(hotplug_dev, dev, errp);
> >> }
> >>
> >> Thanks,
> >> Gu
> >>
> >>>
> >>> .
> >>>
> >>
> >>
> >
> > .
> >
>
>
next prev parent reply other threads:[~2014-09-15 8:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 9:06 [Qemu-devel] [PATCH 0/5] cpu/acpi: convert cpu hot plug to hotplug_handler API Gu Zheng
2014-09-03 9:06 ` [Qemu-devel] [PATCH 1/5] acpi/cpu: add cpu hotplug callback function to match " Gu Zheng
2014-09-10 13:28 ` Igor Mammedov
2014-09-11 3:04 ` Gu Zheng
2014-09-11 10:12 ` Igor Mammedov
2014-09-12 1:39 ` Gu Zheng
2014-09-03 9:06 ` [Qemu-devel] [PATCH 2/5] acpi:ich9: convert cpu hotplug handle to " Gu Zheng
2014-09-03 9:06 ` [Qemu-devel] [PATCH 3/5] acpi:piix4: " Gu Zheng
2014-09-03 9:06 ` [Qemu-devel] [PATCH 4/5] pc: add cpu hotplug handler to PC_MACHINE Gu Zheng
2014-09-10 13:55 ` Igor Mammedov
2014-09-12 3:02 ` Gu Zheng
2014-09-12 14:28 ` Igor Mammedov
2014-09-15 3:57 ` Gu Zheng
2014-09-15 8:11 ` Igor Mammedov [this message]
2014-09-10 14:02 ` Igor Mammedov
2014-09-03 9:06 ` [Qemu-devel] [PATCH 5/5] cpu/hotplug: remove the left unused cpu hotplug notifier function Gu Zheng
2014-09-10 13:59 ` Igor Mammedov
2014-09-10 14:12 ` [Qemu-devel] [PATCH 0/5] cpu/acpi: convert cpu hot plug to hotplug_handler API Igor Mammedov
2014-09-11 2:53 ` Gu Zheng
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=20140915101127.4d6af59f@nial.usersys.redhat.com \
--to=imammedo@redhat.com \
--cc=afaerber@suse.de \
--cc=chen.fan.fnst@cn.fujitsu.com \
--cc=guz.fnst@cn.fujitsu.com \
--cc=isimatu.yasuaki@jp.fujitsu.com \
--cc=qemu-devel@nongnu.org \
--cc=tangchen@cn.fujitsu.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).