From patchwork Mon Oct 22 20:13:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652431 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 A64215BB5 for ; Mon, 22 Oct 2018 20:18:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EA0728EC3 for ; Mon, 22 Oct 2018 20:18:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82E5428ED4; Mon, 22 Oct 2018 20:18:49 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2CC6D28EC4 for ; Mon, 22 Oct 2018 20:18:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 24C142117D260; Mon, 22 Oct 2018 13:18:49 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=dave.hansen@linux.intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BAEE12117CEBF for ; Mon, 22 Oct 2018 13:18:47 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="273527112" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga005.fm.intel.com with ESMTP; 22 Oct 2018 13:18:47 -0700 Subject: [PATCH 7/9] dax/kmem: actually perform memory hotplug To: linux-kernel@vger.kernel.org From: Dave Hansen Date: Mon, 22 Oct 2018 13:13:29 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201329.518577A4@viggo.jf.intel.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.lendacky@amd.com, mhocko@suse.com, linux-nvdimm@lists.01.org, Dave Hansen , ying.huang@intel.com, linux-mm@kvack.org, zwisler@kernel.org, fengguang.wu@intel.com, akpm@linux-foundation.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP This is the meat of this whole series. When the "kmem" device's probe function is called and we know we have a good persistent memory device, hotplug the memory back into the main kernel. Cc: Dan Williams Cc: Dave Jiang Cc: Ross Zwisler Cc: Vishal Verma Cc: Tom Lendacky Cc: Andrew Morton Cc: Michal Hocko Cc: linux-nvdimm@lists.01.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Cc: Huang Ying Cc: Fengguang Wu --- b/drivers/dax/kmem.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff -puN drivers/dax/kmem.c~dax-kmem-hotplug drivers/dax/kmem.c --- a/drivers/dax/kmem.c~dax-kmem-hotplug 2018-10-22 13:12:24.069930387 -0700 +++ b/drivers/dax/kmem.c 2018-10-22 13:12:24.072930387 -0700 @@ -55,10 +55,12 @@ static void dax_kmem_percpu_kill(void *d static int dax_kmem_probe(struct device *dev) { void *addr; + int numa_node; struct resource res; int rc, id, region_id; struct nd_pfn_sb *pfn_sb; struct dev_dax *dev_dax; + struct resource *new_res; struct dax_kmem *dax_kmem; struct nd_namespace_io *nsio; struct dax_region *dax_region; @@ -86,13 +88,30 @@ static int dax_kmem_probe(struct device pfn_sb = nd_pfn->pfn_sb; - if (!devm_request_mem_region(dev, nsio->res.start, - resource_size(&nsio->res), - dev_name(&ndns->dev))) { + new_res = devm_request_mem_region(dev, nsio->res.start, + resource_size(&nsio->res), + "System RAM (pmem)"); + if (!new_res) { dev_warn(dev, "could not reserve region %pR\n", &nsio->res); return -EBUSY; } + /* + * Set flags appropriate for System RAM. Leave ..._BUSY clear + * so that add_memory() can add a child resource. + */ + new_res->flags = IORESOURCE_SYSTEM_RAM; + + numa_node = dev_to_node(dev); + if (numa_node < 0) { + pr_warn_once("bad numa_node: %d, forcing to 0\n", numa_node); + numa_node = 0; + } + + rc = add_memory(numa_node, nsio->res.start, resource_size(&nsio->res)); + if (rc) + return rc; + dax_kmem->dev = dev; init_completion(&dax_kmem->cmp); rc = percpu_ref_init(&dax_kmem->ref, dax_kmem_percpu_release, 0, @@ -106,6 +125,9 @@ static int dax_kmem_probe(struct device return rc; dax_kmem->pgmap.ref = &dax_kmem->ref; + + dax_kmem->pgmap.res.name = "name_kmem_override2"; + addr = devm_memremap_pages(dev, &dax_kmem->pgmap); if (IS_ERR(addr)) return PTR_ERR(addr);