From patchwork Wed Aug 22 10:55:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10572517 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 CDE41112E for ; Wed, 22 Aug 2018 02:16:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C25922B298 for ; Wed, 22 Aug 2018 02:16:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B60372B29E; Wed, 22 Aug 2018 02:16:49 +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=-1.0 required=2.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, 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 5E87F2B298 for ; Wed, 22 Aug 2018 02:16:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 797986B21ED; Tue, 21 Aug 2018 22:16:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 71D276B21EE; Tue, 21 Aug 2018 22:16:48 -0400 (EDT) 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 5E4B46B21EF; Tue, 21 Aug 2018 22:16:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 1EF356B21ED for ; Tue, 21 Aug 2018 22:16:48 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id l65-v6so287942pge.17 for ; Tue, 21 Aug 2018 19:16:48 -0700 (PDT) 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:from:to:cc :subject:date:message-id:in-reply-to:references; bh=GsTG8lALSXFkkbPi8ZceiT5v9rNJDXjkmFjyPfdKasA=; b=J5RmVCCHAn92GOjKWTLVO95UgVmcXi6X+KG725FoGIdXMDnzC2L5mL0iFH93DcOJfo G8h9GT8d+QEH621p1EN0+YVrLONSzp6SifnuhWa84BJC+hke9DDQrv+koPlFuPWTEFRp 4Sxu5yVNi1WH0256EtJy2ktZafGcaTMs6oa7GJNybEJa+Feq3UjEzeRbbl+4LYg95BtC AMC5MIKJSEFKKzibccGbL+5etvg738j6Y0Qlh6ohphpBJgZHMJwqiuzSepW+8O52bYNv lKuHT4lxiSGdAMxvyLI8io8okJ8wRp9uCzxz0MXLjxyeYZhlBE6sOdg0VGGlMMuZJoJG qEVA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlGrkKj/hkTlpIRKYFo9yxrh2V/yNHMHUy7axaSBydOieNAZlU9C Y4cjoxW2/p6mKifTy4yfvz4As7qI1W1HGgHkSLtkvtqHnkDDKe6Tq7g+IIPRMaZS6zpAklTK+Zo imhaR07N0Hsr5p8h5bhN/1b1CLhTN/3c+akWrXJiH1S0ie9Lc+P4g78twcmvLtX0CLA== X-Received: by 2002:a65:6243:: with SMTP id q3-v6mr48807771pgv.273.1534904207834; Tue, 21 Aug 2018 19:16:47 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw5G1X8u4Fd1OnbCQfql0BzX4jugv21/YpieNbSlrBfaNoBNGvRz/Lzmm6+ppzpv1mbRrJ7 X-Received: by 2002:a65:6243:: with SMTP id q3-v6mr48807740pgv.273.1534904207063; Tue, 21 Aug 2018 19:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534904207; cv=none; d=google.com; s=arc-20160816; b=R3+n6j6K8CKFm67bIWQAL5J08zSO4vYzJVY0UMEyY3hUEbNiih09mTiz9vzEtWSq/8 e9tDpZYkcSHsxaOtm6vh0bLbl3SLv3zvpUemC4yK8wzk9uwbX9u9EI38c78v8/RnaVdG jEf/Dj5rjMERIEuLFKqOZ10AhV4tNsn01H6l88z3HN3GTMG3uzqIt5oLaggg4/sviX30 Q30EJtK880OaOxBwfJLhNGZONvxt6jd9Mpd8D5Q/LcTWTcWsP/BPD1xvuZMuH49we8vh SOXLpSVch5A1xJC+9L9Le6EQ3k1YLlqs0jD758VLxUJiCLaqnp1D89gu1pBGWH4dXrsD 8xAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=GsTG8lALSXFkkbPi8ZceiT5v9rNJDXjkmFjyPfdKasA=; b=m00HCpTrPTdEVuBRGicBQ0oSEsrd2nQ4Ygdz32lr59uKoI4PlZlooyuYdDIBjpO2rA SXc4lzRZhIRg6FDLydSqXQDmTJGweJRquDbaH8C9b96LwoqIKWNSUlnme2a+/E+62dJ7 VJaqjfSmOnKARd/aD/3MGMoTj80CkH68llksMZOBNN3cfpXEdXU+JB9mlgUn9Cu/Uxwl oGz8o0ptsvU2NwNBDrsZGttYglOMiWxsm2EGBkVE+UGFFK6VR63xi7XuxNEXOHDg0E5j lYuUF5tteYEWuxJG/oIDhX70ucyj+5ALeP0Q3IF1b5bVhv+DF66vAitEvG9Mnso494zR iJIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id az1-v6si381379plb.456.2018.08.21.19.16.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 19:16:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=yi.z.zhang@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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2018 19:16:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,272,1531810800"; d="scan'208";a="68089377" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 21 Aug 2018 19:16:46 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id CD74A5802E1; Tue, 21 Aug 2018 19:16:42 -0700 (PDT) From: Zhang Yi To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, pbonzini@redhat.com, dan.j.williams@intel.com, dave.jiang@intel.com, yu.c.zhang@intel.com, pagupta@redhat.com, david@redhat.com, jack@suse.cz, hch@lst.de Cc: linux-mm@kvack.org, rkrcmar@redhat.com, jglisse@redhat.com, yi.z.zhang@intel.com, Zhang Yi Subject: [PATCH V4 1/4] kvm: remove redundant reserved page check Date: Wed, 22 Aug 2018 18:55:37 +0800 Message-Id: <26f79872e78cc643937059003763b5cfc1333167.1534934405.git.yi.z.zhang@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, 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 PageReserved() is already checked inside kvm_is_reserved_pfn(), remove it from kvm_set_pfn_dirty(). Signed-off-by: Zhang Yi Signed-off-by: Zhang Yu Reviewed-by: David Hildenbrand Acked-by: Pankaj Gupta --- virt/kvm/kvm_main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 8b47507f..c44c406 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1690,12 +1690,8 @@ EXPORT_SYMBOL_GPL(kvm_release_pfn_dirty); void kvm_set_pfn_dirty(kvm_pfn_t pfn) { - if (!kvm_is_reserved_pfn(pfn)) { - struct page *page = pfn_to_page(pfn); - - if (!PageReserved(page)) - SetPageDirty(page); - } + if (!kvm_is_reserved_pfn(pfn)) + SetPageDirty(pfn_to_page(pfn)); } EXPORT_SYMBOL_GPL(kvm_set_pfn_dirty); From patchwork Wed Aug 22 10:56:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10572527 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 3F2D41390 for ; Wed, 22 Aug 2018 02:18:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0ACD2B2E7 for ; Wed, 22 Aug 2018 02:18:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3B552B2F0; Wed, 22 Aug 2018 02:18:02 +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=-1.0 required=2.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, 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 6CE532B2E7 for ; Wed, 22 Aug 2018 02:18:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F3796B21F0; Tue, 21 Aug 2018 22:18:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8A3996B21F4; Tue, 21 Aug 2018 22:18:01 -0400 (EDT) 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 725B76B21F0; Tue, 21 Aug 2018 22:18:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 2B6746B21F0 for ; Tue, 21 Aug 2018 22:18:01 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id e124-v6so295145pgc.11 for ; Tue, 21 Aug 2018 19:18:01 -0700 (PDT) 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:from:to:cc :subject:date:message-id:in-reply-to:references; bh=JwWIqrnfqvRtRk9oqwaC6IStXdXj/6nsmHZH6RgulUQ=; b=O13LxwT0UbsU9Q3vlJe2Vr21IEHUtNm6VR4uBDSme83wsUsvn1HVVoE3AJO3G0HXMB mVQh7PSckBWnmk00AQzjcj6/ftphXgOAByJnU4Ea4PLzf6pdoFdcMGYYYnnxN0N1eqjR aLFkkPWGaGJaq3tN9DPQsDv4xN5qFZV+GmWhQSUuCY2PzXy7/Gtkw7/nw1ggumC/W2s2 RGMXMPGsH1pdKFi4jsZTVsrvNypVDD8Y9Qyk/HzdE3ZHbCRpemSpG1lDnin0u/7wVnEE 2igIORc6YsZTUIWGmVkjfQJ7/VklU7Eq9fS9eXUOfv+x7+hKALYIiy11+moVH+DKV2NJ M8RQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlF6sHpH9CpVtnBBSRh/5EZoB8vL1l/sSbuKobjMsd4nnoeyuPUT vNIOlLRaBgMJKh+TKUJc7lE0XoggXMHfuMV7J2stXGc7+sNsCeJAr2kJQ82NsnrplRk326KxqnZ KrmqvsnMbOv+pY503yWBMEm/6zogo3+OonDhG7MrJ71FhEzGSJS/LDQZnf8FVmU0IQA== X-Received: by 2002:a62:404e:: with SMTP id n75-v6mr55399283pfa.232.1534904280619; Tue, 21 Aug 2018 19:18:00 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyROYj2miRZpfXkQc7qBkLq8mRjnCXudZFhwLXpQa2WG+TTbdQnqEtrlEcbOeD0TLMoDRCB X-Received: by 2002:a62:404e:: with SMTP id n75-v6mr55399196pfa.232.1534904278402; Tue, 21 Aug 2018 19:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534904278; cv=none; d=google.com; s=arc-20160816; b=brgmJZoMpRzd7Rp/drWCxx42MFD3Wgj/qeAgQHmFEBtbgC8T5qkZ10kfuhKNYdzMqX 5zcqoT9D0UJUEvZzERibQAHMK2WobQJ4TFDEm/gNOD8BoqvhUCBwa8UEctGBDV+wuzxZ UATLrE7CfduHr9WvHFSvfJgHx3xBB6QAcNHpZWmaF79mZZHH0DaSiJlD0YM5lmGTuwmB 0vZ5OCEFJUf2eVs9TfTie3wOC6njKQSpERp7kxvpyJUtFjN3A5Bwhvc2ZklYlORMe489 HPINUozDbw2QvpcfdEa/7lxisSzQT1jFZJyZz7wBToDM/FzXRb1Az+0awgRodz5I68fP K4+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=JwWIqrnfqvRtRk9oqwaC6IStXdXj/6nsmHZH6RgulUQ=; b=YJWAJw2f2sjJxgQ82ZhYuhIL/GXu+LYrMN020y1F83gEwGKmpO8kMukXVbNMDdVtej Kh3VP5DjshDqM20PVrcD0znsPPXy8i4ywsSrKmyd7vF3uC1E4VAOdwPxGLyrE6eFFbzV 4IHC0pLIa+R7gAF7tbEhkxDtjoS8tKIaodpEQ4wOv3jnONiTRUPILY2up19V7Oj4cAJ/ PqtB3z/MLh78c6jMPIz2bJ15fhzehMfmmkHjYDRrJoXzwvCL8QwObOF1hByfwk2SjVQm XWZpSNxvKWA81RAYRcsLVzs404Nd/CVwrMntqiMUck+tQscVX1374Ybx1PIaLjVF8rDP R4pA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id f9-v6si434492pgl.554.2018.08.21.19.17.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 19:17:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yi.z.zhang@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 fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2018 19:17:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,272,1531810800"; d="scan'208";a="256952715" Received: from linux.intel.com ([10.54.29.200]) by fmsmga006.fm.intel.com with ESMTP; 21 Aug 2018 19:17:36 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id DCEA55802E1; Tue, 21 Aug 2018 19:17:34 -0700 (PDT) From: Zhang Yi To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, pbonzini@redhat.com, dan.j.williams@intel.com, dave.jiang@intel.com, yu.c.zhang@intel.com, pagupta@redhat.com, david@redhat.com, jack@suse.cz, hch@lst.de Cc: linux-mm@kvack.org, rkrcmar@redhat.com, jglisse@redhat.com, yi.z.zhang@intel.com, Zhang Yi Subject: [PATCH V4 2/4] mm: introduce memory type MEMORY_DEVICE_DEV_DAX Date: Wed, 22 Aug 2018 18:56:29 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: 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 Currently, NVDIMM pages will be marked 'PageReserved'. However, unlike other reserved PFNs, pages on NVDIMM shall still behave like normal ones in many cases, i.e. when used as backend memory of KVM guest. This patch introduces a new memory type, MEMORY_DEVICE_DEV_DAX. And set this flag while dax driver hotplug the device memory. Signed-off-by: Zhang Yi Signed-off-by: Zhang Yu Reviewed-by: Jan Kara Reviewed-by: Pankaj Gupta --- drivers/dax/pmem.c | 1 + include/linux/memremap.h | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c index fd49b24..fb3f363 100644 --- a/drivers/dax/pmem.c +++ b/drivers/dax/pmem.c @@ -111,6 +111,7 @@ static int dax_pmem_probe(struct device *dev) return rc; dax_pmem->pgmap.ref = &dax_pmem->ref; + dax_pmem->pgmap.type = MEMORY_DEVICE_DEV_DAX; addr = devm_memremap_pages(dev, &dax_pmem->pgmap); if (IS_ERR(addr)) return PTR_ERR(addr); diff --git a/include/linux/memremap.h b/include/linux/memremap.h index f91f9e7..cd07ca8 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -53,11 +53,19 @@ struct vmem_altmap { * wakeup event whenever a page is unpinned and becomes idle. This * wakeup is used to coordinate physical address space management (ex: * fs truncate/hole punch) vs pinned pages (ex: device dma). + * + * MEMORY_DEVICE_DEV_DAX: + * Device memory that support raw access to persistent memory. Without need + * of an intervening filesystem, it could be directed mapped via an mmap + * capable character device. Together with the type MEMORY_DEVICE_FS_DAX, + * we could distinguish the persistent memory pages from normal ZONE_DEVICE + * pages. */ enum memory_type { MEMORY_DEVICE_PRIVATE = 1, MEMORY_DEVICE_PUBLIC, MEMORY_DEVICE_FS_DAX, + MEMORY_DEVICE_DEV_DAX, }; /* From patchwork Wed Aug 22 10:56:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10572529 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 071E51390 for ; Wed, 22 Aug 2018 02:18:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 357B22AC40 for ; Wed, 22 Aug 2018 02:18:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2998C2B2F0; Wed, 22 Aug 2018 02:18:05 +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=-1.0 required=2.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, 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 BFC1E2AC40 for ; Wed, 22 Aug 2018 02:18:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D85DE6B21F2; Tue, 21 Aug 2018 22:18:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D39256B21F3; Tue, 21 Aug 2018 22:18:01 -0400 (EDT) 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 BFD406B21F4; Tue, 21 Aug 2018 22:18:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 769B16B21F3 for ; Tue, 21 Aug 2018 22:18:01 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id a26-v6so297916pgw.7 for ; Tue, 21 Aug 2018 19:18:01 -0700 (PDT) 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:from:to:cc :subject:date:message-id:in-reply-to:references; bh=OA1rmIU3VRvLZ2ODVWo5LwDjZtSFf2ZqZzweBonlHn8=; b=TD6eBLet+vkduc5jxRMMhzAEPOIshQazV583eyAlK4KNro7i9aPxURjoIa6GiYBFTU OmyMGFN7UBkjcZ0T5s+Q1PpdwVddjChNz7KTZT9icFsdupMeivLrKvH5y91EgGf1fJvt B4VM95oTUho31WSGn+5nsDU/l67w/d1ITBew8YhgKQqlbyfFRXmGE9Fjx1ok5udB6ejT gHJH/oFhdoN35fWXnS6pbiXhE5oZAeWK/7ib5o8Eo4UwoflGW6GV3Gq4Z3EZPp5CxA12 oQXstHlgyfKFzpTHrKIOhz7ygh5Ne7uhNnj93LZnqtRYj38OJTdYgkNhfr7VD0exwTr5 PZvw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlGZZvDSQX3hDKvV9XWXos8/GV2S7DmGeJwqW3MFI7fwG92P0cRJ ixc6cO3VliP+c0pZzeELr8BIYNGqkVkG8IVobyAGuN4GobzIoIeCf1ga2CmYHf+zOb3lESxftah fjXF9InUH5G6gDeurIgJVAXcQ4AybP3FOMVa3hA+v5ykoAG51nCGBEOXIuD3CcDq7UA== X-Received: by 2002:a62:e511:: with SMTP id n17-v6mr55749162pff.210.1534904281154; Tue, 21 Aug 2018 19:18:01 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwmnJbzPU/+kSfTyKggo25Y045UDvEv6q99Ju4Mey+Q++1sLNZEvnCT2wEuxk6zbXXGvy1R X-Received: by 2002:a62:e511:: with SMTP id n17-v6mr55749075pff.210.1534904278686; Tue, 21 Aug 2018 19:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534904278; cv=none; d=google.com; s=arc-20160816; b=YfgmQjj5ezBamBGzaaDQcQRfxYboc1A726khFU7LBRS7hJScR4zMRK6X+pblKbzs1d K460PyWGhU9IIw4RqZD9uudY1TMJh0XqcPN0e+wapkqCXUYvsGeEcXUcrLJxVs8qb3/v kXaAfCiL3vZTUU+NOanQC61HXJ4O9jyznbg5VSgl9mmAGDw95jWbdZHpsQkDEPhPwlnd Pl3HY/FEPHXEkqoUv9OX+fHBNRMU3rn7iyha6C+tWtlUb4O4K2j17pOjYg1fH0s4yBag kX0AmRiBK0LgDhqkVpmfzAg0PqU56llHChxKtHjgtjO/ALkV65lP1Zhjm9DcAHzZ9FsD u0zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=OA1rmIU3VRvLZ2ODVWo5LwDjZtSFf2ZqZzweBonlHn8=; b=BcuDL0bsp7g9uF6JB4avHM2SNdS/gHU2W9/n0PvoBu4vN/r3DUWKt8H4o7WEZWKbaO Ict7gwlprpV3nuCLjJZDdFujyxN2URHXXSUMXcsBNxHRkBAFfBdFPh81rbK6/yM47jtN SGdKQobTVi1ZiMs435CLp2ZYjIB84wNo7gG76OgOjMwSFtcL3jMb3Z1NZAb9NdrzLwZE JiB0uVZCJpEmRwaz1+uaJK5OA42A6xfdLMRY7BSy0hU3N1/3ABQ3G6Sc2Kn0xHvi5oqS e/vbxqEzFseI8C8sV1x8+LEvlMnDrO9iwEtE9m9noRHFteaQnntncejcoolckTnm/emD MDmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id f9-v6si434492pgl.554.2018.08.21.19.17.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 19:17:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yi.z.zhang@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 fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2018 19:17:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,272,1531810800"; d="scan'208";a="256952771" Received: from linux.intel.com ([10.54.29.200]) by fmsmga006.fm.intel.com with ESMTP; 21 Aug 2018 19:17:55 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id F052F5802C8; Tue, 21 Aug 2018 19:17:53 -0700 (PDT) From: Zhang Yi To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, pbonzini@redhat.com, dan.j.williams@intel.com, dave.jiang@intel.com, yu.c.zhang@intel.com, pagupta@redhat.com, david@redhat.com, jack@suse.cz, hch@lst.de Cc: linux-mm@kvack.org, rkrcmar@redhat.com, jglisse@redhat.com, yi.z.zhang@intel.com, Zhang Yi Subject: [PATCH V4 3/4] mm: add a function to differentiate the pages is from DAX device memory Date: Wed, 22 Aug 2018 18:56:48 +0800 Message-Id: <044309496afbb4121447dff6a453bd6b96d6068d.1534934405.git.yi.z.zhang@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: 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 DAX driver hotplug the device memory and move it to memory zone, these pages will be marked reserved flag, however, some other kernel componet will misconceive these pages are reserved mmio (ex: we map these dev_dax or fs_dax pages to kvm for DIMM/NVDIMM backend). Together with the type MEMORY_DEVICE_FS_DAX, we can use is_dax_page() to differentiate the pages is DAX device memory or not. Signed-off-by: Zhang Yi Signed-off-by: Zhang Yu Acked-by: Jan Kara Reviewed-by: Pankaj Gupta --- include/linux/mm.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 68a5121..de5cbc3 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -889,6 +889,13 @@ static inline bool is_device_public_page(const struct page *page) page->pgmap->type == MEMORY_DEVICE_PUBLIC; } +static inline bool is_dax_page(const struct page *page) +{ + return is_zone_device_page(page) && + (page->pgmap->type == MEMORY_DEVICE_FS_DAX || + page->pgmap->type == MEMORY_DEVICE_DEV_DAX); +} + #else /* CONFIG_DEV_PAGEMAP_OPS */ static inline void dev_pagemap_get_ops(void) { @@ -912,6 +919,11 @@ static inline bool is_device_public_page(const struct page *page) { return false; } + +static inline bool is_dax_page(const struct page *page) +{ + return false; +} #endif /* CONFIG_DEV_PAGEMAP_OPS */ static inline void get_page(struct page *page) From patchwork Wed Aug 22 10:58:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10572537 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 F3AAB1390 for ; Wed, 22 Aug 2018 02:19:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8E822B338 for ; Wed, 22 Aug 2018 02:19:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCB322B337; Wed, 22 Aug 2018 02:19:22 +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=-1.0 required=2.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, 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 B7AF92B337 for ; Wed, 22 Aug 2018 02:19:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBEC16B21F6; Tue, 21 Aug 2018 22:19:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E6E466B21F7; Tue, 21 Aug 2018 22:19:20 -0400 (EDT) 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 D5EDE6B21F8; Tue, 21 Aug 2018 22:19:20 -0400 (EDT) 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 8E4DB6B21F6 for ; Tue, 21 Aug 2018 22:19:20 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id l65-v6so290867pge.17 for ; Tue, 21 Aug 2018 19:19:20 -0700 (PDT) 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:from:to:cc :subject:date:message-id:in-reply-to:references; bh=/S5I0vc4uBBKNzwfsj2Hye0o7S98ojvXNwNXYVIqaJA=; b=Xl3wbzEjZdn3LD07FVrHrZacG+bnmM9tC2mLvt6Vaqkb4+TfMIQQexPBdsoFokANZ0 TPvf0dCClYCJakHuncTUPAyvNtrz5Ph2oX4wp6osi+wU6qiwigGbyF/cbTPx9382wQIQ 6hztQWUsX5ncKdtNSPNRp5ozJdRZ91Qjgnt/Is8tFeJ+gm3Y7ydrMIlEi8tsC5D+bOew mOe/f4IzxDtmdv9hFMsAAsQhPTp4O2rE4f+ZgArKsy7u0qK4vc/rnzImI/p4ynjSzm78 Bc3n5jGo0+1IuYGMiNQkpgMrSKV5FSnJO2HqGzPs+m0PslMlbySwGF5m5PusPU/M0PIt NGDg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlFrINsT2xbioou5fNKadc68EnY/WKTbis4zjaNYdmTgRZmD4Wqe MCbXOZYypM3WXYRYMvbvEVfnRorfpALYZ7XJPNJzG9BMdGdNRS1kNOhwps3kAX0XhCBewXelw1t thTnOAniS3pNIlPierzBDb3GuhXpf7HJNhPT9GNNlrm09QjZy9+jZn4lJ37LbIvqT7A== X-Received: by 2002:a63:5856:: with SMTP id i22-v6mr10215757pgm.232.1534904360252; Tue, 21 Aug 2018 19:19:20 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyAQxk824oN6T7VHjvcZ900WwsJF800vyPxsUJyo6jQaDjE54BYU0B3XzIU5VX7b1p77Bz0 X-Received: by 2002:a63:5856:: with SMTP id i22-v6mr10215732pgm.232.1534904359598; Tue, 21 Aug 2018 19:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534904359; cv=none; d=google.com; s=arc-20160816; b=ruGiqLqbYcNPlPL2PGQoW6B3/KI8O9VIvIbbRXUMzjZf5Pf1ak88IkDO6xRI5mefMr DpfrY9ivx1n+jYu+xpEszdTd+wdTGjNAwDwG1WPLX1MWjA95OIBNJG1i7vy0w62qetFH fiweUAgh87wvHoZThsEpTew7U7Uiy7dLGcdy7ChhmkJknuQ7itI85KCCqHEqwNBV5+1L M8uOWvR6UcxxnE3nKQNwIOWoN5O5Ped4Slg1R4j4JaStEfAmT9svJoaYH5Qck/NRne4o ose9ArgSbWUvtSoXfbWebwDBgxNK9mT+gLFa/XXqXuX4f6BKM3DS6b5gD25PXeRm/Bnr MpJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/S5I0vc4uBBKNzwfsj2Hye0o7S98ojvXNwNXYVIqaJA=; b=v6Bu3+1Zz8c24vKT5lY41EDHCqPaaYwDmom8PzYz4U33TdaVZJVvxJJOuCjvPDMpBd GlnP2g0MJfyctTYfNgHjQoU+dn0LN2PRLO1yiygbbeaC5p0VCfLUEG5fdFW6EQqPIuv+ n55H6UEQF/dc5EDEr2rbgeZg825jNk/12qLc8Y84z6vM/QcDsiRrYrZD7/8YfA82XREc yBPiQEjXFuy1sdru/7vi+OQ+Ke3jTay/ID8nv2OwBKHlWEwr9Yaov85l0JJLrgTbsrG4 Xo6hXyGxIQvr9D0J528X35mm9f+/J2a10dvT6fLt6pg590RaZxNs6eb4C75ZCBXJYhLT waJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=yi.z.zhang@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga03.intel.com (mga03.intel.com. [134.134.136.65]) by mx.google.com with ESMTPS id 30-v6si451463pgt.678.2018.08.21.19.19.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 19:19:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 134.134.136.65 as permitted sender) client-ip=134.134.136.65; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=yi.z.zhang@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 fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2018 19:19:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,272,1531810800"; d="scan'208";a="83404610" Received: from linux.intel.com ([10.54.29.200]) by fmsmga001.fm.intel.com with ESMTP; 21 Aug 2018 19:19:18 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id 95AB55802C8; Tue, 21 Aug 2018 19:19:15 -0700 (PDT) From: Zhang Yi To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, pbonzini@redhat.com, dan.j.williams@intel.com, dave.jiang@intel.com, yu.c.zhang@intel.com, pagupta@redhat.com, david@redhat.com, jack@suse.cz, hch@lst.de Cc: linux-mm@kvack.org, rkrcmar@redhat.com, jglisse@redhat.com, yi.z.zhang@intel.com, Zhang Yi Subject: [PATCH V4 4/4] kvm: add a check if pfn is from NVDIMM pmem. Date: Wed, 22 Aug 2018 18:58:10 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: 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 For device specific memory space, when we move these area of pfn to memory zone, we will set the page reserved flag at that time, some of these reserved for device mmio, and some of these are not, such as NVDIMM pmem. Now, we map these dev_dax or fs_dax pages to kvm for DIMM/NVDIMM backend, since these pages are reserved, the check of kvm_is_reserved_pfn() misconceives those pages as MMIO. Therefor, we introduce 2 page map types, MEMORY_DEVICE_FS_DAX/MEMORY_DEVICE_DEV_DAX, to identify these pages are from NVDIMM pmem and let kvm treat these as normal pages. Without this patch, many operations will be missed due to this mistreatment to pmem pages, for example, a page may not have chance to be unpinned for KVM guest(in kvm_release_pfn_clean), not able to be marked as dirty/accessed(in kvm_set_pfn_dirty/accessed) etc. Signed-off-by: Zhang Yi Acked-by: Pankaj Gupta --- virt/kvm/kvm_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c44c406..969b6ca 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -147,8 +147,12 @@ __weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, bool kvm_is_reserved_pfn(kvm_pfn_t pfn) { - if (pfn_valid(pfn)) - return PageReserved(pfn_to_page(pfn)); + struct page *page; + + if (pfn_valid(pfn)) { + page = pfn_to_page(pfn); + return PageReserved(page) && !is_dax_page(page); + } return true; }