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, }; /*