qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Salil Mehta via <qemu-devel@nongnu.org>
To: Igor Mammedov <imammedo@redhat.com>,
	Salil Mehta <salil.mehta@opnsrc.net>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"maz@kernel.org" <maz@kernel.org>,
	"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	"lpieralisi@kernel.org" <lpieralisi@kernel.org>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"richard.henderson@linaro.org" <richard.henderson@linaro.org>,
	"andrew.jones@linux.dev" <andrew.jones@linux.dev>,
	"david@redhat.com" <david@redhat.com>,
	"philmd@linaro.org" <philmd@linaro.org>,
	"eric.auger@redhat.com" <eric.auger@redhat.com>,
	"oliver.upton@linux.dev" <oliver.upton@linux.dev>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"mst@redhat.com" <mst@redhat.com>,
	"will@kernel.org" <will@kernel.org>,
	"gshan@redhat.com" <gshan@redhat.com>,
	"rafael@kernel.org" <rafael@kernel.org>,
	"alex.bennee@linaro.org" <alex.bennee@linaro.org>,
	"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
	"darren@os.amperecomputing.com" <darren@os.amperecomputing.com>,
	"ilkka@os.amperecomputing.com" <ilkka@os.amperecomputing.com>,
	"vishnu@os.amperecomputing.com" <vishnu@os.amperecomputing.com>,
	"karl.heubaum@oracle.com" <karl.heubaum@oracle.com>,
	"miguel.luis@oracle.com" <miguel.luis@oracle.com>,
	 zhukeqian <zhukeqian1@huawei.com>,
	"wangxiongfeng (C)" <wangxiongfeng2@huawei.com>,
	"wangyanan (Y)" <wangyanan55@huawei.com>,
	"jiakernel2@gmail.com" <jiakernel2@gmail.com>,
	"maobibo@loongson.cn" <maobibo@loongson.cn>,
	"lixianglai@loongson.cn" <lixianglai@loongson.cn>,
	"npiggin@gmail.com" <npiggin@gmail.com>,
	"harshpb@linux.ibm.com" <harshpb@linux.ibm.com>,
	Linuxarm <linuxarm@huawei.com>,
	"peterx@redhat.com" <peterx@redhat.com>
Subject: RE: [PATCH V15 0/7] Add architecture agnostic code to support vCPU Hotplug
Date: Tue, 16 Jul 2024 11:43:00 +0000	[thread overview]
Message-ID: <b8ec039d53534d48b8389aedd1f959f6@huawei.com> (raw)
In-Reply-To: <20240716115210.08ca24ba@imammedo.users.ipa.redhat.com>

Hi Igor,

