From patchwork Fri Sep 7 18:03:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10591917 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 91D33139B for ; Fri, 7 Sep 2018 09:24:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BA3828537 for ; Fri, 7 Sep 2018 09:24:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FE702AD99; Fri, 7 Sep 2018 09:24:28 +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 1D41D28537 for ; Fri, 7 Sep 2018 09:24:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 279E86B7D9F; Fri, 7 Sep 2018 05:24:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 250CB6B7DA0; Fri, 7 Sep 2018 05:24:27 -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 13FB76B7DA1; Fri, 7 Sep 2018 05:24:27 -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 C538C6B7D9F for ; Fri, 7 Sep 2018 05:24:26 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id o16-v6so6962977pgv.21 for ; Fri, 07 Sep 2018 02:24:26 -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=eG50MBjFSHYFTGbk+RhuL1ugFO5HrMkPaZ0Q7aTdp6n/8W1vsODwkmen7wPwwkqqqM h0O8jBtXdOS3vKr+pny/Cu6S8jF2bio9itilZcvEA9TX9+E5qWsF7A64tKFoWF4d8sLE RVsD/WnOIiazGGDvr3xVbzEIA644vKvevv/oywhxhJwFLaEGeOJBRUubkPIinz3ggpL7 uJW0WQdsbuNRD33UuYsbSw5Nlh+ZJ1K+72s6tlRtnkF02lQ7bSm2YlgpOZPLpqcL10AW BC5J9IuaXIYeAINFlivn7BQCSwlTPDYeXA2fsZDEYGfa2uYlMKoKhNXVNVfKH2JkQAJ+ YasA== 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.100 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: APzg51Dl42F1yf58+KA1D7fRxkpMhvlAMLpreVXzS1fbYdutjJ0NrCHm vBJ5ZCvMpofLvkpR+ZL8uVW04WdmUXX2VWcp58EcQPiGPK1UdXMp2y/eCW5abTmCk/GBbadilz6 BGWMmEzBIHdpDgC+ZaiO98K767tQCShx+lzrTTt6QIwUNOFiTty1QACQcOcWqZQo8uw== X-Received: by 2002:a62:56d9:: with SMTP id h86-v6mr7481716pfj.229.1536312266491; Fri, 07 Sep 2018 02:24:26 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda7ZTWIpk7juM1wg2lxWxrlZ+n5is6EiF210U+66/nCVnOYijDzQsTdiiuBSjoL9YvYQFMK X-Received: by 2002:a62:56d9:: with SMTP id h86-v6mr7481653pfj.229.1536312265660; Fri, 07 Sep 2018 02:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536312265; cv=none; d=google.com; s=arc-20160816; b=eohZBuqSHLMDTawrhTIKpvLhS6IJ+ha51cZQYj1BNS+9bLYiOQCZ+b3QLZk5fju8BG t/Czu7y4vXctdrfqbqPQ0VrXEaNKgcGnZxNkjkonm0B9vy601uZVxQ54/KJ1DiQQRvbH RRFxEb6S7nxhMdT6GhYIhwfRehRTuFxbt56zLRoS1iJ5woyWaLJHWZs0luySE+gdI19Z 5eGX0Vg4lxE4/4A6j6kbuyHw6l9XYvNunfXoJEnvENGUfW20AgcooKVwFy+cpcQ+4xdf ecxVubniO2KqY7YyXgSRJIZzQu6se3KyDzIFYmjOml7ODZuoNRDl6nL31DsUGBE39/Cq B2yQ== 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; bh=GsTG8lALSXFkkbPi8ZceiT5v9rNJDXjkmFjyPfdKasA=; b=DwgADNjzRJod1ITdU5bUwtLMan0pnnAswliixbGIw/Me1IfXgPCqBrE17Ux44sZFI9 L8CCRwVLuip9sZ8eEkIC/bRnoQqtT9ZPOtEVZp1qPXvQtH0TMt/1uWAtnztB4AY8fYLJ g8QQ8tjbSGn+ziu9NVkSEfSham0mj2tZIZvzXLepo0vQMzM8PTZ+PjnUF4r8gGTYYCdP Yv8ctbnER/Ifumsvoy/9aOTe6D8UiFB6nQRpyysysmzPUUAoxUnUrYQKXf/pyDS599Xx jA9XvMHGbl0EZixkxdR6YwIjLe2dwG46tQ1pmJQ8BzeVnbFIEK1o4h7abNIQsjrgpSaj FB0g== 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.100 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 mga07.intel.com (mga07.intel.com. [134.134.136.100]) by mx.google.com with ESMTPS id n124-v6si7883124pgn.43.2018.09.07.02.24.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 02:24:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@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 yi.z.zhang@linux.intel.com designates 134.134.136.100 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 orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2018 02:24:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,341,1531810800"; d="scan'208";a="71327138" Received: from linux.intel.com ([10.54.29.200]) by orsmga008.jf.intel.com with ESMTP; 07 Sep 2018 02:24:25 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id 708385802B3; Fri, 7 Sep 2018 02:24:22 -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 V5 1/4] kvm: remove redundant reserved page check Date: Sat, 8 Sep 2018 02:03:28 +0800 Message-Id: <26f79872e78cc643937059003763b5cfc1333167.1536342881.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 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 Fri Sep 7 18:03:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10591923 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 7E28D139B for ; Fri, 7 Sep 2018 09:24:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7726E28537 for ; Fri, 7 Sep 2018 09:24:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B76A2AD99; Fri, 7 Sep 2018 09:24:39 +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 F33B32861C for ; Fri, 7 Sep 2018 09:24:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 008156B7DA1; Fri, 7 Sep 2018 05:24:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EFA836B7DA2; Fri, 7 Sep 2018 05:24:37 -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 DEA6C6B7DA3; Fri, 7 Sep 2018 05:24:37 -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 984316B7DA1 for ; Fri, 7 Sep 2018 05:24:37 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id r20-v6so6970550pgv.20 for ; Fri, 07 Sep 2018 02:24:37 -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=Rui0iZkHRQ+LrOWR+c2CJ/yzW7zyehrMs+SjL2fgu3lCWfHSf1CD/9DPkWK21Fd4a4 VHDHzPdr6Mk95pYxKbjzfIZyVWVhxKdRBKXSvaCo3TN1fGXrasd9EcbnsJg+FFSFCksI 7dDtkM3Xz6kOlReYUMmxeDDFoNXu9ineqt4Zr7apmplQCi/wyfsauFTxeLrS00QGf6hK j6/AFmsWzLUuRoh2gDH77hsAWCC1iOcoBCLATBf47Q/Dyix/af5lzZYtUjSvSgnJOy20 OxLZJFdLxru1SLDwS0INsfQdzbv90jm+Hp7YK/2zOWa959lP/iUSDKcri8bKPgQ2HhCV l9Kw== 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: APzg51Aon5tyw+caepQnYevTKY5H+O2YkFeJ3re1w0CTVLKSi/fsaULt INpKtY003erdFzFw/Ia4jgNHLXTLcP1qrkUPVj/SjBEgIGq1Ye4oifPSCOCa/4cGDrum732srao lD8X1eJOPHlwYjtV8pbNO508/6I/YOnPtb6rmIJdDLGJWkBiOoHlaqGjKlESGW6krtw== X-Received: by 2002:a17:902:e85:: with SMTP id 5-v6mr6785122plx.73.1536312277279; Fri, 07 Sep 2018 02:24:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZsqz4uTEO0P5fTAaOK+Zdl8tVASxJp4aJ0KN3RphwXlA9dGRkbOQaelY3c9wEdwsMq1HOT X-Received: by 2002:a17:902:e85:: with SMTP id 5-v6mr6785088plx.73.1536312276557; Fri, 07 Sep 2018 02:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536312276; cv=none; d=google.com; s=arc-20160816; b=nH0RYoWQaYyvaFvvfE5x4VSrtw7jMVUMt9d0T9cRvJZmusI3soX7U/0s64CJYHsTra TlPXnjog+q8M6OFEelaPR0hbtQXv3gnAyI+TGdkOkyfAoH0vWjuFTgmgEFOQ+4QeCIMS E7MP1xQ0MyqVxPUUXDeVk7P50t9X673g8BLvweUvs7kIiao9viLoyx7YhhbKXYatm+ER DjFyoBYcU8HlJvoKFB/w/jNWTIuxXRjvPwj/8+tMJQP3tKzJKL0QnshCtSW8kFvTvREm DMMRbXLvgQorPK6KkPMmXiBdfVeNr0Q8+WQJsuR6C/MhnHxyWmlMJEbUu2qnbiBzrUcV aQdQ== 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; bh=JwWIqrnfqvRtRk9oqwaC6IStXdXj/6nsmHZH6RgulUQ=; b=XPCwd3zqP3nab5A6uBDsnF0MQITcAmuT3zb9Vf/fqlZ9CteqKJ3ueAbH8t6b4tXBeV kZiONTnWJPD10hha9mcfivZaIKWiEnydJiC49/JkV0ap2DmwN0GZ18NOeGP0/69JyuLA jK4TtscUWZWqYTbj5RD2+Isd/ah9qGDcZ60u40i4Upg7UV8xrKi47z/1ACWwSU9tIg1f +5yzJFMQgt8BuVacYkhMUoTE79ipHI1/qRzK+dDGAotMRWO8pVxs9K1kMaHfz8d0laPF jBf4hAB7CZkg1zincdMOM6cqPN0lksYeG3xStAfAEy7TzuoEAhxgL1zA4ealSWHHkOXC s6Pw== 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 u15-v6si7957939pgi.76.2018.09.07.02.24.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 02:24:36 -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; 07 Sep 2018 02:24:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,341,1531810800"; d="scan'208";a="72355804" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 07 Sep 2018 02:24:35 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id 06B1D5803DA; Fri, 7 Sep 2018 02:24:32 -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 V5 2/4] mm: introduce memory type MEMORY_DEVICE_DEV_DAX Date: Sat, 8 Sep 2018 02:03:39 +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 --- 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 Fri Sep 7 18:03:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10591929 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 0919E139B for ; Fri, 7 Sep 2018 09:24:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0274A28537 for ; Fri, 7 Sep 2018 09:24:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA8CB2AD99; Fri, 7 Sep 2018 09:24:55 +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 8386C28537 for ; Fri, 7 Sep 2018 09:24:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 909AC6B7DA3; Fri, 7 Sep 2018 05:24:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8B93C6B7DA4; Fri, 7 Sep 2018 05:24:54 -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 7CFED6B7DA5; Fri, 7 Sep 2018 05:24:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 3A5AC6B7DA3 for ; Fri, 7 Sep 2018 05:24:54 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id h65-v6so7247550pfk.18 for ; Fri, 07 Sep 2018 02:24:54 -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=D1LMBYCsN2SBuubfO1+pEYtYi9wOlIKcHJy6v36OyCtuCW//BkV9/1Nc/iuU3ksLHu JwJzlbDhKLm9G5izvm6L7u+I9soxmfqlxJ/MNauTYOKjCWZwJQyN36qxKxdAc7onZi5u Xqv9G81z2TodQKpt3HBEVZNglZlsRMZ5t7H0OGMh9a1vp878QA2mCnGLkI4pnmdedq/s SCVsJenkgrLM9XLt1WueCArOqXDtgof6V8MMAOXij0qqPjWIoQRf4IbMbciFmqALsuEk N5U08LL0+UcPT2B3vrW83QLuDWl4HZAfdvVSsHM9tgfMdNb5XPtPFaQVYq/6+kdouzqW 3jdA== 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.151 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: APzg51BaUB+lY6m2RMZwTSghAMj3zRA1LXouzEhYkwcHIpZcyIbW5wPq Pt6mjYCR58YWxZ5Uhff/kcC6wUzWGBwRecGLqXkbgEnJIVPGVY6papgZvGevMdYFQsbu8xoDug+ 3r4NFr+WzYbT69bsbY6zXlEo/ay7yO2khUuwK2OaE6umxiTzqWBOv/K6Pt47ADbspbw== X-Received: by 2002:a62:d1b:: with SMTP id v27-v6mr7296672pfi.87.1536312293918; Fri, 07 Sep 2018 02:24:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZInMvnnS6am3Y+In8O4dN2Opz9wFFxKxJrX9jSMi13scHRFjIMUgUbco4oZsZgiXIjtW2M X-Received: by 2002:a62:d1b:: with SMTP id v27-v6mr7296613pfi.87.1536312292898; Fri, 07 Sep 2018 02:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536312292; cv=none; d=google.com; s=arc-20160816; b=pcDcDZjyVKUXXipjU5c7KKcdgu9JufzZFUzdNt/3nNAesntzEngq/DvQPDYbRPGzfY aOIIS6NXCaAdthAR2gc7jGIlIe5h+1x47YY9Cq9UOuVwLZPKUMnKMluSL3xJURHlBycz WEdgZUDXPl7k5itV29Rkjzd1t390N4xia37LJpmInzfoPBXBzyqcPuz9LkBjL6Zfq1Yp t57p9IZAwQrNe2JCSE2FXdbHTm12o5xbjsIyxsxzM9lVwOBbb57L+LfzpCZ6pZD1Q7ZE tOoujWwKmjEZzRaHdsOqXcuN9FpMhrSD6pFxf901Ch0tBl3nUweMxo1Z3+bgVl7tZ5iM fISA== 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; bh=OA1rmIU3VRvLZ2ODVWo5LwDjZtSFf2ZqZzweBonlHn8=; b=NK+oJTqzj/fLKvA0FcpJmK+CFsYc1EwMI0SgeGG+J73BC9Tbc3atlxmJ4PfuDj3XRd 8mq9EWg20Tr8Cip+Zf/eRsOyZfW1SRFFsRrQ9NaKS2D/BANA/SqB9n5BTVY5S5xGpgOA TFHM4UxBlMrtWvNQKO4T1DKjOnJUNXWuIWOIr0HgZqjNRf46CcsWjVkHoOamimlUzTWb 1jJAhnMKl6FrbIW8dlBgqZidAaj2kRK85VJMNfX8e4ajkBvdQoKIQAn/JyRdYJB7eXtL j4WRZn0/po4Pz0gp10nFTekpzxV2/6hRg2zGFotJqUyAN7PbTEt/iAWLtkFRorsrjtx2 i4Hw== 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.151 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 mga17.intel.com (mga17.intel.com. [192.55.52.151]) by mx.google.com with ESMTPS id f62-v6si7420743plf.164.2018.09.07.02.24.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 02:24:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.151 as permitted sender) client-ip=192.55.52.151; 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.151 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 orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2018 02:24:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,341,1531810800"; d="scan'208";a="71100215" Received: from linux.intel.com ([10.54.29.200]) by orsmga007.jf.intel.com with ESMTP; 07 Sep 2018 02:24:52 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id 780375802B3; Fri, 7 Sep 2018 02:24:49 -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 V5 3/4] mm: add a function to differentiate the pages is from DAX device memory Date: Sat, 8 Sep 2018 02:03:55 +0800 Message-Id: <044309496afbb4121447dff6a453bd6b96d6068d.1536342881.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 --- 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 Fri Sep 7 18:04:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10591935 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 5C18D13BB for ; Fri, 7 Sep 2018 09:25:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5535A2861C for ; Fri, 7 Sep 2018 09:25:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 492392AD9C; Fri, 7 Sep 2018 09:25:08 +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 DADC22861C for ; Fri, 7 Sep 2018 09:25:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C174B6B7DA6; Fri, 7 Sep 2018 05:25:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BC5F76B7DA7; Fri, 7 Sep 2018 05:25:06 -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 ADD816B7DA8; Fri, 7 Sep 2018 05:25:06 -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 69C516B7DA6 for ; Fri, 7 Sep 2018 05:25:06 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id l65-v6so6926264pge.17 for ; Fri, 07 Sep 2018 02:25:06 -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=LytyC9t3+sNwUdANecEL3nPD2TALvqL+VTkhxu7fwHA=; b=J7GVZaB0fuZF4AI9eDOU5fDTb3rrXwGaxRUfs8vEl52/Gtbus30eFiolOIdPO87zoY AGrgtDMrgJ3M9lefKsJc3Ah6K36o2oV7zKp95Ck/y8U/4+PW9AxldSndPXS6uNOA81Bt ZK6A6p/7yueV5R6Spr4ppa0oXBFOd8vxtRQJvOATIFKR0cAhi+CsVZfpX71SwFQKRdQs W1SmT/M/UJ4kaqnF2IYctW0TWe8Do9NhhCi2Tgxls8TAW/dX9RpC+QjpaDEPPnSFLoGX /wkjeLIfvuYgZnsim8sqzy0n5MU/zK7Re58DiZVx1KLYr4Ms5fI3uFETCQY5w0iWt7x5 8wUw== 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.24 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: APzg51ArzSghh+Cb3pQgn/Qr8nfK1ZaqrklICWTseZsH4u6YbLW0Vz/j tMw6ctT6fsMtk1PglMW0Lbwpuq6NQ+gkBEBNPCsVjRjYSWhpxWUQhDjROFTWqXPcC3CBK81sIzu +xxU5uu3Gq3fYl42vjDZJvgXZ0uybmQc/g1vGHnODgwO/oEucXcUhyLSVaRbAqJsstQ== X-Received: by 2002:a17:902:b115:: with SMTP id q21-v6mr7023171plr.333.1536312306092; Fri, 07 Sep 2018 02:25:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZQxEuaDygbmGvUKlDZ+K3W2gEEaNi3fwhX+z7FuJKixBEajZTNId7UPwnxcMsKiEWVZakm X-Received: by 2002:a17:902:b115:: with SMTP id q21-v6mr7023112plr.333.1536312305399; Fri, 07 Sep 2018 02:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536312305; cv=none; d=google.com; s=arc-20160816; b=0Z5sL3UT/JSdiKglI9oArg1KOw3uA6IajHpGpi64yNYCdVXUeGA3P5YVi2gydNs+GQ T6SGm/p0b7wju+kTBSpJOkmNk5gdhxXon7epxfeccPfhpyYz+lSwohAjt0nkg+Dp62U1 Au4qUJAtF9DAb92D7rw8ZjVEH7DlFMirulh+np9IyRykTr/CknaUhHFO2RG738NYf8KM Pq8yIWdQstiuN3IEO4UzA3cSE22pK8Uaht2Sc7q1LL2mRkxY+WjtI6iedH6nCASicjj2 J8JjJm8BLdwiF2ArxCsdSHAoXxxC2OikYZtuk5dc6AK0xF+PkceewLjCH4tN62A3NuqX EYbw== 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; bh=LytyC9t3+sNwUdANecEL3nPD2TALvqL+VTkhxu7fwHA=; b=KmNYKEMP+ZxcVkWh/FKIUmYM+bvymrs0dseaAbr4ANFPNsFZAbiSpEx/QkQhnDt4A4 +PuTALLxylhDYpTEVg5WxTZzIAUGjr6wnj+L00G8YQcqbFep+VICLGJ0gYfBmqxJgOkn ScchoBllykiTayp9TIW53E7HRv3ZHV4z8eUz/Hse41j36WABZ9aIOdoGTJOA74JfGxZ3 tm6EWIj9aE8za9eahHPviScrEtEJL/IrqWbb71ozGOZ1fF5vzKZ8zo7hXVwfXex8meTC vIT60IhbP1qrlztqxCN9wtDCbrf53H0LVTBg5r7hkHZarz0f+phoDz9Fy5BhRSbCcpN0 qFMA== 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.24 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 mga09.intel.com (mga09.intel.com. [134.134.136.24]) by mx.google.com with ESMTPS id d11-v6si8006684pgh.564.2018.09.07.02.25.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 02:25:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 134.134.136.24 as permitted sender) client-ip=134.134.136.24; 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.24 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 orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2018 02:25:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,341,1531810800"; d="scan'208";a="81637128" Received: from linux.intel.com ([10.54.29.200]) by orsmga003.jf.intel.com with ESMTP; 07 Sep 2018 02:25:04 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.163]) by linux.intel.com (Postfix) with ESMTP id 5C75C5803DA; Fri, 7 Sep 2018 02:25:02 -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 V5 4/4] kvm: add a check if pfn is from NVDIMM pmem. Date: Sat, 8 Sep 2018 02:04:08 +0800 Message-Id: <4e8c2e0facd46cfaf4ab79e19c9115958ab6f218.1536342881.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 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 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 c44c406..9c49634 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -147,8 +147,20 @@ __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); + + /* + * For device specific memory space, there is a case + * which we need pass MEMORY_DEVICE_FS[DEV]_DAX pages + * to kvm, these pages marked reserved flag as it is a + * zone device memory, we need to identify these pages + * and let kvm treat these as normal pages + */ + return PageReserved(page) && !is_dax_page(page); + } return true; }