From nobody Thu Mar 28 15:01:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1562874464; cv=none; d=zoho.com; s=zohoarc; b=PgLamWT4bicABt6IfV2+HT5AY4ks1poq+4hEMEHtLgP57PCHqVLGTfrfXEINjVgeTBWKU1OcoGdVzL26J1kSdK5NM01ahkuOIWjNNseoY6Ku6HvHW3WTv733ccQ1W2siwheFzIeHg+9nMbAjjcYOvqLKly2dTR7Zfa4ZNHrT9ug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562874464; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=Oh1erswSUkoZmZf2K1cLEsgEHtcWDypOBkqlfS+cmZs=; b=E4tBpi3hLlrjUyB7C7HuxVjZCQi00rdfHriBOUnKuZ/6Dt4nNvPCQ9f3BmtXHm29yFDjGn6StHUi4dbee/Md4Spm4lV31HXXoDhh9oKQsQ3PhwbFU9GuSEsO6qhBDAoaYLFTRJHj6FmjqK9PvHXvf0bxcIMdYz9cQrdC7/mde6Y= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1562874464691681.2081059723868; Thu, 11 Jul 2019 12:47:44 -0700 (PDT) Received: from localhost ([::1]:44922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlf2d-0002C5-IE for importer@patchew.org; Thu, 11 Jul 2019 15:47:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47947) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlf2P-0001eO-UO for qemu-devel@nongnu.org; Thu, 11 Jul 2019 15:47:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlf2O-0000iS-PL for qemu-devel@nongnu.org; Thu, 11 Jul 2019 15:47:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hlf2M-0000eM-BT; Thu, 11 Jul 2019 15:47:26 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6BJlBde078194; Thu, 11 Jul 2019 15:47:16 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tp9r1vg8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2019 15:47:16 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x6BJj3R8022527; Thu, 11 Jul 2019 19:47:15 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma01dal.us.ibm.com with ESMTP id 2tjk97pb3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2019 19:47:14 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6BJlDYo54985132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jul 2019 19:47:13 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59D7EC6057; Thu, 11 Jul 2019 19:47:13 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71BAEC6055; Thu, 11 Jul 2019 19:47:12 +0000 (GMT) Received: from maxibm.br.ibm.com (unknown [9.18.235.216]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 11 Jul 2019 19:47:12 +0000 (GMT) From: "Maxiwell S. Garcia" To: qemu-devel@nongnu.org Date: Thu, 11 Jul 2019 16:47:02 -0300 Message-Id: <20190711194702.26598-1-maxiwell@linux.ibm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-11_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907110218 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2] migration: Do not re-read the clock on pre_save in case of paused guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:PowerPC TCG CPUs" , "Maxiwell S. Garcia" , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Re-read the timebase before migrate was ported from x86 commit: 6053a86fe7bd: kvmclock: reduce kvmclock difference on migration The clock move makes the guest knows about the paused time between the stop and migrate commands. This is an issue in an already-paused VM because some side effects, like process stalls, could happen after migration. So, this patch checks the runstate of guest in the pre_save handler and do not re-reads the timebase in case of paused state (cold migration). Signed-off-by: Maxiwell S. Garcia --- hw/ppc/ppc.c | 13 +++++++++---- target/ppc/cpu-qom.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index a9e508c496..8572e45274 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1008,6 +1008,8 @@ static void timebase_save(PPCTimebase *tb) * there is no need to update it from KVM here */ tb->guest_timebase =3D ticks + first_ppc_cpu->env.tb_env->tb_offset; + + tb->runstate_paused =3D runstate_check(RUN_STATE_PAUSED); } =20 static void timebase_load(PPCTimebase *tb) @@ -1051,9 +1053,9 @@ void cpu_ppc_clock_vm_state_change(void *opaque, int = running, } =20 /* - * When migrating, read the clock just before migration, - * so that the guest clock counts during the events - * between: + * When migrating a running guest, read the clock just + * before migration, so that the guest clock counts + * during the events between: * * * vm_stop() * * @@ -1068,7 +1070,10 @@ static int timebase_pre_save(void *opaque) { PPCTimebase *tb =3D opaque; =20 - timebase_save(tb); + /* guest_timebase won't be overridden in case of paused guest */ + if (!tb->runstate_paused) { + timebase_save(tb); + } =20 return 0; } diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index be9b4c30c3..5fbcdee9c9 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -201,6 +201,7 @@ typedef struct PowerPCCPUClass { typedef struct PPCTimebase { uint64_t guest_timebase; int64_t time_of_the_day_ns; + bool runstate_paused; } PPCTimebase; =20 extern const struct VMStateDescription vmstate_ppc_timebase; --=20 2.20.1