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)