Received: by 2002:ac2:5937:0:0:0:0:0 with SMTP id v23csp1761064lfi; Thu, 26 Mar 2020 04:15:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv7Fy1bVMFvpvUhOYCG+qKHuAjCvMXAEFYrfgBtMUtMBSuR+nHWiBYPsWUhfvADpkdJdaO+ X-Received: by 2002:ac8:2c33:: with SMTP id d48mr3017468qta.323.1585221308292; Thu, 26 Mar 2020 04:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585221308; cv=none; d=google.com; s=arc-20160816; b=rkXhlcNge5h46XazhwDcxMi513W/Zbt9uBC/Ekpt/0gxChSWU1fM1+RT9PLoZsQvPj VA1IccFd5gA0pH1WVXOX4eTAXsT4J4x0GeN8osKOCyliDhDCeZw4Y1UeI6LfmYSDrOtY k4/DYki4LXpuADjV54/DEiX2w73vfmWPnfQ5YPYLTNtLdN0AQZON8PojA/No+mzr+rA9 I3RgAyb8Nj92x05JJ/U9LkgvpG4/mDm1/JxP2iiE6oy604mJPgDMf126QJEQ8byctl2h vgpMixn67Xhy0AawlUgTBWITNZxAqLfgx7sQZyPB5lP1UCJqvdd8vFQHV62wyHuL3V7w 32gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:to:from; bh=FJlmf71GbDzqSr16f7VMQp8xhNDuIO9JRXD/qsNeFqQ=; b=Nu2VhN8scUQHP7Lwkwyjasub5NimJKyG/xDLUatym8YKoFA4JXnKQIz6IONGlKhRBn RnAgvL2mcDhr+NVnFhNGKCK2wjoE0htwpvVHTxOiDbbwQTO3ZgOx7N77oVeXMNAO11mP Y3ZIyHnwi2iS6jBkXWXeoCEVSzqHf87lsrKxYIQQlS6jqk+TOfw/5GbJTmLM/9P014Gw sjU//OT1mac768OkYlGyPu5Vm1B5oLPoFreeWxv+u1r9vsDLKBvOYOnlHFJ4s54S2QcL 1Lqfb5N5FIvBDouASi1BIUm7N4GubNqsvWxoB/u995uJIZ+MewjoFblxjzqlDHNxp0y4 1TNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n10si1018828qvl.148.2020.03.26.04.15.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Mar 2020 04:15:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1]:49484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHQTb-0007WI-OA for alex.bennee@linaro.org; Thu, 26 Mar 2020 07:15:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60185) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHQTU-0007Vc-AG for qemu-arm@nongnu.org; Thu, 26 Mar 2020 07:15:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHQTS-0006FC-Bu for qemu-arm@nongnu.org; Thu, 26 Mar 2020 07:15:00 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2087 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jHQTS-0006DT-2U; Thu, 26 Mar 2020 07:14:58 -0400 Received: from lhreml703-cah.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id A715B721B8505ED14D4A; Thu, 26 Mar 2020 11:14:54 +0000 (GMT) Received: from lhreml701-chm.china.huawei.com (10.201.108.50) by lhreml703-cah.china.huawei.com (10.201.108.44) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 26 Mar 2020 11:14:53 +0000 Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by lhreml701-chm.china.huawei.com (10.201.108.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 26 Mar 2020 11:14:54 +0000 Received: from lhreml710-chm.china.huawei.com ([169.254.81.184]) by lhreml710-chm.china.huawei.com ([169.254.81.184]) with mapi id 15.01.1713.004; Thu, 26 Mar 2020 11:14:53 +0000 From: Shameerali Kolothum Thodi To: Auger Eric , "qemu-devel@nongnu.org" , "qemu-arm@nongnu.org" Subject: RE: [RFC v1] arm/virt: Add memory hot remove support Thread-Topic: [RFC v1] arm/virt: Add memory hot remove support Thread-Index: AQHV/SI7g2bnth2huEKfm213qjOT+KhawV2AgAAAwFA= Date: Thu, 26 Mar 2020 11:14:53 +0000 Message-ID: <246eb04443e342749ed91533949a5e67@huawei.com> References: <20200318123722.19736-1-shameerali.kolothum.thodi@huawei.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.47.92.97] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 185.176.76.210 X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "peter.maydell@linaro.org" , "xuwei \(O\)" , "mst@redhat.com" , Anshuman Khandual , Linuxarm , "Zengtao \(B\)" , "imammedo@redhat.com" Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: ctRM0OQ5JcPb Hi Eric, > -----Original Message----- > From: Auger Eric [mailto:eric.auger@redhat.com] > Sent: 26 March 2020 11:01 > To: Shameerali Kolothum Thodi ; > qemu-devel@nongnu.org; qemu-arm@nongnu.org > Cc: imammedo@redhat.com; peter.maydell@linaro.org; mst@redhat.com; > xuwei (O) ; Zengtao (B) ; > Linuxarm ; Anshuman Khandual > > Subject: Re: [RFC v1] arm/virt: Add memory hot remove support >=20 > Hi Shameer, >=20 > On 3/18/20 1:37 PM, Shameer Kolothum wrote: > > This adds support for memory hot remove on arm/virt that > > uses acpi ged device. >=20 > I gave this a try and it works fine if the PCDIMM slot was initially > hotplugged: > (QEMU) object-add qom-type=3Dmemory-backend-ram id=3Dmem1 > props.size=3D4294967296 > {"return": {}} > (QEMU) device_add driver=3Dpc-dimm id=3Dpcdimm1 memdev=3Dmem1 > (QEMU) device_del id=3Dpcdimm1 > {"return": {}} >=20 > on guest I can see: > [ 82.466321] Offlined Pages 262144 > [ 82.541712] Offlined Pages 262144 > [ 82.589236] Offlined Pages 262144 > [ 82.969166] Offlined Pages 262144 >=20 > However I noticed that if qemu is launched directly with >=20 > -m 16G,maxmem=3D32G,slots=3D2 \ > -object memory-backend-ram,id=3Dmem1,size=3D4G \ > -device pc-dimm,memdev=3Dmem1,id=3Ddimm1,driver=3Dpc-dimm -device >=20 > and then in the qmp shell: > (QEMU) device_del id=3Ddimm1 >=20 > the hot-unplug fails in guest: >=20 > [ 78.897407] Offlined Pages 262144 > [ 79.260811] Offlined Pages 262144 > [ 79.308105] Offlined Pages 262144 > [ 79.333675] page:fffffe00137d1f40 refcount:1 mapcount:0 > mapping:ffff0004ea9f20b1 index:0xaaab11c6e > [ 79.335927] anon flags: 0x17ffff8000080024(uptodate|active|swapbacked) > [ 79.337571] raw: 17ffff8000080024 dead000000000100 > dead000000000122 > ffff0004ea9f20b1 > [ 79.339502] raw: 0000000aaab11c6e 0000000000000000 00000001ffffffff > ffff0004fd4e3000 > [ 79.341701] page dumped because: unmovable page > [ 79.342887] page->mem_cgroup:ffff0004fd4e3000 > [ 79.354729] page:fffffe00137d1f40 refcount:1 mapcount:0 > mapping:ffff0004ea9f20b1 index:0xaaab11c6e > [ 79.357012] anon flags: 0x17ffff8000080024(uptodate|active|swapbacked) > [ 79.358658] raw: 17ffff8000080024 dead000000000100 > dead000000000122 > ffff0004ea9f20b1 > [ 79.360611] raw: 0000000aaab11c6e 0000000000000000 00000001ffffffff > ffff0004fd4e3000 > [ 79.362560] page dumped because: unmovable page > [ 79.363742] page->mem_cgroup:ffff0004fd4e3000 > [ 79.368636] memory memory20: Offline failed. >=20 > I did not expect this. The PCDIMM slot in that case does not seem to be > interpreted as a hot-unpluggable one (?). I added Anshuman in cc. Could you please try adding "movable_node" to qemu guest kernel command lin= e params. This will prevent any kernel allocation from hotplugable memory nodes which= I think is causing the behavior you are seeing. Thanks, Shameer > Thanks >=20 > Eric >=20 >=20 >=20 > > > > Signed-off-by: Shameer Kolothum > > --- > > -RFC because linux kernel support for mem hot remove is just queued > > for 5.7[1]. > > -Tested with guest kernel 5.6-rc5 + [1] > > > > 1. https://patchwork.kernel.org/cover/11419301/ > > --- > > hw/acpi/generic_event_device.c | 28 +++++++++++++++++ > > hw/arm/virt.c | 56 > ++++++++++++++++++++++++++++++++-- > > 2 files changed, 82 insertions(+), 2 deletions(-) > > > > diff --git a/hw/acpi/generic_event_device.c > b/hw/acpi/generic_event_device.c > > index 021ed2bf23..3e28c110fa 100644 > > --- a/hw/acpi/generic_event_device.c > > +++ b/hw/acpi/generic_event_device.c > > @@ -182,6 +182,32 @@ static void > acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, > > } > > } > > > > +static void acpi_ged_unplug_request_cb(HotplugHandler *hotplug_dev, > > + DeviceState *dev, Error > **errp) > > +{ > > + AcpiGedState *s =3D ACPI_GED(hotplug_dev); > > + > > + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { > > + acpi_memory_unplug_request_cb(hotplug_dev, > &s->memhp_state, dev, errp); > > + } else { > > + error_setg(errp, "acpi: device unplug request for unsupported > device" > > + " type: %s", object_get_typename(OBJECT(dev))); > > + } > > +} > > + > > +static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev, > > + DeviceState *dev, Error **errp) > > +{ > > + AcpiGedState *s =3D ACPI_GED(hotplug_dev); > > + > > + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { > > + acpi_memory_unplug_cb(&s->memhp_state, dev, errp); > > + } else { > > + error_setg(errp, "acpi: device unplug for unsupported device" > > + " type: %s", object_get_typename(OBJECT(dev))); > > + } > > +} > > + > > static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBit= s > ev) > > { > > AcpiGedState *s =3D ACPI_GED(adev); > > @@ -286,6 +312,8 @@ static void acpi_ged_class_init(ObjectClass *class, > void *data) > > dc->vmsd =3D &vmstate_acpi_ged; > > > > hc->plug =3D acpi_ged_device_plug_cb; > > + hc->unplug_request =3D acpi_ged_unplug_request_cb; > > + hc->unplug =3D acpi_ged_unplug_cb; > > > > adevc->send_event =3D acpi_ged_send_event; > > } > > diff --git a/hw/arm/virt.c b/hw/arm/virt.c > > index 94f93dda54..91974e4e80 100644 > > --- a/hw/arm/virt.c > > +++ b/hw/arm/virt.c > > @@ -2096,11 +2096,62 @@ static void > virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, > > } > > } > > > > +static void virt_dimm_unplug_request(HotplugHandler *hotplug_dev, > > + DeviceState *dev, Error > **errp) > > +{ > > + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); > > + Error *local_err =3D NULL; > > + > > + if (!vms->acpi_dev) { > > + error_setg(errp, > > + "memory hotplug is not enabled: missing acpi-ged > device"); > > + goto out; > > + } > > + > > + hotplug_handler_unplug_request(HOTPLUG_HANDLER(vms->acpi_dev), > dev, > > + &local_err); > > +out: > > + error_propagate(errp, local_err); > > +} > > + > > +static void virt_dimm_unplug(HotplugHandler *hotplug_dev, > > + DeviceState *dev, Error **errp) > > +{ > > + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); > > + Error *local_err =3D NULL; > > + > > + hotplug_handler_unplug(HOTPLUG_HANDLER(vms->acpi_dev), dev, > &local_err); > > + if (local_err) { > > + goto out; > > + } > > + > > + pc_dimm_unplug(PC_DIMM(dev), MACHINE(vms)); > > + object_property_set_bool(OBJECT(dev), false, "realized", NULL); > > + > > + out: > > + error_propagate(errp, local_err); > > +} > > + > > static void virt_machine_device_unplug_request_cb(HotplugHandler > *hotplug_dev, > > DeviceState *dev, Error > **errp) > > { > > - error_setg(errp, "device unplug request for unsupported device" > > - " type: %s", object_get_typename(OBJECT(dev))); > > + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { > > + virt_dimm_unplug_request(hotplug_dev, dev, errp); > > + } else { > > + error_setg(errp, "device unplug request for unsupported device= " > > + " type: %s", object_get_typename(OBJECT(dev))); > > + } > > +} > > + > > +static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev, > > + DeviceState *dev, Error > **errp) > > +{ > > + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { > > + virt_dimm_unplug(hotplug_dev, dev, errp); > > + } else { > > + error_setg(errp, "virt: device unplug for unsupported device" > > + " type: %s", object_get_typename(OBJECT(dev))); > > + } > > } > > > > static HotplugHandler *virt_machine_get_hotplug_handler(MachineState > *machine, > > @@ -2181,6 +2232,7 @@ static void virt_machine_class_init(ObjectClass > *oc, void *data) > > hc->pre_plug =3D virt_machine_device_pre_plug_cb; > > hc->plug =3D virt_machine_device_plug_cb; > > hc->unplug_request =3D virt_machine_device_unplug_request_cb; > > + hc->unplug =3D virt_machine_device_unplug_cb; > > mc->numa_mem_supported =3D true; > > mc->auto_enable_numa_with_memhp =3D true; > > mc->default_ram_id =3D "mach-virt.ram"; > >