From patchwork Thu Sep 6 07:00:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10589935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED488920 for ; Thu, 6 Sep 2018 07:01:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4D672A4FE for ; Thu, 6 Sep 2018 07:01:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8DD12A509; Thu, 6 Sep 2018 07:01:16 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E1DF2A4FE for ; Thu, 6 Sep 2018 07:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727727AbeIFLfN (ORCPT ); Thu, 6 Sep 2018 07:35:13 -0400 Received: from mail-pl1-f177.google.com ([209.85.214.177]:41623 "EHLO mail-pl1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727732AbeIFLfN (ORCPT ); Thu, 6 Sep 2018 07:35:13 -0400 Received: by mail-pl1-f177.google.com with SMTP id b12-v6so4514883plr.8 for ; Thu, 06 Sep 2018 00:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rfQjjZoYN8ey6JzyEFUHP7aTftpMshBfTWmwy04gytM=; b=ZXHBPDR5o+zImRH2BS5ZWyh1BhK4II1mfOrl+ZCfAYlDHOtz942pD+eCUoaJmf2C/D HTHj0TSShk3r/RZp1+O8SZXL2I5YZMoRzh5yO0UDjuuChgi4bvTTWaBtTjPyP3QZMXZA mz0f0mitNdazo/8S2qFF6CY8AnzyzbYeYUxGCDyPSsDCOmMvf8/fMNGfrd/3BRG+7Oxj i8nvYWamTXbeOypZkfBZX5E3FiqJLpUCzdDXpVZ4+b7ueshy/ne+KT6PwnBpcXSih+I/ g9MDEbMW+Wq46ioeDRUKIBFUdp6pcipbs1Ll2UslXU6epXeebT/9J8B9B595rQiX4ZQn TbiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rfQjjZoYN8ey6JzyEFUHP7aTftpMshBfTWmwy04gytM=; b=ZLCc6VJlza1UAxL/lvJYcjq0mvhGt4TcLYGupxzRpxB6HWBfuFfd0nklzZ0mhpz2KI hgka92Gk8lLexxLZw30QD/kVl9IrsoEZCLEzxJ36u6+NqxofYl2v7xzDwQn2BWB6SzKd 0BZKY6kuwDzZ42zif0yEJjKRt5bKftregl14NGurkUTZgqJn5rxUf74o+sodzQRXtdDr jZvs8yOcQH1K3+wWBQJCU3fIv8LAtkdiX9nj3NDyJeNpnUnPR9+iqT2rXrWGkOvZZHG5 qXCQFWWMJTtJNHDqwXPzQTrj9RY4kip2dPHSngIuN6ng010n5UGRjdATc6UGNlhiZlVd p2Uw== X-Gm-Message-State: APzg51Ay7cqGLjBu7Rnnq3XRcIpPRxUfvjmRuBdi0vD7XP2jDWoZrkI6 GE2RXcyZOOm9vEf1rpzcIx4= X-Google-Smtp-Source: ANB0VdZKV2VHxnwkbzx3ENQfi43vyK6E3D0lT9iX06m7MhX3zauxiP/7EbvexJC+xul5HlMWpubMHA== X-Received: by 2002:a17:902:be07:: with SMTP id r7-v6mr1282618pls.275.1536217274359; Thu, 06 Sep 2018 00:01:14 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.37]) by smtp.gmail.com with ESMTPSA id u195-v6sm7697017pgb.21.2018.09.06.00.01.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 00:01:13 -0700 (PDT) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com, peterx@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn, eblake@redhat.com, quintela@redhat.com, Xiao Guangrong Subject: [PATCH v6 1/3] migration: do not flush_compressed_data at the end of iteration Date: Thu, 6 Sep 2018 15:00:59 +0800 Message-Id: <20180906070101.27280-2-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180906070101.27280-1-xiaoguangrong@tencent.com> References: <20180906070101.27280-1-xiaoguangrong@tencent.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xiao Guangrong flush_compressed_data() needs to wait all compression threads to finish their work, after that all threads are free until the migration feeds new request to them, reducing its call can improve the throughput and use CPU resource more effectively We do not need to flush all threads at the end of iteration, the data can be kept locally until the memory block is changed or memory migration starts over in that case we will meet a dirtied page which may still exists in compression threads's ring Signed-off-by: Xiao Guangrong Reviewed-by: Juan Quintela --- migration/ram.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 2add09174d..e152831254 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1996,17 +1996,22 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again) pss->page = 0; pss->block = QLIST_NEXT_RCU(pss->block, next); if (!pss->block) { + /* + * If memory migration starts over, we will meet a dirtied page + * which may still exists in compression threads's ring, so we + * should flush the compressed data to make sure the new page + * is not overwritten by the old one in the destination. + * + * Also If xbzrle is on, stop using the data compression at this + * point. In theory, xbzrle can do better than compression. + */ + flush_compressed_data(rs); + /* Hit the end of the list */ pss->block = QLIST_FIRST_RCU(&ram_list.blocks); /* Flag that we've looped */ pss->complete_round = true; rs->ram_bulk_stage = false; - if (migrate_use_xbzrle()) { - /* If xbzrle is on, stop using the data compression at this - * point. In theory, xbzrle can do better than compression. - */ - flush_compressed_data(rs); - } } /* Didn't find anything this time, but try again on the new block */ *again = true; @@ -3219,7 +3224,6 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) } i++; } - flush_compressed_data(rs); rcu_read_unlock(); /*