From patchwork Fri Jan 3 21:16:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11317417 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 C66CD13A4 for ; Fri, 3 Jan 2020 21:16:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8AB4522314 for ; Fri, 3 Jan 2020 21:16:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="t53IHZGm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8AB4522314 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 A96D68E000A; Fri, 3 Jan 2020 16:16:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A479E8E0003; Fri, 3 Jan 2020 16:16:48 -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 985558E000A; Fri, 3 Jan 2020 16:16:48 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 822558E0003 for ; Fri, 3 Jan 2020 16:16:48 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 429878249980 for ; Fri, 3 Jan 2020 21:16:48 +0000 (UTC) X-FDA: 76337582496.08.voice72_1e3be819da619 X-Spam-Summary: 2,0,0,2b679370c2c2eab4,d41d8cd98f00b204,alexander.duyck@gmail.com,:kvm@vger.kernel.org:mst@redhat.com:linux-kernel@vger.kernel.org:willy@infradead.org:mhocko@kernel.org::akpm@linux-foundation.org:mgorman@techsingularity.net:vbabka@suse.cz:yang.zhang.wz@gmail.com:nitesh@redhat.com:konrad.wilk@oracle.com:david@redhat.com:pagupta@redhat.com:riel@surriel.com:lcapitulino@redhat.com:dave.hansen@intel.com:wei.w.wang@intel.com:aarcange@redhat.com:pbonzini@redhat.com:dan.j.williams@intel.com:alexander.h.duyck@linux.intel.com: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: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:13972:14 096:1409 X-HE-Tag: voice72_1e3be819da619 X-Filterd-Recvd-Size: 6137 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Fri, 3 Jan 2020 21:16:47 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id m13so5170795pjb.2 for ; Fri, 03 Jan 2020 13:16:47 -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=vHnJ25hiopScSvzKvTkXEmD6+64R/VseLeElW32hnVg=; b=t53IHZGmEgX9YjlcOJRzkA5sC8hxtOfQ5r4K36DaKIdwKRpWrlw6xUA7KtJ/N+4WFA 1GmTnundDTnYX3kQFavCI+lXTHXJQNqnDQryR3yBwggyPWfFPC4znSePcUJqWWTnol01 vT2fReiplgNwlQlOnhcYv/aXuKwLRgb3I9sTLDICYPK+CRHX2sF08brQgVoj/kr4W2Wf o11TPQXsyenK9r1FVFNfWyp4BdegxclJvRLDQftbuULIlLf0/hvFuP4SRAjpZWhUgppR pdEfp89FHjsTHFqEByWNb8FWauxbQxU7ImzKWKl2eiafLtGij0zcZn++HDGLoSX0ML1s +gtQ== 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=vHnJ25hiopScSvzKvTkXEmD6+64R/VseLeElW32hnVg=; b=JRb2MyUV0Kkvk2wH2ONN+bpWaYETDDtm0n9xfVu3cj4jarsxi+ej1jIW95mA//V0K6 uMuvf2gJu9WGr2T6vE/mKo2pFpAgmYMHew+ulaLWZfdOxWu9JuztT2rFxO/3rIm1i31u +tjADrwQINd+ek0EYlFulkbW6EJw1qJzm9XePXIuhsTS0qARyGKXexBGF30mKH1vPfM5 SSw4ql/55WeQ2y4iTchUoJtT5bXW3dQNHOASshyGDHLOxdldJGvST0fmd+E2UVZi6MQ7 WYXDwUUPGvRM+Klj8Yt2MlpMCiVg5cUYJIOoGnqx8vHAF6MuTqhO4FtVNE3haiQgklOv DdHw== X-Gm-Message-State: APjAAAW+jrPSq0suubvc2B/3E1uF+mJjvY+echGM0Mh2B6wWi/mjcHVo 9GBG+OjSOiilevAZLCiRCS0= X-Google-Smtp-Source: APXvYqyIwhMfT8gkotRykocjUamFEQI2CeeGZ0bUEVUCIYEWsu9cdQy9mvbieF3fJE3VCTrs32qtlQ== X-Received: by 2002:a17:90a:d34c:: with SMTP id i12mr29093260pjx.18.1578086206769; Fri, 03 Jan 2020 13:16:46 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id a17sm16449218pjv.6.2020.01.03.13.16.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jan 2020 13:16:46 -0800 (PST) Subject: [PATCH v16 5/9] virtio-balloon: Pull page poisoning config out of free page hinting From: Alexander Duyck To: kvm@vger.kernel.org, mst@redhat.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 Cc: yang.zhang.wz@gmail.com, nitesh@redhat.com, konrad.wilk@oracle.com, david@redhat.com, pagupta@redhat.com, riel@surriel.com, lcapitulino@redhat.com, dave.hansen@intel.com, wei.w.wang@intel.com, aarcange@redhat.com, pbonzini@redhat.com, dan.j.williams@intel.com, alexander.h.duyck@linux.intel.com, osalvador@suse.de Date: Fri, 03 Jan 2020 13:16:45 -0800 Message-ID: <20200103211645.29237.24462.stgit@localhost.localdomain> In-Reply-To: <20200103210509.29237.18426.stgit@localhost.localdomain> References: <20200103210509.29237.18426.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 93f995f6cf36..04a1e4b8e11d 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -860,7 +860,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) { @@ -927,11 +926,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 @@ -1032,7 +1040,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);