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=-4.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 B845EC433FE for ; Wed, 9 Dec 2020 07:19:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 1AA2523B79 for ; Wed, 9 Dec 2020 07:19:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AA2523B79 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmtl7-00056S-Gh for qemu-devel@archiver.kernel.org; Wed, 09 Dec 2020 02:19:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmtj2-0004d4-6S for qemu-devel@nongnu.org; Wed, 09 Dec 2020 02:17:25 -0500 Received: from mail-vi1eur05on2117.outbound.protection.outlook.com ([40.107.21.117]:21728 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmtiu-0008Oi-Gk for qemu-devel@nongnu.org; Wed, 09 Dec 2020 02:17:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EAIENgXqM77iZIoyfixFz97rml7nonfiQH7Yf2ysgMn9zWAoYKyqBN/bCEkYSPVwx8mh2omSYLznHOV+IZbLzgPYwVFpAweisdBGBrHR0eJ4TVZMoRj/Smi0qjJ5qok71F37nnROj0Jr+i10lr4dmRUK/EurNiH4bvetJEvlFmUIqQPho9osiiGjI1aPYcqUzfuU1cLq74lJLyA+pwsUD4+C8/rKjrCeeHFHSAMWzdj1g11qMwhmZYcuocHpW5TDBJnA6hdIZkRTvuTaCiDY0PS/0WkRHsb2/mROyMY+FFx7PAMbKlDs5zDeQcQBIstTbGMg+E/eVA/gD+TpX/EZ0A== 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=sJYFmkj+RQpVuvuJpKV5P+awEaVHT5aqPzqC49wBaIo=; b=fvKnnCO7Mw76ZOdMIh3vYCx75awWxxo2W0k/OXwOoc8mo9U3eC8xYqM+gNLzE+dUffve08NmZkjXUHvmD2jdDfIxy+vTiifQ+DyVwPpPjf35dAIZ7NsiBXOnXk85fjRQHJ59i4C/ENeAbsCfOANNSTCdlGBqpoyK1HUbJ9WibdHToyGYtNPIF0z7yCAteELLdYhsd369x0f7z/BOyLnAQl/BbuHvk5tykhRSJNyrzzzsBEXfDE3xbdZcwZXs1OdzPBAELVgHVzMmGDQI3muT4GEAOkQQ0iJLi+QLYTRa44HlyK+qmsb10iewzNna5xWm0bYwWGym34KN4aLl2HkF7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sJYFmkj+RQpVuvuJpKV5P+awEaVHT5aqPzqC49wBaIo=; b=aqn2ZfFRmd7R1x5yZ2uYlilyV/QJbUv6+lVafS+OlAZvdfc7cM/cKHqCmLtQcf+wqr4/lXfwpMTvKsPxesKmJTFfQIf02AenCVUDA1JDca91IAHz9w6v9YYWz70UKqPQOrqy5e32LQauJekEO7Bu04kAFk6Do/aHoW3oF7/Jqyc= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=virtuozzo.com; Received: from VI1PR0802MB2510.eurprd08.prod.outlook.com (2603:10a6:800:ad::14) by VI1PR08MB5469.eurprd08.prod.outlook.com (2603:10a6:803:132::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12; Wed, 9 Dec 2020 07:17:11 +0000 Received: from VI1PR0802MB2510.eurprd08.prod.outlook.com ([fe80::ac70:da6f:e05d:1cc9]) by VI1PR0802MB2510.eurprd08.prod.outlook.com ([fe80::ac70:da6f:e05d:1cc9%12]) with mapi id 15.20.3632.023; Wed, 9 Dec 2020 07:17:11 +0000 Subject: Re: [PATCH v5 0/4] migration: UFFD write-tracking migration/snapshots To: Peter Xu Cc: qemu-devel@nongnu.org, Den Lunev , Eric Blake , Paolo Bonzini , Juan Quintela , "Dr . David Alan Gilbert" , Markus Armbruster References: <20201204093103.9878-1-andrey.gruzdev@virtuozzo.com> <20201208182453.GE21402@xz-x1> From: Andrey Gruzdev Message-ID: Date: Wed, 9 Dec 2020 10:17:08 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: <20201208182453.GE21402@xz-x1> Content-Type: multipart/alternative; boundary="------------AC289C5393C35A8AEAD034FB" Content-Language: en-US X-Originating-IP: [95.165.26.68] X-ClientProxiedBy: FRYP281CA0005.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::15) To VI1PR0802MB2510.eurprd08.prod.outlook.com (2603:10a6:800:ad::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.64] (95.165.26.68) by FRYP281CA0005.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.8 via Frontend Transport; Wed, 9 Dec 2020 07:17:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9feaae58-909c-4e44-64bf-08d89c127214 X-MS-TrafficTypeDiagnostic: VI1PR08MB5469: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zm2gfOf7pG3I3PUkUaDlByjunRDaiI+R57BKGPSxJYNcJWUa9lv7xBtxKGlmBqDwucijiDiDKSDc0g0VZ87t4d6Hnwijul6euN66KOI5mhraLPgKBpT75LudWrSzZbDdRK/eWiEXrg/+IgGOtrE/OGeIWWH1qaHvm4RT5aZKUz1P5cnnRj3I1ocOL9vg5kDBgyymoNqRgCOB9okBDF81LVi3NL0pqeIOKh4n8TE8NPyJKMeF0ddMQXI9QYQ9inP7BcxQvuQP5DeKh/oXhKdb6PdzDf8bZAYM0/Z0xYUcQmd/ESVshc8sqzuygQiS+MMRGp/fKUq8XXMylRsW6bRRNe1VX4K1UhixI1TCSofjqtlIDeYcf1POj1WwV6mSQx9Z7A7Auno9qQfjBdVHzr6VTs5bFyYrxtFtDoXNiGkFYeQT4v9W0oWP0Tgwk5TU4rn70IGPCMncGVCrnU+v3RRDQdMSJjdyugELiUigsFYYURM9kA31Sydl0HxOd3EXst0E+ohvDVeFMcyapAeMxlCWVUW3Y4HbF0iJxckTR9lKkZE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0802MB2510.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(136003)(366004)(376002)(33964004)(966005)(86362001)(26005)(186003)(16526019)(53546011)(52116002)(16576012)(54906003)(36756003)(2906002)(5660300002)(31686004)(34490700003)(166002)(31696002)(6916009)(4326008)(8936002)(66476007)(66556008)(6486002)(83380400001)(66946007)(508600001)(2616005)(8676002)(44832011)(956004)(21314003)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?K0lkUVJhZFBXYWd5aGYwd2NxZS9xc0NXYk1WQmxDVFJydUwvK1MxbG13bjk0?= =?utf-8?B?cVB6MWdXTS9QdUxOQ1VlcnZ2YWlwRWxaOTVTWnArRDZRRGhEbEJ3NnhqbEUv?= =?utf-8?B?ZDVSeTlZSkx0T09MU1lzZ3hhTHVqMHJNYm00MjZKKzFHcE15NUlQaTRrZXNz?= =?utf-8?B?cTZ5NlU2MUF2cGJ2QXRsYzNHYkJoVldsWTFPU3N3eTNRUlkwaWRVTW1JMC84?= =?utf-8?B?blQ1UDQvTjBrV3oxeGNIOFlka0NLUS9mN0syenpCTnU0L0xNZ2svVUU3V3Np?= =?utf-8?B?RHptb0xuNlYyR3RLdXFjZVplbFVYY0lubVVLMmhpUi8xMWhDOW9SR21lYWJY?= =?utf-8?B?bTMrc1NFak5TZzZCS2RUR0lnOXNsQzM4MmFBNHg0cWQvNVViUyt1NFN6VHU5?= =?utf-8?B?NjFsLzI3WXRHRFNQME5xQWNERmEyekFSRlNIamFxUjIxa1RJL1pCSHR6bERZ?= =?utf-8?B?OVZFWUd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d08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2020 07:17:10.8679 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-Network-Message-Id: 9feaae58-909c-4e44-64bf-08d89c127214 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4/C4V9jZabFtV04uSf6Y2mWde4KyL9fo5vd7qf5l7LKMz6LWDpw3Tsm6mUtS4afoMh3FK5ZXEZPXKhpqbKzpkgFGVryKODFD86IU5xb/MSo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5469 Received-SPF: pass client-ip=40.107.21.117; envelope-from=andrey.gruzdev@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, MSGID_FROM_MTA_HEADER=0.001, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --------------AC289C5393C35A8AEAD034FB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 08.12.2020 21:24, Peter Xu wrote: > On Fri, Dec 04, 2020 at 12:30:59PM +0300, Andrey Gruzdev wrote: >> This patch series is a kind of 'rethinking' of Denis Plotnikov's ideas he's >> implemented in his series '[PATCH v0 0/4] migration: add background snapshot'. >> >> Currently the only way to make (external) live VM snapshot is using existing >> dirty page logging migration mechanism. The main problem is that it tends to >> produce a lot of page duplicates while running VM goes on updating already >> saved pages. That leads to the fact that vmstate image size is commonly several >> times bigger then non-zero part of virtual machine's RSS. Time required to >> converge RAM migration and the size of snapshot image severely depend on the >> guest memory write rate, sometimes resulting in unacceptably long snapshot >> creation time and huge image size. >> >> This series propose a way to solve the aforementioned problems. This is done >> by using different RAM migration mechanism based on UFFD write protection >> management introduced in v5.7 kernel. The migration strategy is to 'freeze' >> guest RAM content using write-protection and iteratively release protection >> for memory ranges that have already been saved to the migration stream. >> At the same time we read in pending UFFD write fault events and save those >> pages out-of-order with higher priority. >> >> How to use: >> 1. Enable write-tracking migration capability >> virsh qemu-monitor-command --hmp migrate_set_capability. >> track-writes-ram on >> >> 2. Start the external migration to a file >> virsh qemu-monitor-command --hmp migrate exec:'cat > ./vm_state' >> >> 3. Wait for the migration finish and check that the migration has completed. >> state. >> >> Changes v4->v5: >> >> * 1. Refactored util/userfaultfd.c code to support features required by postcopy. >> * 2. Introduced checks for host kernel and guest memory backend compatibility >> * to 'background-snapshot' branch in migrate_caps_check(). >> * 3. Switched to using trace_xxx instead of info_report()/error_report() for >> * cases when error message must be hidden (probing UFFD-IO) or info may be >> * really littering output if goes to stderr. >> * 4 Added RCU_READ_LOCK_GUARDs to the code dealing with RAM block list. >> * 5. Added memory_region_ref() for each RAM block being wr-protected. >> * 6. Reused qemu_ram_block_from_host() instead of custom RAM block lookup routine. >> * 7. Refused from using specific hwaddr/ram_addr_t in favour of void */uint64_t. >> * 8. Currently dropped 'linear-scan-rate-limiting' patch. The reason is that >> * that choosen criteria for high-latency fault detection (i.e. timestamp of >> * UFFD event fetch) is not representative enough for this task. >> * At the moment it looks somehow like premature optimization effort. >> * 8. Dropped some unnecessary/unused code. > I went over the series and it looks nice! > > There're a few todos for this series, so I added them into the wiki page (I > created a "feature" section for migration todo and put live snapshot there): > > https://wiki.qemu.org/ToDo/LiveMigration#Features > > Anyone feel free to add.. > > Thanks, > Thanks, Peter! -- Andrey Gruzdev, Principal Engineer Virtuozzo GmbH +7-903-247-6397 virtuzzo.com --------------AC289C5393C35A8AEAD034FB Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit
On 08.12.2020 21:24, Peter Xu wrote:
On Fri, Dec 04, 2020 at 12:30:59PM +0300, Andrey Gruzdev wrote:
This patch series is a kind of 'rethinking' of Denis Plotnikov's ideas he's
implemented in his series '[PATCH v0 0/4] migration: add background snapshot'.

Currently the only way to make (external) live VM snapshot is using existing
dirty page logging migration mechanism. The main problem is that it tends to
produce a lot of page duplicates while running VM goes on updating already
saved pages. That leads to the fact that vmstate image size is commonly several
times bigger then non-zero part of virtual machine's RSS. Time required to
converge RAM migration and the size of snapshot image severely depend on the
guest memory write rate, sometimes resulting in unacceptably long snapshot
creation time and huge image size.

This series propose a way to solve the aforementioned problems. This is done
by using different RAM migration mechanism based on UFFD write protection
management introduced in v5.7 kernel. The migration strategy is to 'freeze'
guest RAM content using write-protection and iteratively release protection
for memory ranges that have already been saved to the migration stream.
At the same time we read in pending UFFD write fault events and save those
pages out-of-order with higher priority.

How to use:
1. Enable write-tracking migration capability
   virsh qemu-monitor-command <domain> --hmp migrate_set_capability.
track-writes-ram on

2. Start the external migration to a file
   virsh qemu-monitor-command <domain> --hmp migrate exec:'cat > ./vm_state'

3. Wait for the migration finish and check that the migration has completed.
state.

Changes v4->v5:

* 1. Refactored util/userfaultfd.c code to support features required by postcopy.
* 2. Introduced checks for host kernel and guest memory backend compatibility
*    to 'background-snapshot' branch in migrate_caps_check().
* 3. Switched to using trace_xxx instead of info_report()/error_report() for
*    cases when error message must be hidden (probing UFFD-IO) or info may be
*    really littering output if goes to stderr.
* 4  Added RCU_READ_LOCK_GUARDs to the code dealing with RAM block list.
* 5. Added memory_region_ref() for each RAM block being wr-protected.
* 6. Reused qemu_ram_block_from_host() instead of custom RAM block lookup routine.
* 7. Refused from using specific hwaddr/ram_addr_t in favour of void */uint64_t.
* 8. Currently dropped 'linear-scan-rate-limiting' patch. The reason is that
*    that choosen criteria for high-latency fault detection (i.e. timestamp of
*    UFFD event fetch) is not representative enough for this task.
*    At the moment it looks somehow like premature optimization effort.
* 8. Dropped some unnecessary/unused code.
I went over the series and it looks nice!

There're a few todos for this series, so I added them into the wiki page (I
created a "feature" section for migration todo and put live snapshot there):

https://wiki.qemu.org/ToDo/LiveMigration#Features

Anyone feel free to add..

Thanks,

Thanks, Peter!

-- 
Andrey Gruzdev, Principal Engineer
Virtuozzo GmbH  +7-903-247-6397
                virtuzzo.com
--------------AC289C5393C35A8AEAD034FB--