Received: by 10.223.176.46 with SMTP id f43csp594212wra; Wed, 24 Jan 2018 03:04:21 -0800 (PST) X-Google-Smtp-Source: AH8x225YNVWMqgK4yFeZshjVt68Or78ahBZmgXBULGe19CxTzzbvhucE5G8Jh7pep91z22uZvI2w X-Received: by 10.99.126.86 with SMTP id o22mr10704402pgn.364.1516791861611; Wed, 24 Jan 2018 03:04:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516791861; cv=none; d=google.com; s=arc-20160816; b=IOl7Jz3rQUP9xHUd/nYIYQVqOTU3FIlp1+AnZsHG54zgPEFzqHkUAy0hDU72MKnBcn Hk9O7Zb49f9oNuedpTjyLiDFO+yExtrYwmoiENhUQ8rur/LgZErFZuqxvmutFG8MddTZ nFqD0nMGMITaHa7iDB72N+0iApaTTdK5z1KlUp5x5YumLQWLUNecW1JVvSXmnLkBaX5Z LoxDw0+JatJh3fgHvW3IwgRY7rjf1gzPx/mwgo1zUxMgolQd+W4tm5omn3w+1vujKIzC 8A8Ob0x67RNy1ZDzpjt+5F9Ga5k58rUT96AFeu/kiu20wB4hXEdRt2Q3VNRoYGcdlTSs SJJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=i/7i07O6g8NaifaVc9vNTpDExVSTfQ5kGsXFn3B7b40=; b=RLNztAvqn4eMIa/ur/yrfDanpvC/CeZaoI+XGyWdULWbePZRRac/Zs16L/OD61U2M7 1eM5QZCMxHxfoHk2YXjmxMrGKm3LRUV6kqVkLFan5jqA6YYiZdbCvaR/dI3Ga7VTg0cO ibdDi8so+zUMGHb8msTvaSMUcDE0WBOQySRP2cGWrPwRGZBc0pxQXUW4qTxBhkgVNH8y okaucLYmOPnfN3nGO/7Y3jo1DEpy5+arVlNcToL8NmR1lZsxMibRmB1cP+4BwrQHxDM7 JbMN5e2m0i0aEPz6zaposDS4T458R3ODPkrRwd9IFxU4z4f+9EkCwZp19N44UChlKRkl X9QA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k25si4760pgn.657.2018.01.24.03.04.07; Wed, 24 Jan 2018 03:04:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933129AbeAXLBl (ORCPT + 99 others); Wed, 24 Jan 2018 06:01:41 -0500 Received: from mga03.intel.com ([134.134.136.65]:50845 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932891AbeAXLBj (ORCPT ); Wed, 24 Jan 2018 06:01:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2018 03:01:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,406,1511856000"; d="scan'208";a="22195015" Received: from devel-ww.sh.intel.com ([10.239.48.110]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jan 2018 03:01:36 -0800 From: Wei Wang To: virtio-dev@lists.oasis-open.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, linux-mm@kvack.org, mst@redhat.com, mhocko@kernel.org, akpm@linux-foundation.org Cc: pbonzini@redhat.com, wei.w.wang@intel.com, liliang.opensource@gmail.com, yang.zhang.wz@gmail.com, quan.xu0@gmail.com, nilal@redhat.com, riel@redhat.com Subject: [PATCH v24 0/2] Virtio-balloon: support free page reporting Date: Wed, 24 Jan 2018 18:42:40 +0800 Message-Id: <1516790562-37889-1-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch series is separated from the previous "Virtio-balloon Enhancement" series. The new feature, VIRTIO_BALLOON_F_FREE_PAGE_HINT, implemented by this series enables the virtio-balloon driver to report hints of guest free pages to the host. It can be used to accelerate live migration of VMs. Here is an introduction of this usage: Live migration needs to transfer the VM's memory from the source machine to the destination round by round. For the 1st round, all the VM's memory is transferred. From the 2nd round, only the pieces of memory that were written by the guest (after the 1st round) are transferred. One method that is popularly used by the hypervisor to track which part of memory is written is to write-protect all the guest memory. The second feature enables the optimization of the 1st round memory transfer - the hypervisor can skip the transfer of guest free pages in the 1st round. It is not concerned that the memory pages are used after they are given to the hypervisor as a hint of the free pages, because they will be tracked by the hypervisor and transferred in the next round if they are used and written. ChangeLog: v23->v24: - change feature name VIRTIO_BALLOON_F_FREE_PAGE_VQ to VIRTIO_BALLOON_F_FREE_PAGE_HINT - kick when vq->num_free < half full, instead of "= half full" - replace BUG_ON with bailing out - check vb->balloon_wq in probe(), if null, bail out - add a new feature bit for page poisoning - solve the corner case that one cmd id being sent to host twice v22->v23: - change to kick the device when the vq is half-way full; - open-code batch_free_page_sg into add_one_sg; - change cmd_id from "uint32_t" to "__virtio32"; - reserver one entry in the vq for teh driver to send cmd_id, instead of busywaiting for an available entry; - add "stop_update" check before queue_work for prudence purpose for now, will have a separate patch to discuss this flag check later; - init_vqs: change to put some variables on stack to have simpler implementation; - add destroy_workqueue(vb->balloon_wq); v21->v22: - add_one_sg: some code and comment re-arrangement - send_cmd_id: handle a cornercase For previous ChangeLog, please reference https://lwn.net/Articles/743660/ Wei Wang (2): mm: support reporting free page blocks virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT drivers/virtio/virtio_balloon.c | 265 +++++++++++++++++++++++++++++++----- include/linux/mm.h | 6 + include/uapi/linux/virtio_balloon.h | 7 + mm/page_alloc.c | 91 +++++++++++++ 4 files changed, 333 insertions(+), 36 deletions(-) -- 2.7.4