From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41089C352AA for ; Tue, 1 Oct 2019 15:29:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB5312133F for ; Tue, 1 Oct 2019 15:29:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y+MwPM0P" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB5312133F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9C4238E000A; Tue, 1 Oct 2019 11:29:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 975928E0001; Tue, 1 Oct 2019 11:29:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 814718E000A; Tue, 1 Oct 2019 11:29:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id 5E5868E0001 for ; Tue, 1 Oct 2019 11:29:51 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 0F00B8243762 for ; Tue, 1 Oct 2019 15:29:51 +0000 (UTC) X-FDA: 75995600982.06.pen92_7308b2d106531 X-HE-Tag: pen92_7308b2d106531 X-Filterd-Recvd-Size: 6124 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Oct 2019 15:29:50 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id q7so8243154pfh.8 for ; Tue, 01 Oct 2019 08:29:50 -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=lfoAPWtM2xIIEKQ6l0hlVJUA8BjoZHVNTsVw7CYX+0pTBPwuTlv6RtHy8H/RiRh2cy ywzNnDIzMNABrxbO0d5IIhPI3Mi1M+m8BnI1JSkQqGACsZufUiTjTqRKs08gtCH1zWf8 uDkuUiKnXhN44q+2aSy4YhBSw12UsxH5qhxcwDY3ZB/8CUCQNCbY9XK6wo8iL1FU3ya7 fWi1WzmLtn/YF2UYjDZQI1i+/pAaIPuPGz7q5ovaO0bhL15mf/3OVRby0NG9h8fjwsaf 9BTjjLM3owYO5XCoz3+qhp0+4GtndS8cbJbYOhbp+kHGiZY9WOQyR6UpPczLQ949lXRr SpFg== X-Gm-Message-State: APjAAAX1lT5/7uHTOYix0adx5fEh9jer2P6DGzC0szuwYo/OvxNnJSc/ 5LktW0CrFkfD1e8wHcfGA50= X-Google-Smtp-Source: APXvYqwd/kCnyEC2V2itCDr9rRprR6IlLzz9BlpPrfcMUabGpgkedv6UUvLcNR7Y0XMtl684QLFcWw== 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 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: 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);