From patchwork Mon Dec 3 19:25:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10710415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8BCC13BF for ; Mon, 3 Dec 2018 19:25:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA49B2AF6C for ; Mon, 3 Dec 2018 19:25:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADDF82B1A4; Mon, 3 Dec 2018 19:25:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE972AF6C for ; Mon, 3 Dec 2018 19:25:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C2FB6B6AC0; Mon, 3 Dec 2018 14:25:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 671836B6AC1; Mon, 3 Dec 2018 14:25:39 -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 561B86B6AC2; Mon, 3 Dec 2018 14:25:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 145F06B6AC0 for ; Mon, 3 Dec 2018 14:25:39 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id s27so7439656pgm.4 for ; Mon, 03 Dec 2018 11:25:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=STy7w+8gswWjStbq2Q93YOGUS6JNeR4D5R0c0fVb3MM=; b=d6CCHBDO0cFJvVK0J4S07zYgnBTDxu6P1X6+UNki1BgmVFifdlCTnQ1M1QQbkVuRod hRk+4NI6yYhstG+olKvZv0Q/zW+0qwq/2WLD4WKdD1OXeq+SWK6h4BlzXq4tfwlyKdfY PP7UiGvosYNqiC1rnl/hr87rftwYR0Tf53cAZfabWOuwNTO++rH00wDkC7c3CHnxJ/W/ NUZAQNqtZ4ShzhO5ysm2kflygLhVhKYbMFoUAOOe/oqX7l2wLuSDJqG89A5aNEQAxxoL mJ7U10ITPIkRBQXr5u9cC0IEuf0JECY94rQ+DeshrWPYMifZvqlomC602Pjv2WZs/0dV ERDA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AA+aEWb7AOEDb7tP019C6sMIQsTveSfUNxf7MXtyDKhVLSm8unMnjmVf dGoeuarISmopCY6thDHfXNvFozJn/Hhq5FFC/bpfJIXMVZYyE9jisoACK5FFGg7QETqac1RmCYR SjfXp1ayf7e+04oVKleokonkpvgHUpVpyGD5Q+uuTtj3Ibf/s08bALQLjwqe/lsK7KQ== X-Received: by 2002:a62:ea09:: with SMTP id t9mr12719343pfh.228.1543865138743; Mon, 03 Dec 2018 11:25:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/Udoelu6ArLex9MoltZ/3rMals8QrYRqXNbSQ+mkRpeRZkMOF2dXgAqKnvk905gd2NhuPNq X-Received: by 2002:a62:ea09:: with SMTP id t9mr12719289pfh.228.1543865138011; Mon, 03 Dec 2018 11:25:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543865137; cv=none; d=google.com; s=arc-20160816; b=jFkSAOeCYnU1a9jEphf2CrDr3E4FKxBQkaN682qZQrUJ6iIcvwbB7wOxUdgWT6rLQP 8TfHSu+Wh28HbdPZ8Ob3XfyYbl7qwQ6hwPpua83WoyTnEYGGrdqDqenVcyG0j+OKJsPc O3HloSO0awU4HojkMkHI5tDAQjThusgNYc7ESzVVWwKS2521s6bdz1qITdajvqlmntHT 1ACuh6P+zRB8qhWHOHZjQzaW+CV8PRudItBrVpTDgaSauMGgsVu6TDrzKObkLjYLzliy ftjDFxcBG+SmTss636G4FMXH0XEGtgN4N2v4KWTnwqOUEOI/QC/Yf92y7v/PwGRAUYwa +pvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject; bh=STy7w+8gswWjStbq2Q93YOGUS6JNeR4D5R0c0fVb3MM=; b=Ec9TJ6xx44uPa9t7r7ytJ5Idlng71Y3m2YKHEJ4U9bInuX7Cubive6hbAChZV9B415 SBvH0Mol+gNVLOmwq7PgCyKdC7rKxbQbk0mjREQpPpFbRzWhwFlty3Mx93jrqk0K4edl tr+UyZxQQ879GMk6ObhbrEc3HTG+Rbiu+19qAq9bfxLiqtE8FfPIh7akbythXefQGlqr myGg4MDX6+7caD0WmzeXq/Jrl+Fxi4ma6CEDjuLxzDG7vNNuJWIh1u26PiZ4zdS9HcvV CoLj8k9t5MBV0ZBZcezUTI0IqI8wy7uMpuj9fRH8/FITLkyCDJo4yxYU3jbDCgSFKa3W Zmpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id g184si15031204pfb.288.2018.12.03.11.25.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 11:25:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.100 as permitted sender) client-ip=134.134.136.100; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2018 11:25:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,311,1539673200"; d="scan'208";a="97705143" Received: from ahduyck-desk1.amr.corp.intel.com ([10.7.198.76]) by orsmga006.jf.intel.com with ESMTP; 03 Dec 2018 11:25:36 -0800 Subject: [PATCH RFC 3/3] kvm: Add additional check to determine if a page is refcounted From: Alexander Duyck To: dan.j.williams@intel.com, pbonzini@redhat.com, yi.z.zhang@linux.intel.com, brho@google.com, kvm@vger.kernel.org, linux-nvdimm@lists.01.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, dave.jiang@intel.com, yu.c.zhang@intel.com, pagupta@redhat.com, david@redhat.com, jack@suse.cz, hch@lst.de, rkrcmar@redhat.com, jglisse@redhat.com Date: Mon, 03 Dec 2018 11:25:36 -0800 Message-ID: <154386513636.27193.9038916677163713072.stgit@ahduyck-desk1.amr.corp.intel.com> In-Reply-To: <154386493754.27193.1300965403157243427.stgit@ahduyck-desk1.amr.corp.intel.com> References: <154386493754.27193.1300965403157243427.stgit@ahduyck-desk1.amr.corp.intel.com> User-Agent: StGit/unknown-version 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: X-Virus-Scanned: ClamAV using ClamSMTP The function kvm_is_refcounted_page is used primarily to determine if KVM is allowed to take a reference on the page. It was using the PG_reserved flag to determine this previously, however in the case of DAX the page has the PG_reserved flag set, but supports pinning by taking a reference on the page. As such I have updated the check to add a special case for ZONE_DEVICE pages that have the new support_refcount_pinning flag set. Signed-off-by: Alexander Duyck --- virt/kvm/kvm_main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 5e666df5666d..2e7e9fbb67bf 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -148,8 +148,20 @@ __weak int kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, bool kvm_is_refcounted_pfn(kvm_pfn_t pfn) { - if (pfn_valid(pfn)) - return !PageReserved(pfn_to_page(pfn)); + if (pfn_valid(pfn)) { + struct page *page = pfn_to_page(pfn); + + /* + * The reference count for MMIO pages are not updated. + * Previously this was being tested for with just the + * PageReserved check, however now ZONE_DEVICE pages may + * also allow for the refcount to be updated for the sake + * of pinning the pages so use the additional check provided + * to determine if the reference count on the page can be + * used to pin it. + */ + return !PageReserved(page) || is_device_pinnable_page(page); + } return false; }