From patchwork Mon Aug 27 01:32:19 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: 10576353 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 7087B14E1 for ; Mon, 27 Aug 2018 02:02:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DCCE297B7 for ; Mon, 27 Aug 2018 02:02:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51D2F297BA; Mon, 27 Aug 2018 02:02: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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0015297B9 for ; Mon, 27 Aug 2018 02:02:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74C2E6B3E06; Sun, 26 Aug 2018 22:02:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6DBD66B3E0B; Sun, 26 Aug 2018 22:02:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 487C86B3E09; Sun, 26 Aug 2018 22:02:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 05E316B3E05 for ; Sun, 26 Aug 2018 22:02:09 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id s77-v6so9937940pgs.2 for ; Sun, 26 Aug 2018 19:02:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=XgnPYipPxM5b9E6tKmShJno5ECYTnNhCdGFzDptaqkE=; b=RMRPENMc6SIFhL9bOhUGNHI95SMU0LUDSxF+H12oRjXa5RDG9hQcWvvYzGpykG5TB0 HOO/RIEURUpWGDEsPUwWxkMsO+g6WEtvF3b55f/IOJurx/EVe16NqlUfCdwNWHjvEPZm iuz8RQlnzRPyNWL2HI5J5eBdpBgEzxDzw7PQpcgwrvm8OfzLKFgYDKXO7VUKLxRBr1p0 A3FOBZA/QWFH/78Yh3nqEnC9KnjT8nojTIMH4z6lUPCArd87BiVtuWmM4qUggfbudTMU r5w4iD1GQ52XHfLM9KFqWeBdBf0WMKlOJKL7Iw1dx5hliuc3wIcjDzYrzhyDq6y7aPb9 Kjng== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of wei.w.wang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=wei.w.wang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APzg51DSp0DvuNBRkNGGqvQqJufKSkuB9Azok/B0qU1L0TBTJeL1wPbO NWs8G1B/DJtB3m5Y63GUPkrhcXmTqbghAIviqBcy9uWUNH3YVcq+PgRtsK0iZVKmrIWiibR7EIH mazC5Wh9ZCh/DMgwjMzbR7nh+jlHH4TuFDE1Vt27y6a9sxD5e3lCj/xmvmOBs9ACqkQ== X-Received: by 2002:a63:550b:: with SMTP id j11-v6mr1368639pgb.167.1535335328624; Sun, 26 Aug 2018 19:02:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZLtd0+Q0/LPBPv/ufcqeDZ/sBJztWXblibfJStPPU9N86k5hkJADVzWdwnwNkcKJPgRHgE X-Received: by 2002:a63:550b:: with SMTP id j11-v6mr1368597pgb.167.1535335327889; Sun, 26 Aug 2018 19:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535335327; cv=none; d=google.com; s=arc-20160816; b=WrRnXAtAd4NYqmLoxRhcY0S5Sy/t77fIPe+B76LntU5erS8SyemamyqV500EZFoRnt XOXtc62OIakHRy9tr1WTvu8LJyg/jqDlniuB2XHJlLBgyY1MNZvLB++HAN9T9eZ58FQ7 6I8KlCRb6JGeBc2+vAGyhV7KOsaAAoY7CSMWxibhOcfdbEOFws1N1aF5TG3fCXrRzNxB 6vLjn0Cqd1bE7ywiLswt8XuQar1YPrf3yorcL10eKSt+O/pXDahS+T+rdmSDTB0VazzU PA0IHZ/6VCW5foQQdYF4WllAZ28ZCL4aePjYYZk0+JcRCBTwK2NCFDfS3R81WBwf0x3Z GXNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XgnPYipPxM5b9E6tKmShJno5ECYTnNhCdGFzDptaqkE=; b=XhUgVKoemAGcvS42JySsVZXTd39vMgAfC3gHy9R33FE4X+waaT9IMh8pvqdwefWkkI UbGTrCwYmDFz6/2tI0Shhw8pJ19EqTBGFjKhAKuMssoImNQMvVYDH4Oi7ma+/f24z5rW H3IOx4FBpDb24CU04yqqwYVbgStv8XO/Vaq1XKWG9ZKH4ShqXUnxuQxKFbEXQJKIZNKT w3jkzXDtMKJ9J4bOz/Bxodm63b7e9f2yPE3mUHrc5B+JYoimtbF20rCpSgUf2uMCtmHw mqSHKkJ6k59eMomaD47T97M12vdsRh8B/lxagicvVpLeQggN1lbyk6ubDb+TjHHxDyFU JjSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of wei.w.wang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=wei.w.wang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id 35-v6si12920763pgm.687.2018.08.26.19.02.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Aug 2018 19:02:07 -0700 (PDT) Received-SPF: pass (google.com: domain of wei.w.wang@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of wei.w.wang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=wei.w.wang@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Aug 2018 19:02:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,293,1531810800"; d="scan'208";a="75801393" Received: from devel-ww.sh.intel.com ([10.239.48.110]) by FMSMGA003.fm.intel.com with ESMTP; 26 Aug 2018 19:01:43 -0700 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, dgilbert@redhat.com Cc: torvalds@linux-foundation.org, 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, peterx@redhat.com, quintela@redhat.com Subject: [PATCH v37 3/3] virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON Date: Mon, 27 Aug 2018 09:32:19 +0800 Message-Id: <1535333539-32420-4-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535333539-32420-1-git-send-email-wei.w.wang@intel.com> References: <1535333539-32420-1-git-send-email-wei.w.wang@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The VIRTIO_BALLOON_F_PAGE_POISON feature bit is used to indicate if the guest is using page poisoning. Guest writes to the poison_val config field to tell host about the page poisoning value that is in use. Suggested-by: Michael S. Tsirkin Signed-off-by: Wei Wang Cc: Michael S. Tsirkin Cc: Michal Hocko Cc: Andrew Morton --- drivers/virtio/virtio_balloon.c | 10 ++++++++++ include/uapi/linux/virtio_balloon.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index a185678..728ecd1 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -825,6 +825,7 @@ static int virtio_balloon_register_shrinker(struct virtio_balloon *vb) static int virtballoon_probe(struct virtio_device *vdev) { struct virtio_balloon *vb; + __u32 poison_val; int err; if (!vdev->config->get) { @@ -892,6 +893,11 @@ static int virtballoon_probe(struct virtio_device *vdev) vb->num_free_page_blocks = 0; spin_lock_init(&vb->free_page_list_lock); INIT_LIST_HEAD(&vb->free_page_list); + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)) { + memset(&poison_val, PAGE_POISON, sizeof(poison_val)); + virtio_cwrite(vb->vdev, struct virtio_balloon_config, + poison_val, &poison_val); + } } /* * We continue to use VIRTIO_BALLOON_F_DEFLATE_ON_OOM to decide if a @@ -992,6 +998,9 @@ static int virtballoon_restore(struct virtio_device *vdev) static int virtballoon_validate(struct virtio_device *vdev) { + if (!page_poisoning_enabled()) + __virtio_clear_bit(vdev, VIRTIO_BALLOON_F_PAGE_POISON); + __virtio_clear_bit(vdev, VIRTIO_F_IOMMU_PLATFORM); return 0; } @@ -1001,6 +1010,7 @@ static unsigned int features[] = { VIRTIO_BALLOON_F_STATS_VQ, VIRTIO_BALLOON_F_DEFLATE_ON_OOM, VIRTIO_BALLOON_F_FREE_PAGE_HINT, + VIRTIO_BALLOON_F_PAGE_POISON, }; static struct virtio_driver virtio_balloon_driver = { diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h index 47c9eb4..a1966cd7 100644 --- a/include/uapi/linux/virtio_balloon.h +++ b/include/uapi/linux/virtio_balloon.h @@ -35,6 +35,7 @@ #define VIRTIO_BALLOON_F_STATS_VQ 1 /* Memory Stats virtqueue */ #define VIRTIO_BALLOON_F_DEFLATE_ON_OOM 2 /* Deflate balloon on OOM */ #define VIRTIO_BALLOON_F_FREE_PAGE_HINT 3 /* VQ to report free pages */ +#define VIRTIO_BALLOON_F_PAGE_POISON 4 /* Guest is using page poisoning */ /* Size of a PFN in the balloon interface. */ #define VIRTIO_BALLOON_PFN_SHIFT 12 @@ -48,6 +49,8 @@ struct virtio_balloon_config { __u32 actual; /* Free page report command id, readonly by guest */ __u32 free_page_report_cmd_id; + /* Stores PAGE_POISON if page poisoning is in use */ + __u32 poison_val; }; #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */