From patchwork Wed Jan 17 06:32:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Wei W" X-Patchwork-Id: 10168629 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 6F75A60386 for ; Wed, 17 Jan 2018 06:54:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CEA127D0E for ; Wed, 17 Jan 2018 06:54:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50FC927F10; Wed, 17 Jan 2018 06:54:08 +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 B817727F8F for ; Wed, 17 Jan 2018 06:54:07 +0000 (UTC) Received: from localhost ([::1]:42033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebhbr-0007qi-2y for patchwork-qemu-devel@patchwork.kernel.org; Wed, 17 Jan 2018 01:54:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebhYF-00055a-JQ for qemu-devel@nongnu.org; Wed, 17 Jan 2018 01:50:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebhYE-0003tR-4b for qemu-devel@nongnu.org; Wed, 17 Jan 2018 01:50:23 -0500 Received: from mga11.intel.com ([192.55.52.93]:59302) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebhYD-0003no-Sj for qemu-devel@nongnu.org; Wed, 17 Jan 2018 01:50:22 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2018 22:50:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,371,1511856000"; d="scan'208";a="196306562" Received: from devel-ww.sh.intel.com ([10.239.48.110]) by fmsmga006.fm.intel.com with ESMTP; 16 Jan 2018 22:50:19 -0800 From: Wei Wang To: qemu-devel@nongnu.org, virtio-dev@lists.oasis-open.org, mst@redhat.com, quintela@redhat.com, dgilbert@redhat.com Date: Wed, 17 Jan 2018 14:32:00 +0800 Message-Id: <1516170720-4948-5-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516170720-4948-1-git-send-email-wei.w.wang@intel.com> References: <1516170720-4948-1-git-send-email-wei.w.wang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [PATCH v1 4/4] virtio-balloon: Don't skip free pages if the poison val is non-zero 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: yang.zhang.wz@gmail.com, quan.xu0@gmail.com, liliang.opensource@gmail.com, wei.w.wang@intel.com, pbonzini@redhat.com, nilal@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If the guest is using a non-zero poisoning, we don't skip the transfer of guest free pages. Todo: As a next step optimization, we can try 1) skip the transfer of guest poisoned free pages; 2) send the poison value to destination; and 3) seek a way to poison the guest free pages before the guest starts to run on the destination. Signed-off-by: Wei Wang CC: Michael S. Tsirkin --- hw/virtio/virtio-balloon.c | 3 ++- include/hw/virtio/virtio-balloon.h | 1 + include/standard-headers/linux/virtio_balloon.h | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index dcc8cb3..0cdc755 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -403,7 +403,7 @@ static void virtio_balloon_handle_free_pages(VirtIODevice *vdev, VirtQueue *vq) ram_addr_t offset; if (atomic_read(&dev->free_page_report_status) == - FREE_PAGE_REPORT_S_IN_PROGRESS) { + FREE_PAGE_REPORT_S_IN_PROGRESS && !dev->poison_val) { block = qemu_ram_block_from_host(elem->in_sg[0].iov_base, false, &offset); size = elem->in_sg[0].iov_len; @@ -530,6 +530,7 @@ static void virtio_balloon_set_config(VirtIODevice *vdev, ((ram_addr_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT), &error_abort); } + dev->poison_val = le32_to_cpu(config.poison_val); trace_virtio_balloon_set_config(dev->actual, oldactual); } diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-balloon.h index 268f7d6..0bb80cd 100644 --- a/include/hw/virtio/virtio-balloon.h +++ b/include/hw/virtio/virtio-balloon.h @@ -43,6 +43,7 @@ typedef struct VirtIOBalloon { uint32_t num_pages; uint32_t actual; uint32_t free_page_report_cmd_id; + uint32_t poison_val; uint64_t stats[VIRTIO_BALLOON_S_NR]; VirtQueueElement *stats_vq_elem; size_t stats_vq_offset; diff --git a/include/standard-headers/linux/virtio_balloon.h b/include/standard-headers/linux/virtio_balloon.h index 596df5d..f6f4ff3 100644 --- a/include/standard-headers/linux/virtio_balloon.h +++ b/include/standard-headers/linux/virtio_balloon.h @@ -47,6 +47,8 @@ struct virtio_balloon_config { uint32_t actual; /* The free_page report command id, readonly by guest */ uint32_t free_page_report_cmd_id; + /* Stores PAGE_POISON if page poisoning with sanity check is in use */ + uint32_t poison_val; }; #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */