From patchwork Thu Aug 9 10:53:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10560725 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 B324114E5 for ; Thu, 9 Aug 2018 02:14:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AC282AC87 for ; Thu, 9 Aug 2018 02:14:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E7E82AD81; Thu, 9 Aug 2018 02:14:41 +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 3264C2AC87 for ; Thu, 9 Aug 2018 02:14:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 510856B000D; Wed, 8 Aug 2018 22:14:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4C0FB6B000E; Wed, 8 Aug 2018 22:14:40 -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 3B15F6B0010; Wed, 8 Aug 2018 22:14:40 -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 ED3686B000E for ; Wed, 8 Aug 2018 22:14:39 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id u4-v6so1935574pgr.2 for ; Wed, 08 Aug 2018 19:14:39 -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=zieWptaV9vB5PqQkkJ6YZzjdQJZ+OJerLc2Ac8SiI5o=; b=bzuaD5sQ0G1P3vN/BPEzYCr4x8ecX5jzpj+PJu+CtkDM7PqWH/+6/xCKK5oRPkGbBj 3whG1EtO6OPARdYtmRNNIimTZF0rItzxDOwaubxvlZ65Vm16R9/r3LLXdJsC4FKoPidM z2o8P0KW8BPb5/T1dET6lv/AWbag1KX9cXE/70F/XXZ7w1aR9eHY3/bo07gobKRum0LW a2/Vtw2jn6xJnvrcWbZ2N6d6TkHzhynb8IvXelGyy2xl4Il5UT3GY8hCiCBwkZwJ2m0g j/IPyU003zhfNgKAAEOID5RkK65vHoltahbgC2GdVSkdoTs3Irf2IWZQEfyw3QhVzQVI HZEA== 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: AOUpUlHjJr/jOJgj/SVA9nZAEmVn/LF0MOTLW0kngeApfRCoW/ansv99 ckcRsleu7xTDsNP0q3K9v9yVMWAPYa+nAVagUXiP8zxdoDIyuDxgVSToiQLszufyDRT8/oORLsc Y170QQvD2x34Hue++FV0j9T18l29kvitv8PTIzJHAjdF2P/OEWPxLniuPNLipmov5Ew== X-Received: by 2002:a62:c218:: with SMTP id l24-v6mr210730pfg.185.1533780879635; Wed, 08 Aug 2018 19:14:39 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxMmnyh71EIEt0HrbmRxxoBaXoPTJcSAoEsDPfsbsCj1RlRe7ys7PrvM6tFaf62Mo6+l+zQ X-Received: by 2002:a62:c218:: with SMTP id l24-v6mr210698pfg.185.1533780878922; Wed, 08 Aug 2018 19:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533780878; cv=none; d=google.com; s=arc-20160816; b=01HOS9r22nesZh36ZcVu7FSn5b69R4rbUFYh7r1QQUf9QcSQR6nZSZlN0/inuXXdhM iM/sx4VRkQtOWrPBkgpFN83bBoGauNCE++syaEYHum+yqPKguOtg/phYDdVzZzuzTk8K ELVJ+K3NqhTIKoxpDONqieHMItmFDGpyij6CoH/ZoVA2DOhF/SPgP+joXVfzCW4iY/Rr kWK3VROmy6XGGQts7SuF8692z9OsVDaTgfWNVe65lc/vbxWCgCb/14ZG0u2CoO95mJRV d5pu+HpuJhDEWxShjaYT7TOs6qbV1Njso6dsYLBDEnFiNeGjciXktlEAhYvdk5ap3Lii wX8Q== 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=zieWptaV9vB5PqQkkJ6YZzjdQJZ+OJerLc2Ac8SiI5o=; b=mSid2QHNqcV6rndZVgVtmN3O2JtcHQX0mobjIwK4dfwKdNPAJcmR5DUxf1CWG6LPQx 1S08+VFf8lMtiShkYTqkiGak9gm3LVDzMvPJyE2ccrKHrboS8MXf27CrRBFI1uV38vPw 2P5JFzwimH8Wmde7SydwBjnu0k7o1jdSoODNY6ox1gb0FBu/bHuuKqaFkfyN2It9UClM i0vvxUgt0vzVkfMiramvJY0xGKhx9dsWUXkcdGl1P0qefszho//y81k3ZTFsHeeaD20T A3/ROSAyrFwQYZWd2Ok2yHlD8/1B8Vq0g5IlVUUzqEoSUdy68k23uPLqA5oLs/v9IEXz Dwag== 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 l7-v6si5950968pgs.35.2018.08.08.19.14.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 19:14:38 -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 fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Aug 2018 19:14:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,213,1531810800"; d="scan'208";a="74999559" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP; 08 Aug 2018 19:14:38 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.78]) by linux.intel.com (Postfix) with ESMTP id E129B5801BD; Wed, 8 Aug 2018 19:14:35 -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, jack@suse.cz, hch@lst.de, yu.c.zhang@intel.com Cc: linux-mm@kvack.org, rkrcmar@redhat.com, yi.z.zhang@intel.com, Zhang Yi Subject: [PATCH V3 3/4] mm: add a function to differentiate the pages is from DAX device memory Date: Thu, 9 Aug 2018 18:53:21 +0800 Message-Id: <2b7856596e519130946c834d5d61b00b7f592770.1533811181.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 --- 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)