Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8468027ybn; Tue, 1 Oct 2019 08:31:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqysH/yAbf8wDs88OBZ8FBsAYWrafQ8cqgi59LOqPKDAaRm0eHfvd/4Vgb6X91FWnhRf8P7E X-Received: by 2002:aa7:ce88:: with SMTP id y8mr26812358edv.145.1569943875456; Tue, 01 Oct 2019 08:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569943875; cv=none; d=google.com; s=arc-20160816; b=SUAyZlIoM148Un5VJ0KUlwdG0zYUF71XydQHwQoXRjGQbhNkcgvJOywbp+RUel7Ax0 iNRNt4bW3KgNEpFZDYns/Uj25Yc1jZcciyh/fAFGtpTKbMSKsyi7R35W3RIOgbA8AmFp eKNYg1j51TbYFpevDMs4gq3DAGyrE6S6lSLyCAE557BtyiL6+Ix/2BynNQnyaEn0y8Og n2K4xbL9dmgmfQtFQ2tfxH253rOLMv5EGRQPeHd8acaMgqVm2Q3VAJKdrHc9LQQuOVDZ EMFADoCuYEqocFW0h/I63BtiARvfRSv+JimkTL/YxXD4mFfxR7oGZNdJ2Nf6G+O1b36r SlGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=ywjGGrMf/PJ6pRbEzUf6NoarQ8dqbT7Q7Zl+POuvcuU=; b=iETLtcGaPkE69ksROWPa/4QQPRUAixGLsfbwJfbiA1256Fij4U4CPSBh01w95nQB66 k18X32z3M7MdPyk0Olb/2mfiIGA7bTa4R90nRaZcwGVZgq79n+IdVSXGpdAwUPgeFkGN MsmxSzNbxf00Y5Nc0Sd0qAnaWKvTnxdaWNQqj2bd0wy1AdFMnhpsKRfFwZou98p6b9Yi 0bUteAGPA1ZA9/oTzIquTJzXlIOFHYHzePrHqFaX4AKUrXskPmoQlji4q6Ejlqq63/Hq 8RBbIp0c5SLTAOA7j582Z0z5OeH+BhlC8JGqEO6GAqtAZe+/dK9DydIaiCBltHkohhT0 JusA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y+MwPM0P; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oq24si9020997ejb.202.2019.10.01.08.30.50; Tue, 01 Oct 2019 08:31:15 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y+MwPM0P; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389664AbfJAP3v (ORCPT + 99 others); Tue, 1 Oct 2019 11:29:51 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46010 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727204AbfJAP3u (ORCPT ); Tue, 1 Oct 2019 11:29:50 -0400 Received: by mail-pg1-f193.google.com with SMTP id q7so9868466pgi.12; Tue, 01 Oct 2019 08:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=ywjGGrMf/PJ6pRbEzUf6NoarQ8dqbT7Q7Zl+POuvcuU=; b=Y+MwPM0PwyoQs6gNC+lR1Q5jB5E8k4nKxYlTqXp7RB0DriL/eunD9PtWjyD13XHLb5 PSjMcjNm4wTs/EsWyHr508chLopFHQy/Rr5L5sw+D1EHEyhOD05WhTyZPVgFU7LqdZam u6S0n5sGijNBUI27TPTXFGxH8GW7E4Ja7mvxvWAk8lcrel2TJJDk/p6EJrGUcpznoz6e VvMWNVdO2RINsTcVtYHT5uW+lM53GGdYkU0CD9FNd+OFrLsxIBj2vPmmDGpe98NnwZVh Cty1NRgNY1eJSRAZHdmKCezLgdIH74lf77h6TpGH2DJi1KJCQsDPfx0ylqaYeVOL+/1E 8pSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=ywjGGrMf/PJ6pRbEzUf6NoarQ8dqbT7Q7Zl+POuvcuU=; b=N9Z1ngnVRbzmLHfGsisSnry0Ruz5WGpyKi3N3dHVM7idu5HLXiNrTYi5mNL4qrKgkp HoE1OGzK5846qEtVsy3Uk4ZziQBfX4l6wRK3xur/W5CDRA0Jz7F35KNY7TndxloLe7XG 7J50L97LMZ6Db766V6TLhVE/zwWCRsrS2C6kL4Y3qCJWcV0xw0Gr3FQsDU/xxekJdM8Q 7KBkZKVF54GdLQMpN4lHYvCAVoZkim7sZeDqObph/jb5RWcOs92rGjddT7cgBdeQ2LsX SeKa5v3uxd6//zjKkRrA/txu1ePPtK6WduggEwW+dv3wfP5hMZuSVnOaw2HfPwnKzouj FNMw== X-Gm-Message-State: APjAAAUPzgkF5dSGtaPaVOQTf+L3g+DDb/JJzHrDg9LKgoPXnSCqav7w F3pi6SfybfSN/wDnv0t4fd0= X-Received: by 2002:a65:6488:: with SMTP id e8mr2541462pgv.192.1569943789337; Tue, 01 Oct 2019 08:29:49 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id j22sm5658829pgg.16.2019.10.01.08.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Oct 2019 08:29:48 -0700 (PDT) Subject: [PATCH v11 5/6] virtio-balloon: Pull page poisoning config out of free page hinting From: Alexander Duyck To: virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org, mst@redhat.com, david@redhat.com, dave.hansen@intel.com, linux-kernel@vger.kernel.org, willy@infradead.org, mhocko@kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, vbabka@suse.cz, osalvador@suse.de Cc: yang.zhang.wz@gmail.com, pagupta@redhat.com, konrad.wilk@oracle.com, nitesh@redhat.com, riel@surriel.com, lcapitulino@redhat.com, wei.w.wang@intel.com, aarcange@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, alexander.h.duyck@linux.intel.com Date: Tue, 01 Oct 2019 08:29:48 -0700 Message-ID: <20191001152947.27008.56645.stgit@localhost.localdomain> In-Reply-To: <20191001152441.27008.99285.stgit@localhost.localdomain> References: <20191001152441.27008.99285.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Duyck Currently the page poisoning setting wasn't being enabled unless free page hinting was enabled. However we will need the page poisoning tracking logic as well for unused page reporting. As such pull it out and make it a separate bit of config in the probe function. In addition we need to add support for the more recent init_on_free feature which expects a behavior similar to page poisoning in that we expect the page to be pre-zeroed. Reviewed-by: David Hildenbrand Signed-off-by: Alexander Duyck --- drivers/virtio/virtio_balloon.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 226fbb995fb0..92099298bc16 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -842,7 +842,6 @@ 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) { @@ -909,11 +908,20 @@ 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)) { + } + if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)) { + /* Start with poison val of 0 representing general init */ + __u32 poison_val = 0; + + /* + * Let the hypervisor know that we are expecting a + * specific value to be written back in unused pages. + */ + if (!want_init_on_free()) memset(&poison_val, PAGE_POISON, sizeof(poison_val)); - virtio_cwrite(vb->vdev, struct virtio_balloon_config, - poison_val, &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 @@ -1014,7 +1022,10 @@ static int virtballoon_restore(struct virtio_device *vdev) static int virtballoon_validate(struct virtio_device *vdev) { - if (!page_poisoning_enabled()) + /* Tell the host whether we care about poisoned pages. */ + if (!want_init_on_free() && + (IS_ENABLED(CONFIG_PAGE_POISONING_NO_SANITY) || + !page_poisoning_enabled())) __virtio_clear_bit(vdev, VIRTIO_BALLOON_F_PAGE_POISON); __virtio_clear_bit(vdev, VIRTIO_F_IOMMU_PLATFORM);