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)