From patchwork Fri May 5 20:47:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 9714363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 304B660235 for ; Fri, 5 May 2017 20:52:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23D9D28678 for ; Fri, 5 May 2017 20:52:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1876628684; Fri, 5 May 2017 20:52:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B68CB28678 for ; Fri, 5 May 2017 20:52:35 +0000 (UTC) Received: from localhost ([::1]:48992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6kDL-0007ar-2G for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 May 2017 16:52:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6k9A-0004yX-4o for qemu-devel@nongnu.org; Fri, 05 May 2017 16:48:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6k97-0006UR-1x for qemu-devel@nongnu.org; Fri, 05 May 2017 16:48:16 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55639) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6k96-0006Ty-PO for qemu-devel@nongnu.org; Fri, 05 May 2017 16:48:12 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v45Khk8i122881 for ; Fri, 5 May 2017 16:48:11 -0400 Received: from e24smtp05.br.ibm.com (e24smtp05.br.ibm.com [32.104.18.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2a8ecm23c3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 05 May 2017 16:48:11 -0400 Received: from localhost by e24smtp05.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 5 May 2017 17:48:08 -0300 Received: from d24relay02.br.ibm.com (9.18.232.42) by e24smtp05.br.ibm.com (10.172.0.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 5 May 2017 17:48:07 -0300 Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay02.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v45Km7ts35323960; Fri, 5 May 2017 17:48:07 -0300 Received: from d24av04.br.ibm.com (localhost [127.0.0.1]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v45Km6wm014057; Fri, 5 May 2017 17:48:06 -0300 Received: from arthas.ibm.com ([9.80.215.128]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v45KlsiZ013854; Fri, 5 May 2017 17:48:05 -0300 From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Fri, 5 May 2017 17:47:44 -0300 X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170505204746.14116-1-danielhb@linux.vnet.ibm.com> References: <20170505204746.14116-1-danielhb@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17050520-0032-0000-0000-0000055BBF06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17050520-0033-0000-0000-000011E0F33C Message-Id: <20170505204746.14116-5-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-05_16:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705050194 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v9 4/6] hw/ppc/spapr.c: migrate pending_dimm_unplugs of spapr state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP To allow for a DIMM unplug event to resume its work if a migration occurs in the middle of it, this patch migrates the non-empty pending_dimm_unplugs QTAILQ that stores the DIMM information that the spapr_lmb_release() callback uses. It was considered an apprach where the DIMM states would be restored on the post-_load after a migration. The problem is that there is no way of knowing, from the sPAPRMachineState, if a given DIMM is going through an unplug process and the callback needs the updated DIMM State. We could migrate a flag indicating that there is an unplug event going on for a certain DIMM, fetching this information from the start of the spapr_del_lmbs call. But this would also require a scan on post_load to figure out how many nr_lmbs are left. At this point we can just migrate the nr_lmbs information as well, given that it is being calculated at spapr_del_lmbs already, and spare a scanning/discovery in the post-load. All that we need is inside the sPAPRDIMMState structure that is added to the pending_dimm_unplugs queue at the start of the spapr_del_lmbs, so it's convenient to just migrated this queue it if it's not empty. Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e190eb9..30f0b7b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1437,6 +1437,36 @@ static bool version_before_3(void *opaque, int version_id) return version_id < 3; } +static bool spapr_pending_dimm_unplugs_needed(void *opaque) +{ + sPAPRMachineState *spapr = (sPAPRMachineState *)opaque; + return !QTAILQ_EMPTY(&spapr->pending_dimm_unplugs); +} + +static const VMStateDescription vmstate_spapr_dimmstate = { + .name = "spapr_dimm_state", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT64(addr, sPAPRDIMMState), + VMSTATE_UINT32(nr_lmbs, sPAPRDIMMState), + VMSTATE_END_OF_LIST() + }, +}; + +static const VMStateDescription vmstate_spapr_pending_dimm_unplugs = { + .name = "spapr_pending_dimm_unplugs", + .version_id = 1, + .minimum_version_id = 1, + .needed = spapr_pending_dimm_unplugs_needed, + .fields = (VMStateField[]) { + VMSTATE_QTAILQ_V(pending_dimm_unplugs, sPAPRMachineState, 1, + vmstate_spapr_dimmstate, sPAPRDIMMState, + next), + VMSTATE_END_OF_LIST() + }, +}; + static bool spapr_ov5_cas_needed(void *opaque) { sPAPRMachineState *spapr = opaque; @@ -1535,6 +1565,7 @@ static const VMStateDescription vmstate_spapr = { .subsections = (const VMStateDescription*[]) { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, + &vmstate_spapr_pending_dimm_unplugs, NULL } };