From patchwork Tue Feb 11 22:46:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11377043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFCFA14E3 for ; Tue, 11 Feb 2020 22:46:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B1C9C2086A for ; Tue, 11 Feb 2020 22:46:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RwymI6IT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1C9C2086A 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 E65AB6B0353; Tue, 11 Feb 2020 17:46:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DF0226B0355; Tue, 11 Feb 2020 17:46:54 -0500 (EST) 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 CDEFF6B0356; Tue, 11 Feb 2020 17:46:54 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id B28496B0353 for ; Tue, 11 Feb 2020 17:46:54 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6C6684821 for ; Tue, 11 Feb 2020 22:46:54 +0000 (UTC) X-FDA: 76479332748.13.quiet96_1f19d1479702c X-Spam-Summary: 2,0,0,44d7ab9e1d37f11a,d41d8cd98f00b204,alexander.duyck@gmail.com,:kvm@vger.kernel.org:david@redhat.com:mst@redhat.com:linux-kernel@vger.kernel.org::akpm@linux-foundation.org:mgorman@techsingularity.net:yang.zhang.wz@gmail.com:pagupta@redhat.com:konrad.wilk@oracle.com:nitesh@redhat.com:riel@surriel.com:willy@infradead.org:lcapitulino@redhat.com:dave.hansen@intel.com:wei.w.wang@intel.com:aarcange@redhat.com:pbonzini@redhat.com:dan.j.williams@intel.com:mhocko@kernel.org:alexander.h.duyck@linux.intel.com:vbabka@suse.cz:osalvador@suse.de,RULES_HIT:41:152:355:379:800:960:965:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2689:2693:2898:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3872:3874:4117:4321:4385:4390:4395:4605:5007:6261:6653:6742:7576:9413:10004:10400:11026:11473:11658:11914:12043:12048:12294:12296:12297:12438:12517:12519:12555:12679:12760:13255:139 72:14096 X-HE-Tag: quiet96_1f19d1479702c X-Filterd-Recvd-Size: 6135 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Feb 2020 22:46:53 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id g3so13509464wrs.12 for ; Tue, 11 Feb 2020 14:46:53 -0800 (PST) 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=fX2vIOR1jwQ3OQ5AzWWpQmc9VHtoWCtjgAnEJ0fhs8c=; b=RwymI6ITtquMApO+YinDpcxNP7VBbFm7WEPDVC010pMz407lNC/c5KX+1s7zSRJh4t dqaXB5EE4z8HfBg+4hv7SJGV509TyeB9T+KzVsk9dBVzdebV3rHytA+Gc4jUbB7y3VAQ msCbtIOP67GnvmP0K5s1/QDrvDIvu3VCPh/UmEipij+qVVxvxw/LATHN+eZum4L4Gcy0 SOsMlwT+G2EpkeTDwJRC/g3qN5HFNjFPaDxdpkIAZKDm0kUYH6Z+0yHseFMzX0ZKkVr7 XO6lRoellSAN9ZQ7sy38xzUFOmKKl4D39nVOqvs+U/6eu+Dfae4dO97a2Dg4NA06hTje lWgA== 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=fX2vIOR1jwQ3OQ5AzWWpQmc9VHtoWCtjgAnEJ0fhs8c=; b=A0YWVjmeRQhvL8S+8ZXVxffHDaqCqziVcx/isHgF9EHi51QgzL7IvVm6SQ6LGgSPGV bfincw97MxgiaYo7JBQ3UK6q5qVs6gxcoVr9B+xn4DRx1uNeCczITzOz7pDywGLHv3PT emNLI06vgzLNHk/wUNYmqimKROIyTgiSd9xa5vsf4rs53KN97thBCGp49EgeZ11eu5XJ MhEjRnUnPLppg8eL0cT1UwrTfu8OVpz3sd82wCkdeqfN/fMXnmHqlyEPwD8jHcCUhQ/n qT+VEDC65zQwTXNaS3UW+nFZ53b8cpx/m5ZWK/Y1ypIMYjOtEu7sOjvpY+1V0lNiVTAV H/dA== X-Gm-Message-State: APjAAAWiipZgnRG0sjxXwBQYfjuqeWP+IEjTFfjkRtnu3uhKd8JYlma8 w9sVlTXIVYIkUGTf5Hhjys8= X-Google-Smtp-Source: APXvYqyTg3p7MDpQ7yThpeq3f81QFXZv92cPDlZzYpxO1HW5ALCSu0tYc3vtEO7T3KnHxsXgxP6m0g== X-Received: by 2002:a5d:4b8f:: with SMTP id b15mr11024664wrt.100.1581461212483; Tue, 11 Feb 2020 14:46:52 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id x14sm5379650wmj.42.2020.02.11.14.46.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2020 14:46:51 -0800 (PST) Subject: [PATCH v17 5/9] virtio-balloon: Pull page poisoning config out of free page hinting From: Alexander Duyck To: kvm@vger.kernel.org, david@redhat.com, mst@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net Cc: yang.zhang.wz@gmail.com, pagupta@redhat.com, konrad.wilk@oracle.com, nitesh@redhat.com, riel@surriel.com, willy@infradead.org, lcapitulino@redhat.com, dave.hansen@intel.com, wei.w.wang@intel.com, aarcange@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, mhocko@kernel.org, alexander.h.duyck@linux.intel.com, vbabka@suse.cz, osalvador@suse.de Date: Tue, 11 Feb 2020 14:46:46 -0800 Message-ID: <20200211224646.29318.695.stgit@localhost.localdomain> In-Reply-To: <20200211224416.29318.44077.stgit@localhost.localdomain> References: <20200211224416.29318.44077.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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 free 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. Acked-by: Michael S. Tsirkin 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 7bfe365d9372..98d09825f2e2 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -864,7 +864,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) { @@ -930,11 +929,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 balloon 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 @@ -1045,7 +1053,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);