Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2632718imm; Fri, 20 Jul 2018 02:01:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf8c2HwAZpA6nTx8pgL9JB/qztBKto+W+Mp5tzFa0F5wq+92cLTxL2OiN9q+M4hXOV7ePzn X-Received: by 2002:a17:902:1e6:: with SMTP id b93-v6mr1272343plb.149.1532077294330; Fri, 20 Jul 2018 02:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532077294; cv=none; d=google.com; s=arc-20160816; b=eJnUjpXFXXgd6fSs+bdhte3hNLIoM37PekKM1D7R+oQWraQVbBCxUsGluISRETYTSB WFea2bGrMWxKtq+EOriG72p88Y4TNyXbgvvsLh0XSRKtZdOwKVHj4mesN0qBPykEeYpL p9jK1tFDupGfFZ+/wbeS2/CqhkxOhupICKBHO3kD6DWyQeacCB1rD5JWCE9P9Gg/7rPo bHIHdS6B5S3Xcv+6JEYobbqWXUI/WoNJdDJJxYNIcMmj3cDURhZgyL8PZ8LhytRnMGkd PIvjIKKPfUBb/sk/exXgnW1fZCndNtnI6wAmw8GGO9pd8QnOGCWXx5L1+Yp+m4NRzdqe t2hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=d8ZhYJ07kkApg1ESbFUOYem1bK1Eo60ZQL8qY1tdWXY=; b=h1QTNOyhlIdYyH/jx2H0fQTmVCJABJq08zPKD8Mn1OfV8MBQ/q1UKJd5vQ5j81+CAX B38sVm5dyS6ZMz3coVto5V+hJPPn/IvTPl5eKdhD+kMVMHl/znTEt0nrQYCCY2VfoxlG OH6o0MYvAcZ9lVhdMMVaA0ddFE6D4aNMgOIMNsXeD9c3A0YF1UY1PDIA8hiMgiPWkByf A89FeqxKvYktm34/MvEjvXl4PEwX72Mz3E6EkoOKZvvhzHR6JscHHGlTaGvGe25Tmk/n mIeHzX6AOG5tFhDIE4Q+cc/sRx2EFA103tW+gmmqDhNn+sNjc8PGrmWKIhzADskRHn2j 5ZnQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s23-v6si1444631pga.563.2018.07.20.02.01.16; Fri, 20 Jul 2018 02:01:34 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbeGTJr5 (ORCPT + 99 others); Fri, 20 Jul 2018 05:47:57 -0400 Received: from mga12.intel.com ([192.55.52.136]:18474 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727723AbeGTJr4 (ORCPT ); Fri, 20 Jul 2018 05:47:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jul 2018 02:00:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,378,1526367600"; d="scan'208";a="66141368" Received: from devel-ww.sh.intel.com ([10.239.48.110]) by FMSMGA003.fm.intel.com with ESMTP; 20 Jul 2018 02:00:35 -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, torvalds@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, peterx@redhat.com Subject: [PATCH v36 5/5] virtio-balloon: VIRTIO_BALLOON_F_PAGE_POISON Date: Fri, 20 Jul 2018 16:33:05 +0800 Message-Id: <1532075585-39067-6-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532075585-39067-1-git-send-email-wei.w.wang@intel.com> References: <1532075585-39067-1-git-send-email-wei.w.wang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 82cd497..6340cc1 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -814,6 +814,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) { @@ -883,6 +884,11 @@ static int virtballoon_probe(struct virtio_device *vdev) VIRTIO_BALLOON_CMD_ID_STOP); 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); + } } err = virtio_balloon_register_shrinker(vb); @@ -979,6 +985,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; } @@ -988,6 +997,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 18ee430..80a7b7e 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 @@ -47,6 +48,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 */ -- 2.7.4