From patchwork Mon Oct 22 20:13:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652417 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 2421114BB for ; Mon, 22 Oct 2018 20:18:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F1F528ED4 for ; Mon, 22 Oct 2018 20:18:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03A1528EDD; Mon, 22 Oct 2018 20:18:43 +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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8706028EC3 for ; Mon, 22 Oct 2018 20:18:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56D296B0005; Mon, 22 Oct 2018 16:18:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4F7046B0006; Mon, 22 Oct 2018 16:18:39 -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 20AC46B0008; Mon, 22 Oct 2018 16:18:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id D776E6B0005 for ; Mon, 22 Oct 2018 16:18:38 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id h9-v6so30239686pgs.11 for ; Mon, 22 Oct 2018 13:18:38 -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=HhLGMqHXPhN37OxH9xQzYON6LTZTM0jTD0rBQD5tCmM=; b=rYMpIhriZ0w/sWpHrmsMqpTEcR1tyKcOn8P6Gs6rZrKtaAuHulBmHw9NMcHWMKSKiv HuI2992oKZpaep3CauxDNlSClos2maabFQo+JQLl6oF6W9SCt6rEh2/pSQbjxp3qzSAK ggGfv7wl8huMv5WfWLwCNAvAP70UxcGwCTb6FmXurHDbQNOVd9aVGxu6gi9ktO/gOmtM 9x3aFy03P+qyy11V2C4t1jv8Mf5O6LPjFesI/hl3hvEWhgDrrRij7YQzD6DoesiJoY2f jU2s0saN2LN9BCCt5BEZOF1l9Irss+sqxywhbLtp5BRftQNRS0aY4+jqiyAWKZhD9s8R y2zw== 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: ABuFfohLNmTsKjuVpknDDEU+ub/JedT92kGsJduP4aaJmwhY0D9VkyJv JLVPH9+QS6kGjcnJ6OC+Yw0U77r3gvjuwgYW5fuhJVL59WJTTD2Xa4rpBKtBnAuQHYdvRLdnkMI 3+VJTKv7HJsklhuzYb29D3udlL612+OYFHCeYzXr9TKkOIKA2m/jGHWcfHxqRvI4NoQ== X-Received: by 2002:a63:7506:: with SMTP id q6-v6mr43732068pgc.137.1540239518544; Mon, 22 Oct 2018 13:18:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV61rVAd8yHtrTGPaZqWWnbFAgpE0wevnZh3tyhG10B3oUGs+t3YsR04+2ZIOPRTlnLj2gZRk X-Received: by 2002:a63:7506:: with SMTP id q6-v6mr43732030pgc.137.1540239517779; Mon, 22 Oct 2018 13:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239517; cv=none; d=google.com; s=arc-20160816; b=gDbKy0T2T9qJE1JQcfTk7aHyXOTWKAd1D8ptTLCyd9i39o3sLBi14KJWsCU/lQYLn3 mFpf2FIWn1dVka2jMdcppnjfUdXyifzPtUM7a+9hevVcuevpWEmnHFG6qEplf2hoFsIZ 0E7ETKRI/ntpfpVi46D3EQEeUw7uu9r0HKqyP0m2cpJ060KUWfa7pRvUK2g8vhGSfmbC K7dHjuhnDcJRfeuRVOAhNfwdryX6gR/c3X4Vwu1F6GPktMMciDAvgumkR8ajByNfk4lq erAgX2AW/MtfJxDkF3BrliKvDaysMXGro0Q1KJ1MVaXQP2SoJ5Dx5SBsBih8/3i9dHmw 1EdQ== 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=HhLGMqHXPhN37OxH9xQzYON6LTZTM0jTD0rBQD5tCmM=; b=CNn4Nbmp5mb6dCwALERNyDrLh+3X6dnMp1AMNukPXpoN9vGLSZFRlIWfqqR6fOte/A pDDBMuJyNEP08KaS9WQeix+2n9n4IC7VX5iw+FzHGvNY/p9sgl4EIDZgXP0Z6QEiOBfw Aj+HopH9UPfXSx8zWZVFA84vuyuCy9jpOAkr4CWe+uArdRZhdfsrp0fa+IMBoHMpMgQS WA0h0cGdMWJ91Uq/GUKRQUJxE1FSUBFtKCnhAov5r/TjzxpmPffA8V4YsYrMxctCyJit h/zigSjPKPSLez0hytiVD45n68pXxfJantb4f8ZWa47pqA+i6X777GqZeQuzRRdzVIAE wZYg== 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.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:37 -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 orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="83268375" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga007.jf.intel.com with ESMTP; 22 Oct 2018 13:18:37 -0700 Subject: [PATCH 1/9] mm/resource: return real error codes from walk failures 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:19 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201319.471D7B85@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 walk_system_ram_range() can return an error code either becuase *it* failed, or because the 'func' that it calls returned an error. The memory hotplug does the following: ret = walk_system_ram_range(..., func); if (ret) return ret; and 'ret' makes it out to userspace, eventually. The problem is, walk_system_ram_range() failues that result from *it* failing (as opposed to 'func') return -1. That leads to a very odd -EPERM (-1) return code out to userspace. Make walk_system_ram_range() return -EINVAL for internal failures to keep userspace less confused. This return code is compatible with all the callers that I audited. 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/kernel/resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -puN kernel/resource.c~memory-hotplug-walk_system_ram_range-returns-neg-1 kernel/resource.c --- a/kernel/resource.c~memory-hotplug-walk_system_ram_range-returns-neg-1 2018-10-22 13:12:21.000930395 -0700 +++ b/kernel/resource.c 2018-10-22 13:12:21.003930395 -0700 @@ -375,7 +375,7 @@ static int __walk_iomem_res_desc(resourc int (*func)(struct resource *, void *)) { struct resource res; - int ret = -1; + int ret = -EINVAL; while (start < end && !find_next_iomem_res(start, end, flags, desc, first_lvl, &res)) { @@ -453,7 +453,7 @@ int walk_system_ram_range(unsigned long unsigned long flags; struct resource res; unsigned long pfn, end_pfn; - int ret = -1; + int ret = -EINVAL; start = (u64) start_pfn << PAGE_SHIFT; end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; From patchwork Mon Oct 22 20:13:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652423 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 6AF595BB5 for ; Mon, 22 Oct 2018 20:18:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50AE028EC3 for ; Mon, 22 Oct 2018 20:18:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 43B4F28F01; Mon, 22 Oct 2018 20:18:46 +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 A8F4128EC3 for ; Mon, 22 Oct 2018 20:18:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 409996B0008; Mon, 22 Oct 2018 16:18:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3B7376B000A; Mon, 22 Oct 2018 16:18:42 -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 259DD6B000C; Mon, 22 Oct 2018 16:18:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id D4DD16B0008 for ; Mon, 22 Oct 2018 16:18:41 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id 134-v6so12199941pga.1 for ; Mon, 22 Oct 2018 13:18:41 -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=/KXAefnM2F2s3Ny4wZVN+A3m0bVkrUQgwEadPEblYmE=; b=kEMTEvVAjjqfjhyxkEQhZPAzkGkFhK3PiLmMkgu8QHs9NbSGwDixdG4Gp8rmFtubgE 3aP/D/FS3O8VX/pV4UMguTQ5SB7K/Nw87dcIRqvoASnEXYKQUyhCpnnLnf6Vg9gSLz/P 9vM07e64XF5LQs19v/7UUg3OskVOslbS52nTqk2ZWt2vSzQPyAeKNCsTXBFHhyTQTu03 DDTwhRojBrp5j3XOdN/lCHc/e3Lq+NTEpmCwct4fRXZTOLIzhKrgMiWYag9i1FdSgtYh aDwiFK6nUy3xbk9iHyifM3A2z/Ky+lzJXz5gAw/a3bcrmQo1AvNf9wyHpH6xhQpoMVxh 0i5w== 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.93 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: ABuFfogQDGvkqYk0o+KkkQNfGdf7f4MMhm7EIJHup0K/GQ7eB9yP1X9z EdeUD/+lM821+C0V/ioVJJUcbpcyJ8vtVESjezavir+28olOdVnCdGch6l+MQrwKi3Y3qvd9h/4 M8mY5FlSb+IRxAFShnVwj+2Jae1uSE4vJvY27g0ONHtIlQONwYGcrcTwB51MrNW2RHw== X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12-v6mr45788493plb.262.1540239521524; Mon, 22 Oct 2018 13:18:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV60uqZkLuGjfc88CBGQHDi8jFxNTG9xZlbgNJBQrxt0TQ/23RClG60vHIeaF6xbLT/jAi29o X-Received: by 2002:a17:902:8b8c:: with SMTP id ay12-v6mr45788453plb.262.1540239520600; Mon, 22 Oct 2018 13:18:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239520; cv=none; d=google.com; s=arc-20160816; b=NTO86h89bysGCWaM629FvotOiLCaqu+ZFzYuBjDOM1Vvnw/MearsBStt5x9Ct0PdgT vl1SA245XXl7m9vjiK2yJ6e4fCSrJRhzdM4UT8AykVjsvq7NlLzWhyn2SHyU1Dh/IQM6 gNFBdtPOspZRxMHXvs8wZXnhTbQfTqSRPPrtdgx/Amt9BD6DTtm2lEvdtVDmpGez31sk f/OLkW21yiSF17cOGlOfH3UeGqGLbRscdNcEHM2zAVlH0hQh9hU9l1JqGVNtwlrncKrp TPGAQ5/ICNFa4vC20vv1Sj0ZhwLpe0AzjG/u76i74dNlbjYEVUv3jFy8SsC4uJzGe6jp jqAQ== 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=/KXAefnM2F2s3Ny4wZVN+A3m0bVkrUQgwEadPEblYmE=; b=0vG34W5jvX+PYqtaux5pDnOS3FjH+xT2ONauIm3FBFuTwZgzYG/xaqTvSZA3xRFt+E 8NQD+emqrl+gRNZJlXlOWxbuYRKfxqYJ7HcMnItl0A/QBBqb6rgkyz3Vj8SWtrknIL+t kOErzM3+N2TfZwwHZSOyYDNOwSKyxNajpHQShnm3CzT0fT9TsijiAuxrmYlWHQInl6TU vvk0iMTperzsc7groTkppXfAlXD0SG0zujv2oTZ7AxJShvR2TMjlwz+1Xm19EteLRl6f Nqh6wlSujJOaa0mS0FhSDTec4by2Kgx+ckgGKciqjka5tZpljMLOBj5kFs5a1N9w1JqP 7wpg== 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.93 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga11.intel.com (mga11.intel.com. [192.55.52.93]) by mx.google.com with ESMTPS id b3-v6si28711757plc.103.2018.10.22.13.18.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.93 as permitted sender) client-ip=192.55.52.93; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 192.55.52.93 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 fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="101509365" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga001.fm.intel.com with ESMTP; 22 Oct 2018 13:18:38 -0700 Subject: [PATCH 2/9] dax: kernel memory driver for mm ownership of DAX 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:20 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201320.45C9785C@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 Add the actual driver to which will own the DAX range. This allows very nice party with the other possible "owners" of a DAX region: device DAX and filesystem DAX. It also greatly simplifies the process of handing off control of the memory between the different owners since it's just a matter of unbinding and rebinding the device to different drivers. I tried to do this all internally to the kernel and the locking and "self-destruction" of the old device context was a nightmare. Having userspace drive it is a wonderful simplification. 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 | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff -puN /dev/null drivers/dax/kmem.c --- /dev/null 2018-09-18 12:39:53.059362935 -0700 +++ b/drivers/dax/kmem.c 2018-10-22 13:12:21.502930393 -0700 @@ -0,0 +1,152 @@ +// this just just a copy of drivers/dax/pmem.c with +// s/dax_pmem/dax_kmem' for now. +// +// need real license +/* + * Copyright(c) 2016-2018 Intel Corporation. All rights reserved. + */ +#include +#include +#include +#include +#include "../nvdimm/pfn.h" +#include "../nvdimm/nd.h" +#include "device-dax.h" + +struct dax_kmem { + struct device *dev; + struct percpu_ref ref; + struct dev_pagemap pgmap; + struct completion cmp; +}; + +static struct dax_kmem *to_dax_kmem(struct percpu_ref *ref) +{ + return container_of(ref, struct dax_kmem, ref); +} + +static void dax_kmem_percpu_release(struct percpu_ref *ref) +{ + struct dax_kmem *dax_kmem = to_dax_pmem(ref); + + dev_dbg(dax_kmem->dev, "trace\n"); + complete(&dax_kmem->cmp); +} + +static void dax_kmem_percpu_exit(void *data) +{ + struct percpu_ref *ref = data; + struct dax_kmem *dax_kmem = to_dax_pmem(ref); + + dev_dbg(dax_kmem->dev, "trace\n"); + wait_for_completion(&dax_kmem->cmp); + percpu_ref_exit(ref); +} + +static void dax_kmem_percpu_kill(void *data) +{ + struct percpu_ref *ref = data; + struct dax_kmem *dax_kmem = to_dax_pmem(ref); + + dev_dbg(dax_kmem->dev, "trace\n"); + percpu_ref_kill(ref); +} + +static int dax_kmem_probe(struct device *dev) +{ + void *addr; + struct resource res; + int rc, id, region_id; + struct nd_pfn_sb *pfn_sb; + struct dev_dax *dev_dax; + struct dax_kmem *dax_kmem; + struct nd_namespace_io *nsio; + struct dax_region *dax_region; + struct nd_namespace_common *ndns; + struct nd_dax *nd_dax = to_nd_dax(dev); + struct nd_pfn *nd_pfn = &nd_dax->nd_pfn; + + ndns = nvdimm_namespace_common_probe(dev); + if (IS_ERR(ndns)) + return PTR_ERR(ndns); + nsio = to_nd_namespace_io(&ndns->dev); + + dax_kmem = devm_kzalloc(dev, sizeof(*dax_kmem), GFP_KERNEL); + if (!dax_kmem) + return -ENOMEM; + + /* parse the 'pfn' info block via ->rw_bytes */ + rc = devm_nsio_enable(dev, nsio); + if (rc) + return rc; + rc = nvdimm_setup_pfn(nd_pfn, &dax_kmem->pgmap); + if (rc) + return rc; + devm_nsio_disable(dev, nsio); + + pfn_sb = nd_pfn->pfn_sb; + + if (!devm_request_mem_region(dev, nsio->res.start, + resource_size(&nsio->res), + dev_name(&ndns->dev))) { + dev_warn(dev, "could not reserve region %pR\n", &nsio->res); + return -EBUSY; + } + + dax_kmem->dev = dev; + init_completion(&dax_kmem->cmp); + rc = percpu_ref_init(&dax_kmem->ref, dax_kmem_percpu_release, 0, + GFP_KERNEL); + if (rc) + return rc; + + rc = devm_add_action_or_reset(dev, dax_kmem_percpu_exit, + &dax_kmem->ref); + if (rc) + return rc; + + dax_kmem->pgmap.ref = &dax_kmem->ref; + addr = devm_memremap_pages(dev, &dax_kmem->pgmap); + if (IS_ERR(addr)) + return PTR_ERR(addr); + + rc = devm_add_action_or_reset(dev, dax_kmem_percpu_kill, + &dax_kmem->ref); + if (rc) + return rc; + + /* adjust the dax_region resource to the start of data */ + memcpy(&res, &dax_kmem->pgmap.res, sizeof(res)); + res.start += le64_to_cpu(pfn_sb->dataoff); + + rc = sscanf(dev_name(&ndns->dev), "namespace%d.%d", ®ion_id, &id); + if (rc != 2) + return -EINVAL; + + dax_region = alloc_dax_region(dev, region_id, &res, + le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP); + if (!dax_region) + return -ENOMEM; + + /* TODO: support for subdividing a dax region... */ + dev_dax = devm_create_dev_dax(dax_region, id, &res, 1); + + /* child dev_dax instances now own the lifetime of the dax_region */ + dax_region_put(dax_region); + + return PTR_ERR_OR_ZERO(dev_dax); +} + +static struct nd_device_driver dax_kmem_driver = { + .probe = dax_kmem_probe, + .drv = { + .name = "dax_kmem", + }, + .type = ND_DRIVER_DAX_PMEM, +}; + +module_nd_driver(dax_kmem_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Intel Corporation"); +MODULE_ALIAS_ND_DEVICE(ND_DEVICE_DAX_PMEM); From patchwork Mon Oct 22 20:13:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652429 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 8233714BB 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 6CD2928EC3 for ; Mon, 22 Oct 2018 20:18:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 612CC28EDD; 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=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 E20F328EC3 for ; Mon, 22 Oct 2018 20:18:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE34D6B000A; Mon, 22 Oct 2018 16:18:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C9CAC6B000D; Mon, 22 Oct 2018 16:18:42 -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 AE73B6B000E; Mon, 22 Oct 2018 16:18:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 69D746B000A for ; Mon, 22 Oct 2018 16:18:42 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id z10-v6so516384pfd.5 for ; Mon, 22 Oct 2018 13:18:42 -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=uDFvyPwMa2M3G8GTkGgaZXlnqs96uduHzBsjUTjyVTU=; b=WnnjL+f1Ml6jiOn6X/9uUmvmEf0L96cd+dvtn3e3BFx28+IF70NXb5gTgqsD0KgoTW B0WE+YgT5Z6Sdj9zUQCsXFgfs3jn5G5TUMinYlfH0VpEuSM7Lhhue+IZuAsh/2vhGIY1 iMg35JGmCk/RRuXEIteXzKUDgsv4PYep7RGsypKuEP/1gm6GWXWFs5vW6k3PI3lXx86s G+qntItxTrqj750zXPjnOqyU0LalgLtGWIubDfCYLOmw10Rch0rMCzBmlX7BRjHx8UhG 6Mxqt8SS0ly9yrgKKAzjIIsj9IKphcJjZWemFLai7q2g2c0Wzzj3Hu6Q6qoOUwpOzthg cEtg== 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.115 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: ABuFfojfiVZ9mu0Xd6r+as1wgZmNXdoYXET4Qasi8Diw3nAuwAVfAiBM Qookt0S1Owp6NLNclZdAOsa9GTFVmJSWtmWgbsJdzsvF78W+aFOTnJHzribx0Z/DpfE/c929kVu D06Hmb801dlmO5gTOI0XOsnK/jWc/r6xdHt18r8fXaIhD5W/xP9Jesla+KuF1ZdOmiw== X-Received: by 2002:a62:1407:: with SMTP id 7-v6mr46035922pfu.28.1540239522075; Mon, 22 Oct 2018 13:18:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV62oHC5L+4Th0BJ59oYUzo6Ps3gpoFX9IQjLNYUzkIpYSnyVm45zbqnW/p+oVJ83yAW1bEUf X-Received: by 2002:a62:1407:: with SMTP id 7-v6mr46035887pfu.28.1540239521197; Mon, 22 Oct 2018 13:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239521; cv=none; d=google.com; s=arc-20160816; b=ZVHJeemighTLCyYKV5jFjnNmlHWNet6aXilToMvR3qsTLNToAhfUohbkyJWQaUuIKm SkjLb6ewHYAAamXhMkKBGpA2kU6LoWqglr3nj98xpJyxNrVWd2Y8naTUUY/o3yitVsFW BWw7JO4U41ZBqeEY34dnLRk77hlBGFApWoTLKywWTvZMdQWdOyt6i9yw+cx5N0U8jDgC iArBuxWwoiVu+OeLs1b8PlOhqxgdF38u0pHqnhvXKpLGbyJP6RZlZEvMzdGw1YUIFBqi sEuwTkLUWRFpEHvJAFKWY7hQ+LgdpkqnbDcbvCTDiuHNdHGIWQbUQDlKGriBWpzsLmd9 MOTg== 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=uDFvyPwMa2M3G8GTkGgaZXlnqs96uduHzBsjUTjyVTU=; b=l3dhcXMibyyvbqZFdpBODT6tcbz7NwbSy5G+z10aExRVKOJHFmxUQCLIY0EjkWY7gp FQNXj2Bf8V8Ty4Lic/Nyft0ZD5AcJoVht6be3CjgE1GtmPMGYuXyqQmbieVMc+BOq5ib yrpJV5+OoMV+Kd68Zye3u5nAEcRbnTGwUoQtM2ugLoFpIrW5xX8y8Ae1A6K1/UnqkbAr Hj3ZfDIyNOuKrjzjb+ph7D4002j0EuBuH2chXWdrDlP46Cpn4w4qyZHLiRBpE9ar46OE biDXpvHMilK+xrtiwDD9b27t4Om3Q5lmjjtPk9njwHP2qbdf2t/jno0tIhYYQTk2o7ua bHVw== 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.115 as permitted sender) smtp.mailfrom=dave.hansen@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 m17-v6si35751470pgj.155.2018.10.22.13.18.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave.hansen@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 dave.hansen@linux.intel.com designates 192.55.52.115 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 fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="80062767" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga007.fm.intel.com with ESMTP; 22 Oct 2018 13:18:40 -0700 Subject: [PATCH 3/9] dax: add more kmem device infrastructure 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:22 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201322.6C8A7B2A@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 The previous patch is a simple copy of the pmem driver. This makes it easy while this is in development to keep the pmem and kmem code in sync. This actually adds some necessary infrastructure for the new driver to compile. 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 | 10 +++++----- b/include/uapi/linux/ndctl.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff -puN drivers/dax/kmem.c~dax-kmem-try-again-2018-2-header drivers/dax/kmem.c --- a/drivers/dax/kmem.c~dax-kmem-try-again-2018-2-header 2018-10-22 13:12:22.000930392 -0700 +++ b/drivers/dax/kmem.c 2018-10-22 13:12:22.005930392 -0700 @@ -27,7 +27,7 @@ static struct dax_kmem *to_dax_kmem(stru static void dax_kmem_percpu_release(struct percpu_ref *ref) { - struct dax_kmem *dax_kmem = to_dax_pmem(ref); + struct dax_kmem *dax_kmem = to_dax_kmem(ref); dev_dbg(dax_kmem->dev, "trace\n"); complete(&dax_kmem->cmp); @@ -36,7 +36,7 @@ static void dax_kmem_percpu_release(stru static void dax_kmem_percpu_exit(void *data) { struct percpu_ref *ref = data; - struct dax_kmem *dax_kmem = to_dax_pmem(ref); + struct dax_kmem *dax_kmem = to_dax_kmem(ref); dev_dbg(dax_kmem->dev, "trace\n"); wait_for_completion(&dax_kmem->cmp); @@ -46,7 +46,7 @@ static void dax_kmem_percpu_exit(void *d static void dax_kmem_percpu_kill(void *data) { struct percpu_ref *ref = data; - struct dax_kmem *dax_kmem = to_dax_pmem(ref); + struct dax_kmem *dax_kmem = to_dax_kmem(ref); dev_dbg(dax_kmem->dev, "trace\n"); percpu_ref_kill(ref); @@ -142,11 +142,11 @@ static struct nd_device_driver dax_kmem_ .drv = { .name = "dax_kmem", }, - .type = ND_DRIVER_DAX_PMEM, + .type = ND_DRIVER_DAX_KMEM, }; module_nd_driver(dax_kmem_driver); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Intel Corporation"); -MODULE_ALIAS_ND_DEVICE(ND_DEVICE_DAX_PMEM); +MODULE_ALIAS_ND_DEVICE(ND_DEVICE_DAX_KMEM); diff -puN include/uapi/linux/ndctl.h~dax-kmem-try-again-2018-2-header include/uapi/linux/ndctl.h --- a/include/uapi/linux/ndctl.h~dax-kmem-try-again-2018-2-header 2018-10-22 13:12:22.002930392 -0700 +++ b/include/uapi/linux/ndctl.h 2018-10-22 13:12:22.005930392 -0700 @@ -197,6 +197,7 @@ static inline const char *nvdimm_cmd_nam #define ND_DEVICE_NAMESPACE_PMEM 5 /* PMEM namespace (may alias with BLK) */ #define ND_DEVICE_NAMESPACE_BLK 6 /* BLK namespace (may alias with PMEM) */ #define ND_DEVICE_DAX_PMEM 7 /* Device DAX interface to pmem */ +#define ND_DEVICE_DAX_KMEM 8 /* Normal kernel-managed system memory */ enum nd_driver_flags { ND_DRIVER_DIMM = 1 << ND_DEVICE_DIMM, @@ -206,6 +207,7 @@ enum nd_driver_flags { ND_DRIVER_NAMESPACE_PMEM = 1 << ND_DEVICE_NAMESPACE_PMEM, ND_DRIVER_NAMESPACE_BLK = 1 << ND_DEVICE_NAMESPACE_BLK, ND_DRIVER_DAX_PMEM = 1 << ND_DEVICE_DAX_PMEM, + ND_DRIVER_DAX_KMEM = 1 << ND_DEVICE_DAX_KMEM, }; enum { From patchwork Mon Oct 22 20:13:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652437 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 399F05BB5 for ; Mon, 22 Oct 2018 20:18:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 222F72916E for ; Mon, 22 Oct 2018 20:18:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 165AB29182; Mon, 22 Oct 2018 20:18:53 +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 AB88D2917A for ; Mon, 22 Oct 2018 20:18:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 283AD6B000C; Mon, 22 Oct 2018 16:18:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1C3276B000D; Mon, 22 Oct 2018 16:18:44 -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 E8E8A6B000E; Mon, 22 Oct 2018 16:18:43 -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 A7DD46B000C for ; Mon, 22 Oct 2018 16:18:43 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id v10-v6so1561067pgs.15 for ; Mon, 22 Oct 2018 13:18:43 -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=FRRrQjEcKq6x+c2W4XjZQcqv8HzLEXVryuBMi8jnFbI=; b=NUm0XJ2JzDZseQYHP4/z3tdMENEcms0qj7KIwpzCemfs51AWOMtDL5OpsZ3sUVHd8N 5mVUjn5aRN4WKtk0nZeeLCWCTJbZ7hlfh4C9oWFoFhO/CL5wbyBTEAKxpJTg3WjpZnF5 l5uVH3s0g9Td+kkXkSv2IUFV0CqNmUO38s+Bm6ggnDBys+NXIvU9HmXAlL5q88xbkdnw Ok63x9cTBpXz8EsYW6conzyeKnqnHRfQM/c79+CWLe35Q8FosslWPhZMGahf20/lTVSy pw0qWvNBPSN1UmQR4eksD6/ho3ONZUF47Hv7GHgW+3nGu8dPJaKn7c0qWrDPjtr9AKvY r5Ww== 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: ABuFfoiGec1am0gduVfv4stx3PBQxzR772qeAFpDwweMzVBH9xwJ/zdV 1vDeY/7h+qkvaI4VGKkYLpoBqfazMKm6xrMRcOPQFxkh42lZRKyT4TitZSiiJv62+Z7yeyItivV LO+t1jEC7XaNLNDC6aZqeRVYT1Tq0dnRu8uRQ6VofKMnnHhUfGcsLz3qYgoiF2d+Tsg== X-Received: by 2002:a63:a119:: with SMTP id b25-v6mr44024142pgf.186.1540239523362; Mon, 22 Oct 2018 13:18:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV62I6E/w0slUWBoqw668dU5P+rpmB+/kRaGBl+0oC5XHDDNo0izHbHSt3X/baz39YhD+jQYS X-Received: by 2002:a63:a119:: with SMTP id b25-v6mr44024113pgf.186.1540239522746; Mon, 22 Oct 2018 13:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239522; cv=none; d=google.com; s=arc-20160816; b=MFKCFdW8eG94tezpKLyA3o/NUXT6W2Fr2Sd51mIB14TOEnnfBFInqCGVGVUukWLAKh exPRST2EZ85algIA183FdD/OIQK1HAdrFFVuDdHBlzIfb6KejvoGlcSMOiJn2Jt7etWL tYorC0wAXVVorBuE6si4cCGLYnZfvcB55jDR+vgRWWEy0zXuHOnZLCQWhaPU2Q36t0Nk aC0f51NecMWUoHHxZrpmLUjBoHkHIVmBDkPguTVuYthAEWcpBkPqKjeMYoMp8dQCw3kr +UspRsTQ0rXZxLUj+tpsR3WoRz3PljZvyeNKKm8aahnHwtVBp++PHmTUjnmvwdijQGp9 BXRA== 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=FRRrQjEcKq6x+c2W4XjZQcqv8HzLEXVryuBMi8jnFbI=; b=ys81HZgu7isaq85vctxTtoH6oXCCf4jnZjZTRJiXg4et/PnGKQhCNbE8qcdW3kndgd u6Ezg4UaTZMV+zf4tDLV5uwpd2gUM966NPEI1rwjKjlZUD9V9KfqyagdH1xNmKd9TS1c 1V9JRXhnrLp6nFVQVsfgZXv/ULXo5gsqapWLHSXxHHUVIESLucdDDvSdPvjoQt+iuxEo Pph2sVIeVeAIFqLmwCHNR6b5dni5PjrBxvRMz6Ah4tIG0DenSBo4bXW0dAlNDvhjtekb F2CjH7v9xONd0SongzeX66TJRc8fCxfzoPiB05KVdiNifDxP/iRaS9nzg4wQCeBjBkso UITg== 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.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:42 -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 fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="80737009" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga008.fm.intel.com with ESMTP; 22 Oct 2018 13:18:41 -0700 Subject: [PATCH 4/9] dax/kmem: allow PMEM devices to bind to KMEM driver 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:24 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201324.EBB64302@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 Currently, a persistent memory device's mode must be coordinated with the driver to which it needs to bind. To change it from the fsdax to the device-dax driver, you first change the mode of the device itself. Instead of adding a new device mode, allow the PMEM mode to also bind to the KMEM driver. As I write this, I'm realizing that it might have just been better to add a new device mode, rather than hijacking the PMEM eode. If this is the case, please speak up, NVDIMM folks. :) 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/nvdimm/bus.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff -puN drivers/nvdimm/bus.c~dax-kmem-try-again-2018-3-bus-match-override drivers/nvdimm/bus.c --- a/drivers/nvdimm/bus.c~dax-kmem-try-again-2018-3-bus-match-override 2018-10-22 13:12:22.522930391 -0700 +++ b/drivers/nvdimm/bus.c 2018-10-22 13:12:22.525930391 -0700 @@ -464,11 +464,24 @@ static struct nd_device_driver nd_bus_dr static int nvdimm_bus_match(struct device *dev, struct device_driver *drv) { struct nd_device_driver *nd_drv = to_nd_device_driver(drv); + bool match; if (is_nvdimm_bus(dev) && nd_drv == &nd_bus_driver) return true; - return !!test_bit(to_nd_device_type(dev), &nd_drv->type); + match = !!test_bit(to_nd_device_type(dev), &nd_drv->type); + + /* + * We allow PMEM devices to be bound to the KMEM driver. + * Force a match if we detect a PMEM device type but + * a KMEM device driver. + */ + if (!match && + (to_nd_device_type(dev) == ND_DEVICE_DAX_PMEM) && + (nd_drv->type == ND_DRIVER_DAX_KMEM)) + match = true; + + return match; } static ASYNC_DOMAIN_EXCLUSIVE(nd_async_domain); From patchwork Mon Oct 22 20:13:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652439 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 F2A6E13BF for ; Mon, 22 Oct 2018 20:18:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD7162916E for ; Mon, 22 Oct 2018 20:18:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1A2629182; Mon, 22 Oct 2018 20:18:56 +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 64F1A2916E for ; Mon, 22 Oct 2018 20:18:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 086116B0010; Mon, 22 Oct 2018 16:18:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 034056B0266; Mon, 22 Oct 2018 16:18:45 -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 E677E6B0269; Mon, 22 Oct 2018 16:18:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id A02526B0010 for ; Mon, 22 Oct 2018 16:18:45 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id s24-v6so31286776plp.12 for ; Mon, 22 Oct 2018 13:18:45 -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=YZQu2PAToEfu/CwqUQmMm3p8NDieJe9WhunaKTrrkBU=; b=sFk2G9LVN44vYvBVKZrUA2dba6I9c3dKc0M8E54ET/18ewHSTIRg9fcCFTcPfpielU HHgs6IsepWkW2pE+OBV4rCU2YAG8A2aX/CC8ckSb5LPw5+DDxlzMw1zXeir5XppQ10mf 3Iw4EOcqa86VEqBQCVePiKIXwRCxapU7pWBVlXdpW18lkz/8NQUlsMH62Rgj8PBw36fw HCrLO6JK6ROmzv4CYgDO3LLnnYS2wTxzT4Pjho80bDapMH6ET0Y9XwgX1kDXEUNkW8ni RjwDYjSfe8CJNjISm/wW8mwPT867Fh77X8xbJMDybA2Jw2kVn4XuloacjZ2wxgxu39aO J3QQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.31 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: ABuFfogvlOf0429R5i//TtC/0Pio/y5J5dmQON7fShldXlE+jSUvfFfk upxqB8naoh+cjHYjB2UpUXqC5YlSQOKZt3cuTa5ly5qoJh4bOR9/KQ04B6KKkKj40o/9nYZAZEM TqDLpiCUzH9t+QkuczSvfxJptaBXstVnSoyWkcfTW5VuJ/XgodKisTtpg5uN3dyojvQ== X-Received: by 2002:a63:4658:: with SMTP id v24-v6mr44938464pgk.425.1540239525319; Mon, 22 Oct 2018 13:18:45 -0700 (PDT) X-Google-Smtp-Source: ACcGV606GLXHMS5z8uJAX2ulEsR7EPXz6LjIuZKC4fhOhb6Gasdk8L2Os7C+H+n3hga2I+XMnln5 X-Received: by 2002:a63:4658:: with SMTP id v24-v6mr44938427pgk.425.1540239524651; Mon, 22 Oct 2018 13:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239524; cv=none; d=google.com; s=arc-20160816; b=jJKfdvNtbEHc3lqmz9nnDDjCIAZI7cMgjgrfXBXQJLsoy2SUg4cyZVFz4WQsjga/Uf qacavDqapkzw1bGkhwghyG3Scynmw3w+I0h11hPE/twfiD0hBckEUgYEY/x7Z/ErM9uf c3N4xHlGnDDbnvWJugoyiD2b0ealXn1nWsxSN7Is/uLbhfbuiOSlnHXnqK/cICTueMaY jK7ILEnNhsV7VfcAO+ZByXj7VcoDN9l0eQtkynXABz60/71+X0FDFZxVRiTT7o02MZ1k GRdNgT8hzLTNaqsHg403ta+aDD+N56Bof64npRIMTXBv2eVXC8kLcZmRjbRBU5AtA8n0 CpKA== 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=YZQu2PAToEfu/CwqUQmMm3p8NDieJe9WhunaKTrrkBU=; b=uTk/4nQO4kIfVo+C8HLZoZyQGhLZWoKNa4Nkv+rgrAwbxm0WZ5SCHFiimd/bmuozZS P6aNy8iHgClPelu064u8sLOw+ngeULeA65C5AEsCVyOfhDGmL53tGIURSlksX4y0NzZ3 n3QF2LvhnLExVkdjhIA0UurxoA8lmjAOlQFYcmL7+ypdrzTVJi88OZ6wAIjPh5KGnrED Z0AcCy+QUuwUG+zWZfnVHGZ/+M+6fdLXm+gM2NSNV8K+W79TgeefBZeDoaqotZk0whus s1Zp1OvXOHuovWzTiauX3JLEyLzoa1JQ0kyBFy/X/Few35KQ5WYAj+24LajWnR+1F6y3 ohWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga06.intel.com (mga06.intel.com. [134.134.136.31]) by mx.google.com with ESMTPS id m13-v6si36529525pfd.123.2018.10.22.13.18.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.31 as permitted sender) client-ip=134.134.136.31; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.31 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 fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="90396632" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by FMSMGA003.fm.intel.com with ESMTP; 22 Oct 2018 13:18:42 -0700 Subject: [PATCH 5/9] dax/kmem: add more nd dax kmem infrastructure 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:26 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201326.5E3F2752@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 Each DAX mode has a set of wrappers and helpers. Add them for the kmem mode. 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/nvdimm/bus.c | 2 ++ b/drivers/nvdimm/dax_devs.c | 35 +++++++++++++++++++++++++++++++++++ b/drivers/nvdimm/nd.h | 6 ++++++ 3 files changed, 43 insertions(+) diff -puN drivers/nvdimm/bus.c~dax-kmem-try-again-2018-4-bus-dev-type-kmem drivers/nvdimm/bus.c --- a/drivers/nvdimm/bus.c~dax-kmem-try-again-2018-4-bus-dev-type-kmem 2018-10-22 13:12:23.024930389 -0700 +++ b/drivers/nvdimm/bus.c 2018-10-22 13:12:23.031930389 -0700 @@ -46,6 +46,8 @@ static int to_nd_device_type(struct devi return ND_DEVICE_REGION_BLK; else if (is_nd_dax(dev)) return ND_DEVICE_DAX_PMEM; + else if (is_nd_dax_kmem(dev)) + return ND_DEVICE_DAX_KMEM; else if (is_nd_region(dev->parent)) return nd_region_to_nstype(to_nd_region(dev->parent)); diff -puN drivers/nvdimm/dax_devs.c~dax-kmem-try-again-2018-4-bus-dev-type-kmem drivers/nvdimm/dax_devs.c --- a/drivers/nvdimm/dax_devs.c~dax-kmem-try-again-2018-4-bus-dev-type-kmem 2018-10-22 13:12:23.026930389 -0700 +++ b/drivers/nvdimm/dax_devs.c 2018-10-22 13:12:23.031930389 -0700 @@ -51,6 +51,41 @@ struct nd_dax *to_nd_dax(struct device * } EXPORT_SYMBOL(to_nd_dax); +/* nd_dax_kmem */ +static void nd_dax_kmem_release(struct device *dev) +{ + struct nd_region *nd_region = to_nd_region(dev->parent); + struct nd_dax_kmem *nd_dax_kmem = to_nd_dax_kmem(dev); + struct nd_pfn *nd_pfn = &nd_dax_kmem->nd_pfn; + + dev_dbg(dev, "trace\n"); + nd_detach_ndns(dev, &nd_pfn->ndns); + ida_simple_remove(&nd_region->dax_ida, nd_pfn->id); + kfree(nd_pfn->uuid); + kfree(nd_dax_kmem); +} + +static struct device_type nd_dax_kmem_device_type = { + .name = "nd_dax_kmem", + .release = nd_dax_kmem_release, +}; + +bool is_nd_dax_kmem(struct device *dev) +{ + return dev ? dev->type == &nd_dax_kmem_device_type : false; +} +EXPORT_SYMBOL(is_nd_dax_kmem); + +struct nd_dax_kmem *to_nd_dax_kmem(struct device *dev) +{ + struct nd_dax_kmem *nd_dax_kmem = container_of(dev, struct nd_dax_kmem, nd_pfn.dev); + + WARN_ON(!is_nd_dax_kmem(dev)); + return nd_dax_kmem; +} +EXPORT_SYMBOL(to_nd_dax_kmem); +/* end nd_dax_kmem */ + static const struct attribute_group *nd_dax_attribute_groups[] = { &nd_pfn_attribute_group, &nd_device_attribute_group, diff -puN drivers/nvdimm/nd.h~dax-kmem-try-again-2018-4-bus-dev-type-kmem drivers/nvdimm/nd.h --- a/drivers/nvdimm/nd.h~dax-kmem-try-again-2018-4-bus-dev-type-kmem 2018-10-22 13:12:23.027930389 -0700 +++ b/drivers/nvdimm/nd.h 2018-10-22 13:12:23.031930389 -0700 @@ -215,6 +215,10 @@ struct nd_dax { struct nd_pfn nd_pfn; }; +struct nd_dax_kmem { + struct nd_pfn nd_pfn; +}; + enum nd_async_mode { ND_SYNC, ND_ASYNC, @@ -318,9 +322,11 @@ static inline int nd_pfn_validate(struct #endif struct nd_dax *to_nd_dax(struct device *dev); +struct nd_dax_kmem *to_nd_dax_kmem(struct device *dev); #if IS_ENABLED(CONFIG_NVDIMM_DAX) int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns); bool is_nd_dax(struct device *dev); +bool is_nd_dax_kmem(struct device *dev); struct device *nd_dax_create(struct nd_region *nd_region); #else static inline int nd_dax_probe(struct device *dev, From patchwork Mon Oct 22 20:13:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652447 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 E77C513BF for ; Mon, 22 Oct 2018 20:19:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D10622916B for ; Mon, 22 Oct 2018 20:19:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C54262916E; Mon, 22 Oct 2018 20:19:13 +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 3BCEC2916B for ; Mon, 22 Oct 2018 20:19:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16F826B026D; Mon, 22 Oct 2018 16:18:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1230F6B026E; Mon, 22 Oct 2018 16:18:53 -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 F2C1C6B026F; Mon, 22 Oct 2018 16:18:52 -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 B0E6C6B026D for ; Mon, 22 Oct 2018 16:18:52 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id v7-v6so31240164plo.23 for ; Mon, 22 Oct 2018 13:18:52 -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=LkIfAHcPGuqatpzkJQXzIX0BljRNIJziyDVOi4USVeI=; b=ZArO0F3OUyKm52e3Bl7YFlPYLSybUMCtxcpoTXW8M9CENIwHYSZbFNcj8kuX46mkvm i4DmFGq66VPAMi+VDslljhEA79SZvOic5ujMcx1aK1ht80G/rXiCtCvLIoN5EM5hAODt k8gKc/s+ZrIko3XCsKng8sN+rsByeSlnFxVnmgyNQzNZKB2M+GpuVqQhZ2f+TfsT+Xfc vk7+WTUyKJVwJ0qolmqZ2/q6hsY7rF1A0Ima51sf8fcqbwZLIq2NbQZMVMKczO95XOaD My8J1V7pOGqLNAq95IaFoXliAvDCFA9CUewROVyXKbnSwOmm4ko2mDICtf8tt8G2/YVV WSeA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.24 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: ABuFfoh1FJg/JsPK+vA/2EAfE0YQoN/fsK2NcSIK5RmlLmIwPkQBJX7A o3oifc0G+067xOyZF18mRwoKKk+ODanpSMPtmIz6uN5XiocV6nWiOclBVKLp1dBTQanJUu25USC Pr50SjTwHucLjsTpqWOxjvihOf6abWnEKwtZ/biQwrQ4tn/eMHtwWTFiFvUCU8gibTQ== X-Received: by 2002:a63:f252:: with SMTP id d18-v6mr44396869pgk.2.1540239532374; Mon, 22 Oct 2018 13:18:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV61xWBTALHP0+ACE8wHvDKNq00JhdWk1FotiaNxItOVarsU1XEl1Tw+fcEqs4tJDu0U5X421 X-Received: by 2002:a63:f252:: with SMTP id d18-v6mr44396636pgk.2.1540239526821; Mon, 22 Oct 2018 13:18:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239526; cv=none; d=google.com; s=arc-20160816; b=0XKtj5fiKqQoAT4JnNRPKeZt2R6tLbfyGnXFR2mn/QzzYCQR6RMcBegCIkhITKF0bd yWKnVFjt81aYJRWXmsyQ544hg2KxlZdoIVQbGLxgdiOlX5h9aQN9ZymFiF5VwX0G5Pba JsgPli/B3+hdiieaTHhRiuAD6hCa+r5EI/7K7VDT0NKX9YcPdE3iJcwRM5FTLBKrlYxZ WhtLL8aKMDxxkjFkDHUS4Amrru+Uo6+nA60Vi3XyazGmrAYmsIsinP3lCrFNkkZ1HSOI fn2q/xqWe+nszIKdby5r8qnY/DF9QJkfA0LPPucybLyW81K/dVI2h3od4NJNHl2zCjjU jnUg== 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=LkIfAHcPGuqatpzkJQXzIX0BljRNIJziyDVOi4USVeI=; b=gPp88Lj7+oGCB1M/Zxbr/k4C97t5RmrhzqNgrWzMWEvp6g4QERl8SvST7Nua4kVZzE /oYUELf2vTymBPijTdyxwKxs3Dnl9TjvJwjK3Ceeq+GOFxk5Ramg/E0Bk0/yKTTAeUwJ po6l7hHMfbbtqwdfbZJswda0QREdLN2I1jiCUp9ML/zWFXLlflRdd446cGyLFK8czRpc kd55pk1SHtUIDgc2oLo4+oQJG1MrmjWfh4rEkxZJiJEGQSty0LgMAzCneyiD3Lno1Qjs Cm+B5KxoVNdalDOuihmDuyYpuVsD4F57oZCj6jufG+RubexUbToQ0/RNFcED+kti8nz3 mrSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga09.intel.com (mga09.intel.com. [134.134.136.24]) by mx.google.com with ESMTPS id w13-v6si12595570pgj.229.2018.10.22.13.18.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.24 as permitted sender) client-ip=134.134.136.24; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.24 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 fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="99739367" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga004.fm.intel.com with ESMTP; 22 Oct 2018 13:18:45 -0700 Subject: [PATCH 6/9] mm/memory-hotplug: allow memory resources to be children 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:27 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201327.F1642450@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 The mm/resource.c code is used to manage the physical address space. We can view the current resource configuration in /proc/iomem. An example of this is at the bottom of this description. The nvdimm subsystem "owns" the physical address resources which map to persistent memory and has resources inserted for them as "Persistent Memory". We want to use this persistent memory, but as volatile memory, just like RAM. The best way to do this is to leave the existing resource in place, but add a "System RAM" resource underneath it. This clearly communicates the ownership relationship of this memory. The request_resource_conflict() API only deals with the top-level resources. Replace it with __request_region() which will search for !IORESOURCE_BUSY areas lower in the resource tree than the top level. We also rework the old error message a bit since we do not get the conflicting entry back: only an indication that we *had* a conflict. We *could* also simply truncate the existing top-level "Persistent Memory" resource and take over the released address space. But, this means that if we ever decide to hot-unplug the "RAM" and give it back, we need to recreate the original setup, which may mean going back to the BIOS tables. This should have no real effect on the existing collision detection because the areas that truly conflict should be marked IORESOURCE_BUSY. 00000000-00000fff : Reserved 00001000-0009fbff : System RAM 0009fc00-0009ffff : Reserved 000a0000-000bffff : PCI Bus 0000:00 000c0000-000c97ff : Video ROM 000c9800-000ca5ff : Adapter ROM 000f0000-000fffff : Reserved 000f0000-000fffff : System ROM 00100000-9fffffff : System RAM 01000000-01e071d0 : Kernel code 01e071d1-027dfdff : Kernel data 02dc6000-0305dfff : Kernel bss a0000000-afffffff : Persistent Memory (legacy) a0000000-a7ffffff : System RAM b0000000-bffdffff : System RAM bffe0000-bfffffff : Reserved c0000000-febfffff : PCI Bus 0000:00 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/mm/memory_hotplug.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff -puN mm/memory_hotplug.c~mm-memory-hotplug-allow-memory-resource-to-be-child mm/memory_hotplug.c --- a/mm/memory_hotplug.c~mm-memory-hotplug-allow-memory-resource-to-be-child 2018-10-22 13:12:23.570930388 -0700 +++ b/mm/memory_hotplug.c 2018-10-22 13:12:23.573930388 -0700 @@ -99,24 +99,21 @@ void mem_hotplug_done(void) /* add this memory to iomem resource */ static struct resource *register_memory_resource(u64 start, u64 size) { - struct resource *res, *conflict; - res = kzalloc(sizeof(struct resource), GFP_KERNEL); - if (!res) - return ERR_PTR(-ENOMEM); + struct resource *res; + unsigned long flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; + char resource_name[] = "System RAM"; - res->name = "System RAM"; - res->start = start; - res->end = start + size - 1; - res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; - conflict = request_resource_conflict(&iomem_resource, res); - if (conflict) { - if (conflict->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY) { - pr_debug("Device unaddressable memory block " - "memory hotplug at %#010llx !\n", - (unsigned long long)start); - } - pr_debug("System RAM resource %pR cannot be added\n", res); - kfree(res); + /* + * Request ownership of the new memory range. This might be + * a child of an existing resource that was present but + * not marked as busy. + */ + res = __request_region(&iomem_resource, start, size, + resource_name, flags); + + if (!res) { + pr_debug("Unable to reserve System RAM region: %016llx->%016llx\n", + start, start + size); return ERR_PTR(-EEXIST); } return res; 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); From patchwork Mon Oct 22 20:13:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652443 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 C200C14BB for ; Mon, 22 Oct 2018 20:19:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD1DE2916B for ; Mon, 22 Oct 2018 20:19:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0A6F2916E; Mon, 22 Oct 2018 20:19:04 +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 3F3492916B for ; Mon, 22 Oct 2018 20:19:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E93056B026A; 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 DCC0F6B026B; 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 C1BC76B026C; 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-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 760066B026A for ; Mon, 22 Oct 2018 16:18:50 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id x2-v6so30236805pgr.8 for ; Mon, 22 Oct 2018 13:18:50 -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=sClhAVcJP/TIupWRfcVTdTIK5HemsoApwdW9D6IlpV4=; b=sWD+y393lZhEsZi+HcZXJZ3FBT4dQOE3173S2dshR4lSrSXsRbwz1nVFfDWtoywI1a dCF0OYu7s9UJSMWgga4IPtBjH/4+8R3jeNuErI31+zWapMHownui2lftC/H8EL3JSLYR LDY7IzRyTHVNydJ2Epfohg3pKuNZ3FfJsDaSsI9zTptNJCpfpUSwbwePxV7tUrTurvM/ o17/pFIg+pxuK4b+jCc3VZWKEd9x74DaoJ7tpAziaT4czU1cSbd2EU9hk8Ik6NPnXcm2 9jYgiuPnPK1fcVkfDDOXyEyw1J7xw8j9JFQshyeB9h8bcZJF4zqKft4obwMSBYahb7Jg 3AHA== 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: ABuFfohJxzvdCydgg3g9o3WREOJQJfBkKx0pnm5D7nka9XegBzbccbFl IAf6jtj+0tSndNQN0sMHPBy/6YPlH9BbxqAK1rzx+JCt6NXnrYBenwed+Y1KC83XSTO4yCsm0rw qaaWFez8lfNLSzmjV2xcqfVPbSkj061tjHIJm1zntxsIeHxtVih6M+1oQDpMSwg4tHA== X-Received: by 2002:a17:902:45a5:: with SMTP id n34-v6mr40053568pld.341.1540239530138; Mon, 22 Oct 2018 13:18:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV62p+8213tQmnbltVQ4zn7ApdePmiebhhvOJO6xz19UfiLGR8jF0RNRFLw5BZGNCA3n59pZF X-Received: by 2002:a17:902:45a5:: with SMTP id n34-v6mr40053536pld.341.1540239529404; Mon, 22 Oct 2018 13:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239529; cv=none; d=google.com; s=arc-20160816; b=RO2fTRNzI9+vjaGKQrixkFpMpXQbYW/Xhddp39vxnzw3+nHWDowronQHGR3aUtGRm/ +f2ZtKLqVfUxMdd4gIgbRMPZOpO145ll0BhxZ91A18ESBtVkMGuo8QUpGKG7n4lvYtEe XsjmIJB+ExETOBsNN8BvXtFqqjb0I2sgJHej4/tShVArUsnal3E5nvA62pp4mCmUwQok KXENYSrOP+S4z06uubqp8g0ggnmqJcaISggOAMFzGj7A1JMmBromappddckUuGBeTTfe N/y6NOMIG4fb9fC9FcH0dvQEvvF7pIEXHLrJt3/UWjuk+ffDe/TGVMwH/Zc7NnABckAH wc8w== 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=sClhAVcJP/TIupWRfcVTdTIK5HemsoApwdW9D6IlpV4=; b=LrxDWkc6LJcIHQfD5lJJsZwjN0Lu7w3dX7OQFkTPs3V9DH6aD2uyY2StrmYUgxvMpC /21bakFFM/fFl7ISZ9T/+5fFARTOmIVLJ7rpdzC5I3ID5kLT5CnPcZb9UZnn1gYfuzQD 3F82r9eLRXJCo/Zm5mfxFTobGM1yKT9f9do2MHODNw8IgK/5bxYBcYGknzxjBL+14QGs Q7yRBih3nTUywYJUM6qlPm5fWzlmRFG+hB590EPdbQoXkBTk1xkfOw0ZADq5ukwc9VGA b+Shh9iVH2LilIH8snAq6hA/hArVPcrv19siQzpCKTDP6vNOQimpkzumLamiHhkTLWye uhtA== 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 g10-v6si32754692plt.212.2018.10.22.13.18.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:49 -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 orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="101693469" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga001.jf.intel.com with ESMTP; 22 Oct 2018 13:18:48 -0700 Subject: [PATCH 8/9] dax/kmem: let walk_system_ram_range() search child resources 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:31 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201331.8DDC3CDD@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 In the process of onlining memory, we use walk_system_ram_range() to find the actual RAM areas inside of the area being onlined. However, it currently only finds memory resources which are "top-level" iomem_resources. Children are not currently searched which causes it to skip System RAM in areas like this (in the format of /proc/iomem): a0000000-bfffffff : Persistent Memory (legacy) a0000000-afffffff : System RAM Changing the true->false here allows children to be searched as well. We need this because we add a new "System RAM" resource underneath the "persistent memory" resource when we use persistent memory in a volatile mode. 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/kernel/resource.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff -puN kernel/resource.c~mm-walk_system_ram_range-search-child-resources kernel/resource.c --- a/kernel/resource.c~mm-walk_system_ram_range-search-child-resources 2018-10-22 13:12:24.565930386 -0700 +++ b/kernel/resource.c 2018-10-22 13:12:24.572930386 -0700 @@ -445,6 +445,9 @@ int walk_mem_res(u64 start, u64 end, voi * This function calls the @func callback against all memory ranges of type * System RAM which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY. * It is to be used only for System RAM. + * + * This will find System RAM ranges that are children of top-level resources + * in addition to top-level System RAM resources. */ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int (*func)(unsigned long, unsigned long, void *)) @@ -460,7 +463,7 @@ int walk_system_ram_range(unsigned long flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; while (start < end && !find_next_iomem_res(start, end, flags, IORES_DESC_NONE, - true, &res)) { + false, &res)) { pfn = (res.start + PAGE_SIZE - 1) >> PAGE_SHIFT; end_pfn = (res.end + 1) >> PAGE_SHIFT; if (end_pfn > pfn) From patchwork Mon Oct 22 20:13:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Hansen X-Patchwork-Id: 10652445 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 4395C13BF for ; Mon, 22 Oct 2018 20:19:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DEC12916B for ; Mon, 22 Oct 2018 20:19:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 220222916E; Mon, 22 Oct 2018 20:19:09 +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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B26E42916B for ; Mon, 22 Oct 2018 20:19:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E906E6B026B; Mon, 22 Oct 2018 16:18:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E18406B026C; Mon, 22 Oct 2018 16:18:51 -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 BF5AE6B026D; Mon, 22 Oct 2018 16:18:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 7E4366B026B for ; Mon, 22 Oct 2018 16:18:51 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id d7-v6so25094962pfj.6 for ; Mon, 22 Oct 2018 13:18:51 -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=2Gi3f2LA/oGqTJGydASbd+W5KL3Fl43s5HZPdgiARrE=; b=PejHfxNEjeGUY5uHWK4r76OZQhXhqyn7sTVqqW5SX7entyvDbdWpjqNTCh6K3dYWVS bCeszUomj3dV78o9EQOItawWZMztaPqo6prUHwRJQPGpxjyOUtAdsFeG73TkR1zOYSlp 9mcmxLljVwtDNcR7HiRj7pkKPEpPGXADKfQZaxspIbHf/mfbFMLdTIyLIuSdkUu4WW3g +ZUvCXfH+AbLayUTMX09UEzl3VrBPwCDAhP2op0PAnhMwrkGuHjfpBkrycEwQ7rnqwbr xrcvXTO8n8dT9e8roCneTJKsjoSZ4+Dnd/mtTlSkolCy9e/atrQ/iUT8eT4aMVCfccuh 53mw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.31 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: ABuFfojSwPia11wFOlWLxzhT1eJUTHvhgApV/Gbw1DcTfymbHDap0/2l tD8GqU2cmiBC3w4FbuGnYQdhmVtpLQa8NfimJp1BQPjR4rGafKk7LgaN+oHWWk1zN3igwgVbPGY feJ8X/EjON/U8BZrwMt+2XusPTvFmEM+qP8Xd3u09iLm+cxMtyFepYpWbYBl1Y8bgxw== X-Received: by 2002:a17:902:ceb:: with SMTP id 98-v6mr46836495plt.331.1540239531194; Mon, 22 Oct 2018 13:18:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV61aiofgph8+QVyIroFIPzDY6ujpOt3GCfinwtTo9D0Vv037gKq+A2gK4xvtLk5S84ci5D9k X-Received: by 2002:a17:902:ceb:: with SMTP id 98-v6mr46836474plt.331.1540239530654; Mon, 22 Oct 2018 13:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540239530; cv=none; d=google.com; s=arc-20160816; b=YAMlbUyx3uqtu/udeutJ5hgqoNcM9osJxuiMMQUW7k/HDQ1eHSZxLo5DBYBq3r3KA4 aGsdwN5FCzwIYK99E1dq2bKx7Il2S4+S2/At7/9RYSw7fanyZdgPCGLtt+DNhnofzNuX PPErLmG2UreV/0XqrT3f1Y2QGiRm/MX2tigQqKo+6NCx4fPd1A+Q+hOhQWCMxnNjna5D PiACzkYzNdhU4ecS807LiOEc+gFDgn6R+Tp1WMmF+ez0fL8sQPXpY8VOnmmuIYqQhVqv WrsnS4kJR4kWJlSeJkyluhj3W+pZEXO0iorBmC6DMVg0DA8C0ahSaEmto5RYqFUrvYYf vZ4A== 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=2Gi3f2LA/oGqTJGydASbd+W5KL3Fl43s5HZPdgiARrE=; b=Dcftge0gewxmcWmGBqRCUXgjfauzftwUacNQuLyDwYDGHoYt5A82Odz9SYEijLMSYD IBOXivwDirCkGmeGtXR2/uJV/OCUsGfCr7PWN5TtRFPhpzyYDLu0sQREF1c7M9EtZvxL iha8hjf2JEKsDA2lP0J+qFBqvQMcIuUA/dTzCffLGp+XDp6YFJhLPn2iBKzfERkjRcXe VY3xMcZhEqTQrLhE930HB8ijXKnCk7sJMhWSb91SA3chrOgOjyzz1CUrpaiqPzUt21ec xN/CZ+kPedipT50YZB1kCFS7zwjTYOOHTa4/IG25wDTyn5cyeMxtpdJMNpk3n+TzKdf/ P8eA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=dave.hansen@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga06.intel.com (mga06.intel.com. [134.134.136.31]) by mx.google.com with ESMTPS id c81-v6si37899551pfb.153.2018.10.22.13.18.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 13:18:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.31 as permitted sender) client-ip=134.134.136.31; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dave.hansen@linux.intel.com designates 134.134.136.31 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 orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 13:18:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="102363901" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga002.jf.intel.com with ESMTP; 22 Oct 2018 13:18:50 -0700 Subject: [PATCH 9/9] dax/kmem: actually enable the code in Makefile 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:32 -0700 References: <20181022201317.8558C1D8@viggo.jf.intel.com> In-Reply-To: <20181022201317.8558C1D8@viggo.jf.intel.com> Message-Id: <20181022201332.FC3B5EB7@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 Most of the new code was dead up to this point. Now that all the pieces are in place, enable it. 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/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff -puN drivers/dax/Makefile~dax-kmem-makefile drivers/dax/Makefile --- a/drivers/dax/Makefile~dax-kmem-makefile 2018-10-22 13:12:25.068930384 -0700 +++ b/drivers/dax/Makefile 2018-10-22 13:12:25.071930384 -0700 @@ -2,7 +2,9 @@ obj-$(CONFIG_DAX) += dax.o obj-$(CONFIG_DEV_DAX) += device_dax.o obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem.o +obj-$(CONFIG_DEV_DAX_PMEM) += dax_kmem.o dax-y := super.o dax_pmem-y := pmem.o +dax_kmem-y := kmem.o device_dax-y := device.o