From patchwork Thu Dec 5 16:22:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11275169 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 642BB13A4 for ; Thu, 5 Dec 2019 16:22:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 235C824249 for ; Thu, 5 Dec 2019 16:22:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X/tyVSPT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 235C824249 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 43CF56B1116; Thu, 5 Dec 2019 11:22:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EE5B6B1117; Thu, 5 Dec 2019 11:22:52 -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 304EB6B1118; Thu, 5 Dec 2019 11:22:52 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id 19E3E6B1116 for ; Thu, 5 Dec 2019 11:22:52 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id D2BB6582C for ; Thu, 5 Dec 2019 16:22:51 +0000 (UTC) X-FDA: 76231606542.28.edge18_8d5d507699e19 X-Spam-Summary: 2,0,0,fc2349abf412f04c,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: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:12986:132 55:13972 X-HE-Tag: edge18_8d5d507699e19 X-Filterd-Recvd-Size: 6094 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Dec 2019 16:22:51 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id q28so3787211qkn.10 for ; Thu, 05 Dec 2019 08:22:51 -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=cIarFzQcMyJw/7KWJfpJ/QIbaZPaRS1aw472xHqzr6c=; b=X/tyVSPTBcypDAVdP2FzfeTs11F32VK2gfbvmJDSRmZAiHcFzrjTbRcVFlTZWy51sf lAkny7DkCya5zNJFVE3Hf0ncjYrjGUomebRr4pTPRfo+xwGK2kK7FRhIWiElu9MQf8zt R/ltj8gAVRhRFkD/geHEgZH5Ub6DcDr/WpDLDPNXnpfZ1BPrFBjRuZs4X+hL4I4zrbaH FVrngPRVPrm4qmcbwApw7qHgHaeI8fjxtAK4m3vesi4IzzImvKMF2zAfBvcuEI5rhQAP 6V7ieqRv66928hJNLQjLnbsWVnvb4NPdtmZbc7+AJ4ZZR00Z0tR+OIFrqc3PVSTPyDIV 3H0Q== 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=cIarFzQcMyJw/7KWJfpJ/QIbaZPaRS1aw472xHqzr6c=; b=dIbXCUXAkdOFvy4NkDlPsTlRpY8L6O6P9maL3fHV0r0tEcrDUogtXy9nHsNN1HXbpY bGSwyA5Yb1WMQp1ZFWEta9//76YebLY+fcIxpYRx2LWjoRCBl6sDtQQ49u7oY2RqUap4 y1PIJcRaDdxEt7GKRu4RqFzSoDMWo6f1sMANi6G19CZpjPtwiov+3oTpr4jZmczbhUET qabAHXhFQvtnJynxkqDznVcxJxVYQZmlZscBOpbYp41J/5Zk4mYTP43PdToyfhr32XlR H0qFZAgU/WqD0oPbRcWPvMDk206dE4k3JrDRxIeGe2GIqmIrIY4T9bKdifPPWl/5MTMB SrFA== X-Gm-Message-State: APjAAAXgrO6V0okXEuxPKB7DevBfJZhv/W1DBwL5CvUk7V5lZN9JNu5Z JpxVe3SA0/HxX+5LJesoPCw= X-Google-Smtp-Source: APXvYqyH5JuZqQdwhLUYnTAbM5VtI0q894ZCvsmzmmsW70OLBLQtAw3147EFn4uEB+DTIWk1qD7+iQ== X-Received: by 2002:a05:620a:13c4:: with SMTP id g4mr9099268qkl.305.1575562970708; Thu, 05 Dec 2019 08:22:50 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id x8sm5323438qts.82.2019.12.05.08.22.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Dec 2019 08:22:50 -0800 (PST) Subject: [PATCH v15 5/7] 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: Thu, 05 Dec 2019 08:22:47 -0800 Message-ID: <20191205162247.19548.38842.stgit@localhost.localdomain> In-Reply-To: <20191205161928.19548.41654.stgit@localhost.localdomain> References: <20191205161928.19548.41654.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. Reviewed-by: David Hildenbrand Signed-off-by: Alexander Duyck Acked-by: Michael S. Tsirkin --- 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 15b7f1d8c334..252591bc7e01 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -849,7 +849,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) { @@ -916,11 +915,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 @@ -1021,7 +1029,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);