From patchwork Mon Jul 5 15:13:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12359281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA3C2C07E99 for ; Mon, 5 Jul 2021 15:13:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8126661960 for ; Mon, 5 Jul 2021 15:13:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8126661960 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.150318.277947 (Exim 4.92) (envelope-from ) id 1m0QHv-0003N6-O7; Mon, 05 Jul 2021 15:13:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 150318.277947; Mon, 05 Jul 2021 15:13:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m0QHv-0003Mz-KL; Mon, 05 Jul 2021 15:13:35 +0000 Received: by outflank-mailman (input) for mailman id 150318; Mon, 05 Jul 2021 15:13:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m0QHu-0003Mp-Eb for xen-devel@lists.xenproject.org; Mon, 05 Jul 2021 15:13:34 +0000 Received: from de-smtp-delivery-102.mimecast.com (unknown [194.104.111.102]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 644898e0-a5d7-4f2b-8fb0-71d8cdace4d3; Mon, 05 Jul 2021 15:13:33 +0000 (UTC) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-24-hwN5UErJPKCc14Nz71R6FQ-2; Mon, 05 Jul 2021 17:13:31 +0200 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by VI1PR04MB5743.eurprd04.prod.outlook.com (2603:10a6:803:e0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Mon, 5 Jul 2021 15:13:29 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::99d3:99cd:8adf:3eea]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::99d3:99cd:8adf:3eea%5]) with mapi id 15.20.4287.033; Mon, 5 Jul 2021 15:13:29 +0000 Received: from [10.156.60.236] (37.24.206.209) by PR1P264CA0030.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:19f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Mon, 5 Jul 2021 15:13:29 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 644898e0-a5d7-4f2b-8fb0-71d8cdace4d3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1625498012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rgEdhafpz8BW5gWdiXksunqCC0nVZhZBo0PaP6yDugg=; b=bqjAtljegRBb6MUkqiE3AfSOJ5Wv3+F80VDzQHA5kvjRqSPFTvTlDPKn4QNajsxxbB+SEl TqpwmKH0Wwjl41QaxQ9p+XHybwmWy/ZoUfod3w5xg/tXA2MK0tuYPeCscryr/4hsxh9L0S yHGcMURAd78nT8tJcHTUi9YwN1evLzw= X-MC-Unique: hwN5UErJPKCc14Nz71R6FQ-2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VBu+sH1Y6YKiyXeLuEDh+3FrBdxRwMWkVpOMJ4cNLZKWL9mlRMaZzt+VduYb17kb4o1xhdTvlyfAEqo/dxZwMZk9qvyXhZx6aw5AVDwm4EX3aErdpTDEwV/3S3i2/YZGZtpvnL8LgUpS+tCry9d6tc6cIsoY9TGZT5yugS0G62keOmdMF1U6w7P1wIYCfChDC1LT6OoKTUhlGav9jZp27kHYNOvYes3i3HUVR5S9phjtk5prkvLkmgCEnJRXLeaataBo/iZyivHFFqZy1WOVUbRZB91aoDcUkeR9xbSTFMBveeQSO+2D2YkLgSxABlFRASvTcaTCS2RSsnywp0qpdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rgEdhafpz8BW5gWdiXksunqCC0nVZhZBo0PaP6yDugg=; b=kOyXOgFn17Jo1+5VXXaiNlvbi/bF64KSbRDUNdJKlM8+pnsd2UkflyKkk0BPVi1kvfkBCGT+8+IiFJQ+fVeGKRCzIVR7eYRS+eiyRb+IhtIuvyytH2XOKFS2S5CGMh9//Cs/CtCC2jk2kNfYeDP0b8sUNgep762ReHki1W/wE0wmkoqouvclSgD/IFGRrwmBgklZq3jWMMOdQbKUNvmUElt92Gt29PCEeOUzeVyHftcbeUj37wTRiJ2VTXrNVrGvQypIaXo5pw2CCJoEijw4uUoWqDvZtAnkzIFkEdZ6safuDsbzjaWj/+Mr8iQVxj2R0XUPSXYlriu/BHHcyKRQxA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: xenproject.org; dkim=none (message not signed) header.d=none;xenproject.org; dmarc=none action=none header.from=suse.com; Subject: [PATCH v2 03/13] libxenguest: deal with log-dirty op stats overflow From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Juergen Gross , George Dunlap , Ian Jackson References: <0bebfe8c-6897-dc8b-7fe0-9127d4996eb8@suse.com> Message-ID: <668ef720-389f-4cf1-608e-64aca4f7c73d@suse.com> Date: Mon, 5 Jul 2021 17:13:28 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: <0bebfe8c-6897-dc8b-7fe0-9127d4996eb8@suse.com> Content-Language: en-US X-Originating-IP: [37.24.206.209] X-ClientProxiedBy: PR1P264CA0030.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:19f::17) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f5a04ec-d716-46ca-9682-08d93fc7723c X-MS-TrafficTypeDiagnostic: VI1PR04MB5743: X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l4OjnwNaBl9c7JjrEEwEEvraa5XiAT+KoX6gruMCDMFCd0hTNpNvyYr4J1MoOPP9xg5BAg0qyeztZ/SdfniS8CtpyLmY8vyYadIFrqpRjSuxfe/eWjoVXdBNytfrCzBolaNTWfHAZbHDnNF0Iq0iaU/XJQY6X0h3aq8P9Y6MblIbC6KT9mRuxsg5AioUQ4HGuvIXLVAMXIu7F8tJDaz2FI7yaZKD2cYGgtbA0opr4cfYQKmuu88Fa6SIX8fNonr4i6DNwfw+wdPYUkz+W8cVlVhkXhzeiThV+Bu30zZPwc4g47ZP/hWakF/V4oijfYHpy/U++sSPQeMuKWf9OrYloA+FhdCYekCsM56TGDu8m+HGXVNcbSFoxDp6lyJhCQbGRtDhM5HFWKiUthYekMl2slt0weag+acA+by1I5mvj9iWqV5oQl59Uqs3l0xrL+jI7gE4Hh+ZB6HvA8pqdnIhe0MLt+er/bpAtrBy0syKhRLs5jexV0kuepELQRB+C2NYCn6VV4OcTdhkTe/I+oHelQXxXMy0NUahFrcNSpPo8gco832Ifs/auzrk+Ee25++GDdQOE+gA7GrnC+O+60xoBj3vTufpX6Um0RoUojlDWhnDYT+oCELHQlPwXv1ASdnfC8I/gJs4phesfw9UB0ZuTvH63WVfA43O2O2mRB1ucojD9zyCIr/8bkS5kVhB7WQe7ZvmRVo7rSmXnO8yDJjzA+PSqlsKgedHFtCNuO2g9EoS8SpBuc+jr4mM3JMcfDI7 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5600.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(396003)(136003)(376002)(366004)(346002)(16576012)(83380400001)(6486002)(16526019)(6916009)(4326008)(8936002)(8676002)(186003)(36756003)(478600001)(316002)(38100700002)(26005)(86362001)(31696002)(2906002)(66946007)(5660300002)(31686004)(66556008)(54906003)(66476007)(2616005)(956004)(14143004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mEdveq3oklUuhnZtG4oU94AtPjnH?= =?utf-8?q?vsxHM85lPcCupF5zuIH9tfq+zFn6BUCTf1h6U1VQD3KcSp+GFA5k9YNKwqcYlV/ZZ?= =?utf-8?q?9OMnT6tBpCSMov5FxW+e+N3XukQsbyZi3SUkkfoPseAaMa7zhMdMAYZHwOV7crhc+?= =?utf-8?q?sM+cRh6lpJHM10z3g74Qc8rKeahlcmIm2A9HO3p3+Z5+xh6do/B4SpwkJXUqXF6z3?= =?utf-8?q?Cu9t2Fz+by68h5b1o8ON2mv5xXd21r1d1/hANFPo5q9FmphSZDd/sZq2rofN6wLHh?= =?utf-8?q?3e+Tw/inckgYX1/duP6UoHmpsZPQ0WSyp8wk+X7zzzLXONr55M1dqvUBGr6QvFxWq?= =?utf-8?q?Exk8/ttpWZeKHAOFRJCDS/q0G23HNel+XbtA93dEdy/acUxbAMprkJjxdCNtX3Bd2?= =?utf-8?q?omUyRGaF53/cM4DCNgRMCAterqQcQEVygVN/vbx5jIhJlyNgfalL/uKG7ciZp+J9E?= =?utf-8?q?M2GfSE0tU06olwDweB3B9tRskvztVh3Fryl4UFwg7uXTc9YGRwc/gVqxOCGCR/UhA?= =?utf-8?q?fHzeyW5kkcpQ8rNaTnN8wKIhgsrr8pbldByxzs0nu9t2FcMMRtWc83y/9DTLUnjjk?= =?utf-8?q?2IWgGxyWTEa48D1aRGlABFB1t8ItzApsvRQuMjn7OyoheBa1lvYV02bPmG2I0t/0P?= =?utf-8?q?7/Y0+uc//6YVRUAaK9gDIYxNRftCiFEqN/Kf6kOvdtjBQ8khUyAJaenEpxZEFykwC?= =?utf-8?q?AjNNqNBobZYiq+MapX6PVQl6zjMnCBRCq1hSChbLu8ASxgk4vbc/Q2Hq/dQ+lIeJG?= =?utf-8?q?m3C3Gk/KqGaBCATQNyf3k4A46lbWfpoyKs9Y7F/m4rotE7eF/0O6gmhJsXlX44rkw?= =?utf-8?q?9SQYCig8134lkz+Oo021m/0iEN+D1tPuK/R/Bfj9jmS7e9bSoge8+h/a6YVPk1/RC?= =?utf-8?q?m3HrzwIXrA8bjVjC05kHu7RED1GJDRyfCu8hzazjobC8fl8qROtx5ZCawDWzExosE?= =?utf-8?q?ZRuMivzhgOis/j4Tf/Zzlo1NnG61iMppaANT9MfnN4CmHNjDl+3t1swseXFSuAs51?= =?utf-8?q?C+haQ2ULB6bN1a6zesdvQSwizk7GvzJzyq2nDYfe3ao090WK//PaSCyeJbdtq9XJt?= =?utf-8?q?GlPDxr4k2JVZUyzBDj+MzeKWmUaF5tkOuRYJ2UT7VtbXNRX0aa5/0BKpT/dAsmgCh?= =?utf-8?q?oAE+2gwSQmtbPUPseaQE2QP64S6MLZ1wQapCCr7xX7wIGFucjYkWGePrg+V9PD+cO?= =?utf-8?q?RfD0dd9/eIaEffMTLHqSG1myUpEe2ARIsszsjQLfLdrUnFVNylta5c+wHRWAC46Z6?= =?utf-8?q?FyOTX+Bt9mmGg36q?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f5a04ec-d716-46ca-9682-08d93fc7723c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2021 15:13:29.8500 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tCkIymuHFMTS0pHdpfJWJIxVTYmkcOpq9sLwqXQQip+xU4LUGJeCbiju0FJFcR3s57kW1W5KcNd21Eu+pW9CLg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5743 In send_memory_live() the precise value the dirty_count struct field gets initialized to doesn't matter much (apart from the triggering of the log message in send_dirty_pages(), see below), but it is important that it not be zero on the first iteration (or else send_dirty_pages() won't get called at all). Saturate the initializer value at the maximum value the field can hold. While there also initialize struct precopy_stats' respective field to a more sane value: We don't really know how many dirty pages there are at that point. In suspend_and_send_dirty() and verify_frames() the local variables don't need initializing at all, as they're only an output from the hypercall which gets invoked first thing. In send_checkpoint_dirty_pfn_list() the local variable can be dropped altogether: It's optional to xc_logdirty_control() and not used anywhere else. Note that in case the clipping actually takes effect, the "Bitmap contained more entries than expected..." log message will trigger. This being just an informational message, I don't think this is overly concerning. Signed-off-by: Jan Beulich --- a/tools/libs/guest/xg_sr_restore.c +++ b/tools/libs/guest/xg_sr_restore.c @@ -452,7 +452,6 @@ static int send_checkpoint_dirty_pfn_lis unsigned int count, written; uint64_t i, *pfns = NULL; struct iovec *iov = NULL; - xc_shadow_op_stats_t stats = { 0, ctx->restore.p2m_size }; struct xc_sr_record rec = { .type = REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST, }; @@ -462,7 +461,7 @@ static int send_checkpoint_dirty_pfn_lis if ( xc_logdirty_control( xch, ctx->domid, XEN_DOMCTL_SHADOW_OP_CLEAN, HYPERCALL_BUFFER(dirty_bitmap), ctx->restore.p2m_size, - 0, &stats) != ctx->restore.p2m_size ) + 0, NULL) != ctx->restore.p2m_size ) { PERROR("Failed to retrieve logdirty bitmap"); goto err; --- a/tools/libs/guest/xg_sr_save.c +++ b/tools/libs/guest/xg_sr_save.c @@ -500,7 +500,9 @@ static int simple_precopy_policy(struct static int send_memory_live(struct xc_sr_context *ctx) { xc_interface *xch = ctx->xch; - xc_shadow_op_stats_t stats = { 0, ctx->save.p2m_size }; + xc_shadow_op_stats_t stats = { + .dirty_count = MIN(ctx->save.p2m_size, (typeof(stats.dirty_count))~0) + }; char *progress_str = NULL; unsigned int x = 0; int rc; @@ -519,7 +521,7 @@ static int send_memory_live(struct xc_sr goto out; ctx->save.stats = (struct precopy_stats){ - .dirty_count = ctx->save.p2m_size, + .dirty_count = -1, }; policy_stats = &ctx->save.stats; @@ -643,7 +645,7 @@ static int colo_merge_secondary_dirty_bi static int suspend_and_send_dirty(struct xc_sr_context *ctx) { xc_interface *xch = ctx->xch; - xc_shadow_op_stats_t stats = { 0, ctx->save.p2m_size }; + xc_shadow_op_stats_t stats; char *progress_str = NULL; int rc; DECLARE_HYPERCALL_BUFFER_SHADOW(unsigned long, dirty_bitmap, @@ -701,7 +703,7 @@ static int suspend_and_send_dirty(struct static int verify_frames(struct xc_sr_context *ctx) { xc_interface *xch = ctx->xch; - xc_shadow_op_stats_t stats = { 0, ctx->save.p2m_size }; + xc_shadow_op_stats_t stats; int rc; struct xc_sr_record rec = { .type = REC_TYPE_VERIFY };