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: 10652441 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 CC3C314BB for ; Mon, 22 Oct 2018 20:19:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B66552916B for ; Mon, 22 Oct 2018 20:19:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA2702916E; Mon, 22 Oct 2018 20:19:00 +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=unavailable 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 38DF12916B for ; Mon, 22 Oct 2018 20:19:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 343876B0269; Mon, 22 Oct 2018 16:18:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2F6036B026A; Mon, 22 Oct 2018 16:18:50 -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 1CA496B026B; Mon, 22 Oct 2018 16:18:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id D11006B0269 for ; Mon, 22 Oct 2018 16:18:49 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id v7-v6so31240097plo.23 for ; Mon, 22 Oct 2018 13:18:49 -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:subject:to:cc :from:date:references:in-reply-to:message-id; bh=FG3UhqoiLA828NPdVcKVzeGSXrsaOBAyt9ftrR7wSMg=; b=Gvnuzbp5O2y343/Kw/zC5LOpZcfo825PgxPsrBwlY+G9ScPj6e5anzsFWuejW2LSWQ fB3RDnP2w6GaFuFf4aQ/bMNBVEyMtvWqs+gC7fJF+OdmnAcVLxyTza9OpooaWMY9Np2b 8qf2BkSOVZahZ4ztBuIx5O1U2QnA4vF+RYYuHT4dNSURstoDrFIglaT/yjFbJrj5WCUp Krxx+//vB+v+4kPqzNDp/97Bzmu56Zpicf6PhoLo7oqa4bjpPDmQUBy91lc/tkn2qHUe GMA2B5W1b1zKJv3+duVoNbvkJnCzJP3SWrcnfz5rnhL1ZuLyEsJk4GowHvM+kqBTyUrI BSTg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ABuFfohgfJf+TXA48ThfAG0wqz7nlfpCuC3x5cDYnHxtr3dAwlTjwy8i Ta5+BQDC3Vr4aBWWIbMBT1NcpO7UU1HtAwT5CN5EWs+lKaXLo9Ws/dbqPrbH2eg2ZaVzVwxjqn0 JijOKoCdY6AFHhv0ndy9V9g/Q9ut3h+yscVT3YhbIG3//N3/mP7bI479wtzPtS+SBOA== X-Received: by 2002:a62:35c2:: with SMTP id c185-v6mr46633721pfa.69.1540239529517; Mon, 22 Oct 2018 13:18:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV62YLBkwzvHyIFUCaIOuhPzonOlmu/4auxmWc8BTSsgX8UhxUnEp7wZA1yiRM/3DjPICR2rG X-Received: by 2002:a62:35c2:: with SMTP id c185-v6mr46633653pfa.69.1540239528253; Mon, 22 Oct 2018 13:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239528; cv=none; d=google.com; s=arc-20160816; b=QiKjmnhLqfnh11yZkq+1G1KcjABwdMRGnNA9NgLjXp9p/XnqYVGM9B+wBw5Xcf2zPm SZGtE6fmkn0GIH4IE9NA5te2l1IcM8p5YpVO4gdw0pHyL7478B/OPOkkFUCjyz7iRWvp D/iLC+O059k3I3yfk0gkUb+fLPOIhmFhVrFZALB2yyVx/VKn25J2pW+8004T3GmdFUyQ g35sKNIfLt8427hienk2KdESFBJGLcjiJQ320HJaYf2YMne2I53cYYpTfQc8jrVwjY3j BozQuDzHw3Aw0lgVjgAvrjVwfs98oNMkTkcLMjV4NKPIQFItuUlgZravTgTf17mucBrm 4g4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:in-reply-to:references:date:from:cc:to:subject; bh=FG3UhqoiLA828NPdVcKVzeGSXrsaOBAyt9ftrR7wSMg=; b=V4ujFAdquM3GiEuP/1ndsdP3emWBebyZdxIPQenJRgR/RuRzIZqN0lXjhOS6vo2sia y7ZgK1AwjvDHihEUhErCHSBbZa6RMzL1wBj7aRa/5do5zpNGiOcCsdxu+wfQj56qZ5/s d/rC/eV/C4QkaBkxyTh46lxjRMijF/OHJpdhAMhqj9ao1BEn5GAZB3f0nzyevnVwbmi7 YHt9R9Pfw7QQCMsnFipQZJMwu3iPkLB4cTZHUJwr0r8vmh6QtJC/O2+m7ER8RYUdUNP+ hm6zwBAUGn1aABoAff07gcOEf62B81R0uEjXlXZLNxRbvSzvovA1S6Eulv9fZwVq99UC JTyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga05.intel.com (mga05.intel.com. [192.55.52.43]) by mx.google.com with ESMTPS id r15-v6si34776466pgh.88.2018.10.22.13.18.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.43 as permitted sender) client-ip=192.55.52.43; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dave.hansen@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 fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.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 Cc: Dave Hansen ,dan.j.williams@intel.com,dave.jiang@intel.com,zwisler@kernel.org,vishal.l.verma@intel.com,thomas.lendacky@amd.com,akpm@linux-foundation.org,mhocko@suse.com,linux-nvdimm@lists.01.org,linux-mm@kvack.org,ying.huang@intel.com,fengguang.wu@intel.com 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-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 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);