>  From: Igor Mammedov <imammedo@redhat.com>
>  Sent: Tuesday, July 16, 2024 10:52 AM
>  To: Salil Mehta <salil.mehta@opnsrc.net>
>  
>  On Tue, 16 Jul 2024 03:38:29 +0000
>  Salil Mehta <salil.mehta@opnsrc.net> wrote:
>  
>  > Hi Igor,
>  >
>  > On 15/07/2024 15:11, Igor Mammedov wrote:
>  > > On Mon, 15 Jul 2024 14:19:12 +0000
>  > > Salil Mehta <salil.mehta@huawei.com> wrote:
>  > >
>  > >>>   From: qemu-arm-bounces+salil.mehta=huawei.com@nongnu.org  <qemu-
>  > >>>   arm-bounces+salil.mehta=huawei.com@nongnu.org> On Behalf Of  Salil
>  > >>>   Mehta via
>  > >>>   Sent: Monday, July 15, 2024 3:14 PM
>  > >>>   To: Igor Mammedov <imammedo@redhat.com>
>  > >>>
>  > >>>   Hi Igor,
>  > >>>
>  > >>>   >  From: Igor Mammedov <imammedo@redhat.com>
>  > >>>   >  Sent: Monday, July 15, 2024 2:55 PM
>  > >>>   >  To: Salil Mehta <salil.mehta@huawei.com>
>  > >>>   >
>  > >>>   >  On Sat, 13 Jul 2024 19:25:09 +0100
>  > >>>   >  Salil Mehta <salil.mehta@huawei.com> wrote:
>  > >>>   >
>  > >>>   >  > [Note: References are present at the last after the revision
>  > >>>   > history]  >  > Virtual CPU hotplug support is being added across
>  > >>>   > various architectures  [1][3].
>  > >>>   >  > This series adds various code bits common across all architectures:
>  > >>>   >  >
>  > >>>   >  > 1. vCPU creation and Parking code refactor [Patch 1] 2. Update ACPI
>  > >>>   > > GED framework to support vCPU Hotplug [Patch 2,3] 3. ACPI CPUs AML
>  > >>>   > > code change [Patch 4,5] 4. Helper functions to support unrealization
>  > >>>   > > of CPU objects [Patch 6,7]
>  > >>>   >
>  > >>>   >  with patch 1 and 3 fixed should be good to go.
>  > >>>   >
>  > >>>   >  Salil,
>  > >>>   >  Can you remind me what happened to migration part of this?
>  > >>>   >  Ideally it should be a part of of this series as it should be common
>  > >>>   > for  everything that uses GED and should be a conditional part of
>  > >>>   > GED's  VMSTATE.
>  > >>>   >
>  > >>>   >  If this series is just a common base and no actual hotplug on top of
>  > >>>   > it is  merged in this release (provided patch 13 is fixed), I'm fine
>  > >>>   > with migration  bits being a separate series on top.
>  > >>>   >
>  > >>>   >  However if some machine would be introducing cpu hotplug in the same
>  > >>>   > release, then the migration part should be merged before it or be a
>  > >>>   > part  that cpu hotplug series.
>  > >>>
>  > >>>   We have tested Live/Pseudo Migration and it seem to work with the
>  > >>>   changes part of the architecture specific patch-set.
>  > >
>  > > have you tested, migration from new QEMU to an older one (that doesn't have cpuhotplug builtin)?
>  >
>  >
>  > Just curious, how can we detect at source Qemu what version of the
>  > Qemu destination is running. We require some sort of compatibility
>  > check but then this is a problem not specific to CPU Hotplug?
>  
>  it's usually managed by version machine types + compat settings for
>  machine/device.

Ok. it looks to be a static checking at the source. I'm sure there must be
a way to dynamically do the same by negotiating the features i.e. only
enabling the common subset at the destination. I quickly skimmed the
migration code and I cannot find any thing like this being done as of now.
And this problem looks to be a pandoras box to me. 

>  
>  > We  are not initializing CPU Hotplug VMSD in this patch-set. I was
>  > wondering then how can a new machine attempt to migrate VMSD state
>  > from new Qemu to older Qemu.
>  
>  If I'm not mistaken without VMSD it shouldn't explode, since CPUHP code
>  shouldn't create memory-regions that are migrated.
>  (If I recall correctly, mmio regions aren't going into migration stream)

Correct.

>  
>  > ARM vCPU Hotplug patches will be on top of this later in next Qemu cycle.
>  then it's fine to introduce VMSD later on, just make sure others who adding
>  cpu hotplug elsewhere also aware of it and pickup the same patch.


Yes, thanks.


>  > >>>
>  > >>>   Ampere: https://lore.kernel.org/all/e17e28ac-28c7-496f-b212-
>  > >>>   2c9b552dbf63@amperemail.onmicrosoft.com/
>  > >>>   Oracle: https://lore.kernel.org/all/46D74D30-EE54-4AD2-8F0E-
>  > >>>   BA5627FAA63E@oracle.com/
>  > >>>
>  > >>>
>  > >>>   For ARM, please check below patch part of RFC V3 for changes related to
>  > >>>   migration:
>  > >>>   https://lore.kernel.org/qemu-devel/20240613233639.202896-15-
>  > >>>   salil.mehta@huawei.com/
>  > >>
>  > >>
>  > >> Do you wish to move below change into this path-set and make it
>  > >> common to all instead?
>  > >
>  > > it would be the best to include this with here.
>  > >
>  > >>
>  > >>
>  > >> diff --git a/hw/acpi/generic_event_device.c
>  > >> b/hw/acpi/generic_event_device.c index 63226b0040..e92ce07955
>  > >> 100644
>  > >> --- a/hw/acpi/generic_event_device.c
>  > >> +++ b/hw/acpi/generic_event_device.c
>  > >> @@ -333,6 +333,16 @@ static const VMStateDescription
>  vmstate_memhp_state = {
>  > >>       }
>  > >>   };
>  > >>
>  > >> +static const VMStateDescription vmstate_cpuhp_state = {
>  > >> +    .name = "acpi-ged/cpuhp",
>  > >> +    .version_id = 1,
>  > >> +    .minimum_version_id = 1,
>  > >> +    .fields      = (VMStateField[]) {
>  > >> +        VMSTATE_CPU_HOTPLUG(cpuhp_state, AcpiGedState),
>  > >> +        VMSTATE_END_OF_LIST()
>  > >> +    }
>  > >> +};
>  > >> +
>  > >>   static const VMStateDescription vmstate_ged_state = {
>  > >>       .name = "acpi-ged-state",
>  > >>       .version_id = 1,
>  > >> @@ -381,6 +391,7 @@ static const VMStateDescription
>  vmstate_acpi_ged = {
>  > >>       },
>  > >>       .subsections = (const VMStateDescription * const []) {
>  > >>           &vmstate_memhp_state,
>  > >> +        &vmstate_cpuhp_state,
>  > >
>  > > I'm not migration guru but I believe this should be conditional to
>  > > avoid breaking cross-version migration.
>  > > See 679dd1a957d '.needed = vmstate_test_use_cpuhp. part
>  >
>  >
>  > Sure, thanks for this. As I can see, the needed() function is used at
>  > the source to decide if the state corresponding to a particular device
>  > can be forwarded to the destination QEMU/VM. But how can this be used
>  > to check for cross-version migration?
>  
>  what I'd do is to make sure that older machine types to not have cpu
>  hotplug enabled in supported events, and only machine that has full
>  support for hotplug enabled the bit. And then machine_init depending on
>  that would manage actual 'ged-event'
>  property.
>  
>  Then later VMSD.needed would check ged-event to decide if section should
>  be used or omitted.

I understand this part, as discussed above this is not relevant to this patch-set
as we are not adding CPU Hotplug specific VMSD. But yes, I take your point and
will add above suggested change in the following patches in the next Qemu Cycle.


>  > BTW, I've prepared V16. May I request a quick peek at:
>  >
>  > https://github.com/salil-mehta/qemu/commits/virt-cpuhp-armv8/rfc-
>  v3.ar
>  > ch.agnostic.v16/
>  
>  looked at
>     hw/acpi: Update ACPI GED framework to support vCPU Hotplug
>  
>  I get that ged_event loop in realize was copy-pasted from _EVT handler, but
>  that looks a bit complicated (though I won't object, it's matter of taste)

Yes, I did that intentionally to increase the code reuse which usually is encouraged.
This reduces the amount of re-testing required. But yes, there is a con side as
well to this approach if not done properly i.e. any issues in the older code also
get propagated in the newer code.

Generally we bank upon FFS function to get the next bit and use bit shifting to
deal with this kind of logic efficiently. 

>  
>  I'd prefer simpler condition than for() {} loop, and just use simpler 'if'
>  
>  if (enabled_events & ACPI_GED_CPU_HOTPLUG_EVT) {
>      init cpu hp code
>  }
>  
>  PS:
>  if you keep for loop, I'd replace  error_report() + abort() with 'error_abort'

Maybe I should have looked a this earlier. I've  missed to address this in V16.
Do you mean error_setg(&error_abort,....) kind of logic? it has been discouraged
in favor of assert() I think?

Can we live with this for now or do you want me to send V17 for this change?


Thanks
Salil.


  reply	other threads:[~2024-07-16 11:44 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-13 18:25 [PATCH V15 0/7] Add architecture agnostic code to support vCPU Hotplug Salil Mehta via
2024-07-13 18:25 ` [PATCH V15 1/7] accel/kvm: Extract common KVM vCPU {creation, parking} code Salil Mehta via
2024-07-15 12:49   ` [PATCH V15 1/7] accel/kvm: Extract common KVM vCPU {creation,parking} code Igor Mammedov
2024-07-15 13:28     ` Igor Mammedov
2024-07-15 13:57       ` Salil Mehta via
2024-07-13 18:25 ` [PATCH V15 2/7] hw/acpi: Move CPU ctrl-dev MMIO region len macro to common header file Salil Mehta via
2024-07-15 12:50   ` Igor Mammedov
2024-07-13 18:25 ` [PATCH V15 3/7] hw/acpi: Update ACPI GED framework to support vCPU Hotplug Salil Mehta via
2024-07-15 13:12   ` Igor Mammedov
2024-07-15 13:55     ` Salil Mehta via
2024-07-13 18:25 ` [PATCH V15 4/7] hw/acpi: Update GED _EVT method AML with CPU scan Salil Mehta via
2024-07-15 12:55   ` Igor Mammedov
2024-07-13 18:25 ` [PATCH V15 5/7] hw/acpi: Update CPUs AML with cpu-(ctrl)dev change Salil Mehta via
2024-07-15 13:39   ` Igor Mammedov
2024-07-13 18:25 ` [PATCH V15 6/7] physmem: Add helper function to destroy CPU AddressSpace Salil Mehta via
2024-07-13 18:25 ` [PATCH V15 7/7] gdbstub: Add helper function to unregister GDB register space Salil Mehta via
2024-07-15 13:40   ` Igor Mammedov
2024-07-15  6:11 ` [PATCH V15 0/7] Add architecture agnostic code to support vCPU Hotplug Zhao Liu
2024-07-15  8:45   ` Salil Mehta via
2024-07-15 11:03 ` Vishnu Pajjuri
2024-07-15 11:07   ` Salil Mehta
2024-07-15 11:13 ` Michael S. Tsirkin
2024-07-15 11:27   ` Salil Mehta via
2024-07-15 11:33     ` Michael S. Tsirkin
2024-07-15 11:35       ` Salil Mehta via
2024-07-15 13:55     ` Igor Mammedov
2024-07-15 11:14 ` Salil Mehta via
2024-07-15 13:54 ` Igor Mammedov
2024-07-15 14:14   ` Salil Mehta via
2024-07-15 14:19     ` Salil Mehta via
2024-07-15 15:11       ` Igor Mammedov
2024-07-16  3:38         ` Salil Mehta
2024-07-16  9:52           ` Igor Mammedov
2024-07-16 11:43             ` Salil Mehta via [this message]
2024-07-16 15:21               ` Igor Mammedov

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=b8ec039d53534d48b8389aedd1f959f6@huawei.com \
    --to=qemu-devel@nongnu.org \
    --cc=alex.bennee@linaro.org \
    --cc=andrew.jones@linux.dev \
    --cc=darren@os.amperecomputing.com \
    --cc=david@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=gshan@redhat.com \
    --cc=harshpb@linux.ibm.com \
    --cc=ilkka@os.amperecomputing.com \
    --cc=imammedo@redhat.com \
    --cc=jean-philippe@linaro.org \
    --cc=jiakernel2@gmail.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=karl.heubaum@oracle.com \
    --cc=linux@armlinux.org.uk \
    --cc=linuxarm@huawei.com \
    --cc=lixianglai@loongson.cn \
    --cc=lpieralisi@kernel.org \
    --cc=maobibo@loongson.cn \
    --cc=maz@kernel.org \
    --cc=miguel.luis@oracle.com \
    --cc=mst@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=rafael@kernel.org \
    --cc=richard.henderson@linaro.org \
    --cc=salil.mehta@huawei.com \
    --cc=salil.mehta@opnsrc.net \
    --cc=vishnu@os.amperecomputing.com \
    --cc=wangxiongfeng2@huawei.com \
    --cc=wangyanan55@huawei.com \
    --cc=will@kernel.org \
    --cc=zhukeqian1@huawei.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).