From patchwork Tue Jul 10 17:01:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yi" X-Patchwork-Id: 10516473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13A64600CA for ; Tue, 10 Jul 2018 08:23:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03A9028B68 for ; Tue, 10 Jul 2018 08:23:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBDEC28C71; Tue, 10 Jul 2018 08:23: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 6FDCB28B68 for ; Tue, 10 Jul 2018 08:23:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A36C6B0269; Tue, 10 Jul 2018 04:23:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 850756B026A; Tue, 10 Jul 2018 04:23: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 718F06B026B; Tue, 10 Jul 2018 04:23:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id 315946B0269 for ; Tue, 10 Jul 2018 04:23:40 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id q21-v6so13521107pff.4 for ; Tue, 10 Jul 2018 01:23:40 -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=1IVFnIlSc1pUwU7We0xKU18MpAgTcbYBfHGMF6cOeZY=; b=ecteMpaKkrseYciORgQrEBNlgloOHSxHJ9Z0fBGaom5/dQZDwRe7gHUAyA5FGe9zLR RoQ7/1oXF7lyPrBrGtVAa8widcF0Ccg8LQuKPXo+h1ybxYzOD9zLNXJOYgFdmiI9CLgs RRequKjzAuoq+s7F+BIZFfN3E6xA5yboDkV4humNHPRj3BAp/1tl1VnJz014fHi2HArd olyfVf3rBmM0z0qyRfVV9wDNveOOFFMmN7zuzdGl5KWIA855306++g3WQbeQRmaR9ihN Sy6DIx5mKXkMX/IaL+qwWgFg5PpCFXSc8qjMXM+G0UbL57JhDqmP9AgycCAvTbbISyzT UWcQ== 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.120 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: APt69E1u4mKfY5aHXnqKA88ldXK+epCyf+a96XqNe3QsNZU3cZC/SILX u584E1gFVAEM3La/NGhVy18dUUTMAazCvhkNqCUKXm6/aQH0+v5XsNkjz4PaUr+OiMGvS6BgwWY 44HVU9+oLjWkXNzj7jcqo2OWWeiZmqyjqTl5Sy/U0C4Bympt7k1BHUE9PZZYLQpd/ew== X-Received: by 2002:a65:520c:: with SMTP id o12-v6mr21995836pgp.15.1531211019879; Tue, 10 Jul 2018 01:23:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpephpvuM7WYWoBQIXx/4Dqn3VswSBZ5u2av2Xbab1DdsDmWWPFUwIw5zVmr38fDZDQG7ck+ X-Received: by 2002:a65:520c:: with SMTP id o12-v6mr21995798pgp.15.1531211019092; Tue, 10 Jul 2018 01:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531211019; cv=none; d=google.com; s=arc-20160816; b=bdxDqZhs4uPJG1looOHvvLXh3Dw19TzuVV7ip+koBnWaavOTmRN1dNm3HqGdaWed/K 0NdQQR2RazXTfe+jT3CEkgAj8Ue6fOzrAYqt+aRfYKaIKsRW9pegHX+UawAyKYiVxjQa yvkXVLg6NQ6qEvReyiW7q5FdAx/CYjwc/FtuNSlPqkzfYBvijQexP7Inf+NMSiJYh+mc HIJGLMeUs+Qtg5E529ju7oD+SVXdTKy8E2zyuOmb0In4BOVkxAhsUl6I7pAiuXYcvLo2 SPzP1rlBohuHDtJLPBtTEmbp6KeaxUnJxmwAKTX5XQX+l8/PealswB9DnnWdOROjAjq8 xSfQ== 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=1IVFnIlSc1pUwU7We0xKU18MpAgTcbYBfHGMF6cOeZY=; b=oRpZY0NpK4YKVoUGyh5UhyqxLC/rz7ozDVQgipc02mYzWMabtJm/WnwNKEgP3EGXL9 m8jK6COIreC+ode0IyT4XPxxaANFD16jsZXviLvgOeUJz/ido2RdM5c20Ubq1x9eYDCo 4qfBQEv6KzHmg1/1gJsWboRKJgnLk+OeKZMVNTTMprQvkyl1UCf2x+aho2w36DNezCE6 UauhAzCmwAGeyZwB7BI5AZ0ATwBSVZonW9kk7PO8aH2CEm9qlGtzJBjLfiXGju4bnGGo wfP0aok+nUhfFL8s/6IjL0ZTB0J4s6CJabfWDVOB+Uohadbj9rTehyliv/6ZRjSeNU9h kQxA== 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.120 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 mga04.intel.com (mga04.intel.com. [192.55.52.120]) by mx.google.com with ESMTPS id u1-v6si16367055plj.43.2018.07.10.01.23.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 01:23:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of yi.z.zhang@linux.intel.com designates 192.55.52.120 as permitted sender) client-ip=192.55.52.120; 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.120 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 fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 01:23:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,333,1526367600"; d="scan'208";a="70108231" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP; 10 Jul 2018 01:23:38 -0700 Received: from dazhang1-ssd.sh.intel.com (unknown [10.239.48.78]) by linux.intel.com (Postfix) with ESMTP id 43338580388; Tue, 10 Jul 2018 01:23:36 -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 V2 2/4] mm: introduce memory type MEMORY_DEVICE_DEV_DAX Date: Wed, 11 Jul 2018 01:01:59 +0800 Message-Id: <7e20d862f96662e1a7736dbb747a71949933dcd4.1531241281.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 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 --- drivers/dax/pmem.c | 1 + include/linux/memremap.h | 9 +++++++++ 2 files changed, 10 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 5ebfff6..a36bce8 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -53,11 +53,20 @@ 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: + * 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 differentiate the pages on NVDIMM with the + * normal reserved pages. */ enum memory_type { MEMORY_DEVICE_PRIVATE = 1, MEMORY_DEVICE_PUBLIC, MEMORY_DEVICE_FS_DAX, + MEMORY_DEVICE_DEV_DAX, }; /*