From patchwork Wed Mar 6 10:28:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13583825 X-Patchwork-Delegate: iweiny@gmail.com Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2520D604AF for ; Wed, 6 Mar 2024 10:29:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.137 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720965; cv=none; b=g4NnvzNLAzQHVqOi5G7swE2ceEk9TPHi1rTMjyL9sU8icvl7SkiW/b3EvyJilsjU7TqZcPtjHgt/KxIhqwECij1nGmLwiz+RHc8D+KDSwggsczKTuAxRbpmhQloNGkXy/Q2fP/6FSelFo+8rCZmYSz8MVxh3KCnZrGvb7lVzr68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720965; c=relaxed/simple; bh=ZoN1+liG2Aek8I+8vh1JTxN3rQPUF7ESoET6QRxJG2I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ivAoT7HL4vfOzGeYuAIDQ7IKghO/WxWwHFwSrstd+1GIOdU2GVfEvwj680WrnZPN73mMT0fg3aDpDZgttZuKIXOxMdj3J/a+s5+xlhUUdVaz2nJmDAu0oKU5f5rcBypFGvBQBQVsrM0fS578RjYzDmGwLddFUzwddo33ikijhN0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=JvML1jsU; arc=none smtp.client-ip=207.54.90.137 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="JvML1jsU" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720964; x=1741256964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZoN1+liG2Aek8I+8vh1JTxN3rQPUF7ESoET6QRxJG2I=; b=JvML1jsU/9R/DklI4dtt0iUQiMbXrBuK1nOHvch6cM7Oj057eFgLgz0t s0t6SZR9AhLAyLfo5iIJDfn+NN4FbReFkk6bc5KgMe1HzNuO6j6Tbm6oD i/DN9njyvNJvk0VrEgUW/hO7kBvZP++F3QMwlNXOhD1h01788CibxZHUc holAxt6vwGuGgUQ/Jca84kJY94qjTxQudNp1iOAK913fn53Iv5U/+xFuK nIhiRy/LMVEUtIL8EEm4dMzf8ME1BzoUfp9neVzfrnGutNjGeR+8CrKhg wRAumm2N7bKj+mIx+APN546rvkCsPUMfvDkUwA3emC6ShC5GSDYHq5t+C g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="130783553" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="130783553" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:13 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 97D40D3EA9 for ; Wed, 6 Mar 2024 19:29:08 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id C1761D5603 for ; Wed, 6 Mar 2024 19:29:07 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 261E82030C7E2 for ; Wed, 6 Mar 2024 19:29:07 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 30EC21A006D; Wed, 6 Mar 2024 18:29:06 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: y-goto@fujitsu.com, Alison Schofield , Andrew Morton , Baoquan He , Borislav Petkov , Dan Williams , Dave Hansen , Dave Jiang , Greg Kroah-Hartman , hpa@zytor.com, Ingo Molnar , Ira Weiny , Thomas Gleixner , Vishal Verma , linux-cxl@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org, kexec@lists.infradead.org, Li Zhijian Subject: [PATCH v3 1/7] mm: memremap: register/unregister altmap region to a separate resource Date: Wed, 6 Mar 2024 18:28:40 +0800 Message-Id: <20240306102846.1020868-2-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240306102846.1020868-1-lizhijian@fujitsu.com> References: <20240306102846.1020868-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28234.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28234.006 X-TMASE-Result: 10--10.470700-10.000000 X-TMASE-MatchedRID: 1qLRYaNAGIjSQ8oIxmHtSPSG/+sPtZVkP9kI+hf1EuqeEPi9wVyFrt3m 9tpwPB13LMZCJmSjFZdnvY9hxB9vc68zfGxMvR+8KQxHYsCcxGkJlr1xKkE5ucC5DTEMxpeQlAz 5vo1rYQ0JVj6hwZFNaEK3WEb5CMhwJSdQTuiG7Ijjpxdo/JwVm/NYQxCOihTN6hUULKzHRgQTgt 4grpaSCoXqHVXA333ceUDb3nIq9HleMBK5dsaSGQKDWtq/hHcNqLpXV8E1T7zozDhGeQC9EvdyG 0dzM6lz4vM1YF6AJbbCCfuIMF6xLSAHAopEd76vccmxpuUeZs/EDQ/FH4CdWBWn6lb2OMp5WsRb K4+hKATe8vYowW/wKQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 The elfcorehdr descirbes the dumpable region in PT_LOADs. Generally, an iomem resource registered with flags (IORESOURCE_SYSTEM_RAM | IORESOUCE_BUSY) will be added to PT_LOADs by kexe_file_load(2). An iomem resource with name prefix "System RAM" will be added to PT_LOADs in kexec-tools by calling kexe_load(2). So a simple way to make the altmap dumpable is to register altmap region as a separate resource with the proper name and resource flags. Here naming it as "Device Backed Vmemmap" plus resource flags (IORESOURCE_DEVICE_BACKED_VMEMMAP and IORESOUCE_BUSY) to make it work first. A /proc/iomem example is as following: $ sudo cat /proc/iomem ... fffc0000-ffffffff : Reserved 100000000-13fffffff : Persistent Memory 100000000-10fffffff : namespace0.0 100000000-1005fffff : Device Backed Vmemmap # fsdax a80000000-b7fffffff : CXL Window 0 a80000000-affffffff : Persistent Memory a80000000-affffffff : region1 a80000000-a811fffff : namespace1.0 a80000000-a811fffff : Device Backed Vmemmap # devdax a81200000-abfffffff : dax1.0 b80000000-c7fffffff : CXL Window 1 c80000000-147fffffff : PCI Bus 0000:00 c80000000-c801fffff : PCI Bus 0000:01 ... CC: Andrew Morton CC: Greg Kroah-Hartman CC: Baoquan He CC: Dan Williams CC: linux-mm@kvack.org Signed-off-by: Li Zhijian --- include/linux/ioport.h | 1 + include/linux/memremap.h | 3 +++ mm/memremap.c | 23 ++++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index db7fe25f3370..3b59e924f531 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -69,6 +69,7 @@ struct resource { #define IORESOURCE_UNSET 0x20000000 /* No address assigned yet */ #define IORESOURCE_AUTO 0x40000000 #define IORESOURCE_BUSY 0x80000000 /* Driver has marked this resource busy */ +#define IORESOURCE_DEVICE_BACKED_VMEMMAP 0xa0000000 /* device backed vmemmap resource */ /* I/O resource extended types */ #define IORESOURCE_SYSTEM_RAM (IORESOURCE_MEM|IORESOURCE_SYSRAM) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index 744c830f4b13..ca1f12353008 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -17,6 +17,8 @@ struct device; * @free: free pages set aside in the mapping for memmap storage * @align: pages reserved to meet allocation alignments * @alloc: track pages consumed, private to vmemmap_populate() + * @parent: the parent resource that altmap region belongs to + * @res: altmap region resource */ struct vmem_altmap { unsigned long base_pfn; @@ -25,6 +27,7 @@ struct vmem_altmap { unsigned long free; unsigned long align; unsigned long alloc; + struct resource *parent, *res; }; /* diff --git a/mm/memremap.c b/mm/memremap.c index 9e9fb1972fff..78047157b0ee 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -157,7 +157,17 @@ EXPORT_SYMBOL_GPL(memunmap_pages); static void devm_memremap_pages_release(void *data) { - memunmap_pages(data); + struct dev_pagemap *pgmap = data; + + if (pgmap->flags & PGMAP_ALTMAP_VALID && pgmap->altmap.res) { + resource_size_t start = pgmap->altmap.res->start; + resource_size_t size = pgmap->altmap.res->end - + pgmap->altmap.res->start + 1; + + __release_region(pgmap->altmap.parent, start, size); + } + + memunmap_pages(pgmap); } static void dev_pagemap_percpu_release(struct percpu_ref *ref) @@ -404,11 +414,22 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) { int error; void *ret; + struct vmem_altmap *altmap = &pgmap->altmap; ret = memremap_pages(pgmap, dev_to_node(dev)); if (IS_ERR(ret)) return ret; + if (pgmap->flags & PGMAP_ALTMAP_VALID && altmap->parent) { + unsigned long start = altmap->base_pfn << PAGE_SHIFT; + unsigned long size = vmem_altmap_offset(altmap) << PAGE_SHIFT; + int flags = IORESOURCE_DEVICE_BACKED_VMEMMAP | IORESOURCE_BUSY; + + altmap->res = __request_region(altmap->parent, start, size, + "Device Backed Vmemmap", flags); + pr_debug("Insert a separate resource for altmap, %lx-%lx\n", + start, start + size); + } error = devm_add_action_or_reset(dev, devm_memremap_pages_release, pgmap); if (error) From patchwork Wed Mar 6 10:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13583824 X-Patchwork-Delegate: iweiny@gmail.com Received: from esa1.hc1455-7.c3s2.iphmx.com (esa1.hc1455-7.c3s2.iphmx.com [207.54.90.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFB585F848 for ; Wed, 6 Mar 2024 10:29:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720964; cv=none; b=m1W2+rhbspvW4SjqNZPoi/MS9AiSUHm6gstDA4c5D3SZGXeCQl6rvfsiTdyErU6hRsD/GA5ha/QWMZKotvEXWbgnFN+22K1jL5rw2mWh5TnetmOIru3pfEH9y1kh4f/vxmqV5hsnqGT7Z+yG/xDVc1CkzP+TMiKLxSJ3ucjygN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720964; c=relaxed/simple; bh=qPTXg1j60dmCKgrUxhmFd4z9be0Rjp54MJE3FLxdEQM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SpDZBRhTyFWsp5C6NTMfdoPnNfWfWzfOiKpa0wsNUAMOCc15gPqXVUmU1eA01B3M04V03V3DA35DDfwCT0MByR9hkE+O120PayH7FSeaj7iSy1cwjr80RZsge3Qzzj990Df0ZYFQ6lj43VPN5kVcXdWEAvRUinx31SoHxZeZs+c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=lGOsgFSu; arc=none smtp.client-ip=207.54.90.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="lGOsgFSu" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720963; x=1741256963; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qPTXg1j60dmCKgrUxhmFd4z9be0Rjp54MJE3FLxdEQM=; b=lGOsgFSuoAiXNpP5Y9RAN4XbNTumBMibnuZhhEaiTuXRM4W6f0LtQTu8 qjf5Y23x0trILLJxDNBXxE468SSENqKCmqgzPvsf0nv+32mloxCqbl6PP P0FlfQUtquE96IBM6LBj4O514sBrcgVVPvSiHtoabJwYh7jMo3zynYCfG mYTnL3iINz04yFdbEGE2/VBQKddRAB4iIX8NGGjFjBKtHjs2f5/C9LTvV +9JwPyq7zx3sNq3cZd5VKPMQxxNhlLFKLyn0/iqCEQFvGpwMQmLKfFzR7 YPgrkuPOWBtWk7Rr4G1E+7YP3BeY/YB+yiO2H3y8owa8eZQGQIM8qNaUq g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="151260033" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="151260033" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:12 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 355A112E239 for ; Wed, 6 Mar 2024 19:29:09 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 6B94DBF3C9 for ; Wed, 6 Mar 2024 19:29:08 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id F208D202CB587 for ; Wed, 6 Mar 2024 19:29:07 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 08E3D1A006A; Wed, 6 Mar 2024 18:29:06 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: y-goto@fujitsu.com, Alison Schofield , Andrew Morton , Baoquan He , Borislav Petkov , Dan Williams , Dave Hansen , Dave Jiang , Greg Kroah-Hartman , hpa@zytor.com, Ingo Molnar , Ira Weiny , Thomas Gleixner , Vishal Verma , linux-cxl@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org, kexec@lists.infradead.org, Li Zhijian Subject: [PATCH v3 2/7] mm: memremap: add pgmap_parent_resource() helper Date: Wed, 6 Mar 2024 18:28:41 +0800 Message-Id: <20240306102846.1020868-3-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240306102846.1020868-1-lizhijian@fujitsu.com> References: <20240306102846.1020868-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28234.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28234.006 X-TMASE-Result: 10-1.178600-10.000000 X-TMASE-MatchedRID: a4Q7dosAlP6Po+6vQMop+ikMR2LAnMRpCZa9cSpBObnAuQ0xDMaXkH4q tYI9sRE/7qN2AY1LBYfX/4cXJB77G82IoAvAG8Cytw+xHnsmQjMRKrbwgeEU4psoi2XrUn/Jn6K dMrRsL14qtq5d3cxkNePDdA+sPJoJpIWVq2FPrVRC8PbPp9VJvAwE3szHrU0AtN2HcZBPqwdFSR N53IQttjRtl6ZG50f040PXgYNLw2sECcFYp/ZlI4xrU96OxkmsFcUQf3Yp/ridO0/GUi4gFb0fO PzpgdcEKeJ/HkAZ8Is= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 It's a helper to set the parent resource for the altmap of a given pgmap CC: Andrew Morton CC: Dan Williams CC: Baoquan He CC: linux-mm@kvack.org Signed-off-by: Li Zhijian --- include/linux/memremap.h | 1 + mm/memremap.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index ca1f12353008..1e8b25352f7c 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -193,6 +193,7 @@ static inline bool folio_is_device_coherent(const struct folio *folio) void zone_device_page_init(struct page *page); void *memremap_pages(struct dev_pagemap *pgmap, int nid); void memunmap_pages(struct dev_pagemap *pgmap); +void pgmap_parent_resource(struct dev_pagemap *pgmap, struct resource *res); void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap); void devm_memunmap_pages(struct device *dev, struct dev_pagemap *pgmap); struct dev_pagemap *get_dev_pagemap(unsigned long pfn, diff --git a/mm/memremap.c b/mm/memremap.c index 78047157b0ee..0bbf163d4817 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -390,6 +390,13 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid) } EXPORT_SYMBOL_GPL(memremap_pages); +void pgmap_parent_resource(struct dev_pagemap *pgmap, struct resource *res) +{ + if (pgmap && res) + pgmap->altmap.parent = res; +} +EXPORT_SYMBOL_GPL(pgmap_parent_resource); + /** * devm_memremap_pages - remap and provide memmap backing for the given resource * @dev: hosting device for @res From patchwork Wed Mar 6 10:28:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13583826 X-Patchwork-Delegate: iweiny@gmail.com Received: from esa12.hc1455-7.c3s2.iphmx.com (esa12.hc1455-7.c3s2.iphmx.com [139.138.37.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9884960868 for ; Wed, 6 Mar 2024 10:30:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.138.37.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721028; cv=none; b=tV/RrvQAbc9JjRt0L3QJVcEwNQ80+Dk5xpJRXvOXi9D0+ibooRaxztxfhmwMl6/9VpRq1FmarUWuA0eQ2F4699Mn/c3bWBTEfbeR2j++hFsa9SHXKyFBUqdhGaJfA05eOwbsr8QL7zL4PZ5PBW4aw/CrOXl0ibJl2B4U17Q5tuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721028; c=relaxed/simple; bh=8m938ej88oP8CU4LRmFGqeZ2eI8zznrXHFjHuzUAi80=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ix3fwvX+NDY+Z20Nr15lMp/pGNkEAGaK8X58DAgskLykvNTHVCuu0/9sRLG1ghCbnjNnFkCMS/gRWW+DzVbtbCUkACBVCX/YN2wBCRd6kpsmlw7cgMVgeGYBTkBtq0Mgfuk+N9teVJCjKgw/zt2KW4Q1jux1n4JmlkbNhxh9uAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=PwKdS9ab; arc=none smtp.client-ip=139.138.37.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="PwKdS9ab" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709721026; x=1741257026; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8m938ej88oP8CU4LRmFGqeZ2eI8zznrXHFjHuzUAi80=; b=PwKdS9abdjQvI8XscYmBP1eN+2/f0JlKJHSL5t4mWHi4gfr3st5r8op7 5/LYpMMRN0O6SBrJZqtfSfuj6TjSl1V4MNKGcBQj2VbTipKr6ENnAWk+Q 2gEMHeLK9OGMRcJFWg9HJGpgjEzNUJaxqFfvy2la5CHmEueRtEGXCa0W7 SPIDYO43ERXElIEuWIuPgbqhaX06d+Mo6C/L35ADv8+Ydl2VRN00LXE9D 1vwfjorxo74vnMQCf8214LU5iZVixY4TKOT7GDjH5kh4+zxh09MNYLLyu qqEl99OQHiFJIZnXVfiETdKRJ545NTl3woFiWqFRMXqaqZ53GRoeqvHGQ A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="130699032" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="130699032" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:13 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 2F63BEB462 for ; Wed, 6 Mar 2024 19:29:10 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 56D53D5D17 for ; Wed, 6 Mar 2024 19:29:09 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id C654121BD41 for ; Wed, 6 Mar 2024 19:29:08 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id D32BA1A006D; Wed, 6 Mar 2024 18:29:07 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: y-goto@fujitsu.com, Alison Schofield , Andrew Morton , Baoquan He , Borislav Petkov , Dan Williams , Dave Hansen , Dave Jiang , Greg Kroah-Hartman , hpa@zytor.com, Ingo Molnar , Ira Weiny , Thomas Gleixner , Vishal Verma , linux-cxl@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org, kexec@lists.infradead.org, Li Zhijian Subject: [PATCH v3 3/7] nvdimm: pmem: assign a parent resource for vmemmap region for the fsdax Date: Wed, 6 Mar 2024 18:28:42 +0800 Message-Id: <20240306102846.1020868-4-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240306102846.1020868-1-lizhijian@fujitsu.com> References: <20240306102846.1020868-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28234.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28234.006 X-TMASE-Result: 10--1.564400-10.000000 X-TMASE-MatchedRID: BlFNdihulaZXk4HjwySOxykMR2LAnMRpFInyGi5rPwK4GyTmeN+AbL8F Hrw7frluf146W0iUu2tDc4lSgrowpWptPhjDCRug9k5nZzZVBSBULRRq00o2mZsoi2XrUn/Jn6K dMrRsL14qtq5d3cxkNU8XOMKR+RhSziRYTTEaxycNH0kK2Y6lBnFLca4Td9YkovbRRC+8RtSqnf dPSmIOZvdj0cn+WGO3HBgXAGNBpen5KWrl6H4maf8jyjqYHnMRFcUQf3Yp/ridO0/GUi4gFb0fO PzpgdcEKeJ/HkAZ8Is= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 When the pmem is configured as fsdax, set the vmemmap region as a child of the namespace region so that it can be registered as a separate resource later. CC: Dan Williams CC: Vishal Verma CC: Dave Jiang CC: Ira Weiny CC: Baoquan He CC: nvdimm@lists.linux.dev Signed-off-by: Li Zhijian --- drivers/nvdimm/pmem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 4e8fdcb3f1c8..b2640a3fb693 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -452,7 +452,7 @@ static int pmem_attach_disk(struct device *dev, struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev); struct nd_region *nd_region = to_nd_region(dev->parent); int nid = dev_to_node(dev), fua; - struct resource *res = &nsio->res; + struct resource *res = &nsio->res, *parent; struct range bb_range; struct nd_pfn *nd_pfn = NULL; struct dax_device *dax_dev; @@ -491,12 +491,15 @@ static int pmem_attach_disk(struct device *dev, fua = 0; } - if (!devm_request_mem_region(dev, res->start, resource_size(res), - dev_name(&ndns->dev))) { + parent = devm_request_mem_region(dev, res->start, resource_size(res), + dev_name(&ndns->dev)); + if (!res) { dev_warn(dev, "could not reserve region %pR\n", res); return -EBUSY; } + pgmap_parent_resource(&pmem->pgmap, parent); + disk = blk_alloc_disk(nid); if (!disk) return -ENOMEM; From patchwork Wed Mar 6 10:28:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13583827 X-Patchwork-Delegate: iweiny@gmail.com Received: from esa12.hc1455-7.c3s2.iphmx.com (esa12.hc1455-7.c3s2.iphmx.com [139.138.37.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13463605AD for ; Wed, 6 Mar 2024 10:30:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.138.37.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721031; cv=none; b=Qcwq0CQikeAoV+6GsrRwFoZylmP8W5vMCgK2WokdJ5GmaM0Dyjgj2WdVx4JD+ff6OmGWun1NFg4ThUbjFzXSb+/PTY7yBb0QbOB1zLnDuEa98eJ79MPwhTbIr4O0oQ4iBlY00yvynXYMvUXoBR931zAuu+lkWXU9pUnRNXsOvmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721031; c=relaxed/simple; bh=ZZY/OmJnWGlv4sXJ9ctR7zLIBkL6jlFxWOynKDfrnCI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mX+XOAGIodPI+9jpucExv5/rY4FxeIP2ls9+FqoJKL1RA5x8QfNuULgXF84lgbqwQl+yi626xD5D3T6o3L+2x+//GnoSrWCKwG/camLaUqqWjJ9mIImuq6i1NvigR6G0jaPVnbamwE8p91Ajn10iLd0+Rk1rVVj3jzbBCwGXEhs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=USDkrBey; arc=none smtp.client-ip=139.138.37.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="USDkrBey" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709721029; x=1741257029; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZZY/OmJnWGlv4sXJ9ctR7zLIBkL6jlFxWOynKDfrnCI=; b=USDkrBeyM/u5t5bpnLjTvq/B8dvTz8DIuNhGwCefFlHi3CzUoGHC3MMw Rdzzqtj58pk1nwAVpZoDl9iR6+PurNz83xJV+c2i8QDAEH6l4r/gzNWmL z7h4GA5AfNrF5GWokIfFgY+Q2xzpucMvIu7Y+N0nCk9dJHmwC7zo9aZCe QnaU8VTBdBk1qMMB4Ypkq8gLEOGYa/w1+Ik4Ya/tiDAEoBW4j81a9neJs 4MRuLpso6b99sgWw3NC3OosSZm44LYH3rhBt5g002x3hMR7he+bcnVK3/ TFXX/SXUK+njrN+d/3M7cGgNLfeE8Jy3qPLYijxsm1bhZFiBSVNFz6kPH g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="130699034" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="130699034" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:15 +0900 Received: from yto-m1.gw.nic.fujitsu.com (yto-nat-yto-m1.gw.nic.fujitsu.com [192.168.83.64]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id DF4E25EA65 for ; Wed, 6 Mar 2024 19:29:10 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 277E6D21CB for ; Wed, 6 Mar 2024 19:29:10 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 938BE6BED0 for ; Wed, 6 Mar 2024 19:29:09 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id A5E001A006A; Wed, 6 Mar 2024 18:29:08 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: y-goto@fujitsu.com, Alison Schofield , Andrew Morton , Baoquan He , Borislav Petkov , Dan Williams , Dave Hansen , Dave Jiang , Greg Kroah-Hartman , hpa@zytor.com, Ingo Molnar , Ira Weiny , Thomas Gleixner , Vishal Verma , linux-cxl@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org, kexec@lists.infradead.org, Li Zhijian Subject: [PATCH v3 4/7] dax: pmem: assign a parent resource for vmemmap region for the devdax Date: Wed, 6 Mar 2024 18:28:43 +0800 Message-Id: <20240306102846.1020868-5-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240306102846.1020868-1-lizhijian@fujitsu.com> References: <20240306102846.1020868-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28234.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28234.006 X-TMASE-Result: 10--5.083400-10.000000 X-TMASE-MatchedRID: Q3OJUoK6MKVXk4HjwySOxykMR2LAnMRpFInyGi5rPwK4GyTmeN+AbD13 GoPFA1HFIvrftAIhWmLy9zcRSkKatS9AD6DbcToHEVuC0eNRYvKZIt4iAQN6P6oDeu6wu7bqj26 lKB/EzKHoHOpl9ZcDR4Ay6p60ZV62fJ5/bZ6npdg7AFczfjr/7Cf8pL7Z+mamZiZ008tHBX0M7U m3uTFNcAFzvFI3lI92rZlDJo+ExYU= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 When the pmem is configured as devdax, set the vmemmap region as a child of the namespace region so that it can be registered as a separate resource later. CC: Dan Williams CC: Vishal Verma CC: Dave Jiang CC: Baoquan He CC: nvdimm@lists.linux.dev CC: linux-cxl@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/dax/pmem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c index f3c6c67b8412..6ffeb81e6c7c 100644 --- a/drivers/dax/pmem.c +++ b/drivers/dax/pmem.c @@ -21,6 +21,7 @@ static struct dev_dax *__dax_pmem_probe(struct device *dev) struct nd_dax *nd_dax = to_nd_dax(dev); struct nd_pfn *nd_pfn = &nd_dax->nd_pfn; struct nd_region *nd_region = to_nd_region(dev->parent); + struct resource *parent; ndns = nvdimm_namespace_common_probe(dev); if (IS_ERR(ndns)) @@ -39,8 +40,9 @@ static struct dev_dax *__dax_pmem_probe(struct device *dev) pfn_sb = nd_pfn->pfn_sb; offset = le64_to_cpu(pfn_sb->dataoff); nsio = to_nd_namespace_io(&ndns->dev); - if (!devm_request_mem_region(dev, nsio->res.start, offset, - dev_name(&ndns->dev))) { + parent = devm_request_mem_region(dev, nsio->res.start, offset, + dev_name(&ndns->dev)); + if (!parent) { dev_warn(dev, "could not reserve metadata\n"); return ERR_PTR(-EBUSY); } @@ -66,6 +68,8 @@ static struct dev_dax *__dax_pmem_probe(struct device *dev) .memmap_on_memory = false, }; + pgmap_parent_resource(&pgmap, parent); + return devm_create_dev_dax(&data); } From patchwork Wed Mar 6 10:28:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13583823 X-Patchwork-Delegate: iweiny@gmail.com Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E986960262 for ; Wed, 6 Mar 2024 10:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.139.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720960; cv=none; b=afsEEvIlFBjyLD2CP5I4Y8aTEPvRN6BDr8fsgrkaGk/Ap4n1nDAiYXfgsAvdK0yKxn+GJXSkFWt4fb1yzjTB2OpRaNtsc20O6YbLvoT2NOSiYNoL1H2PhW+uGmeRozlDiCy/mbt1/ILZyM7feU4Wio+6RM6eGtdeJv6ZMrFdF+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720960; c=relaxed/simple; bh=XdN3aG00u/QsuyGD6b2X8W2/qtDpU1h/uB9UBsmVuQc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mfJA4VBB3nM8O5xdmj+/MI3s+wKc5TROOn4rx3AVjkxjDYnmycH9FIZ+W5AkizYy5rBXuntxX/kMZRvAtoc0LjHYgD9mrAh/XEKhIayL5CPuURCEc55xmATBqIJrTu/y0kl+ErI1bISoCUkfxYpN26Nds/arGzEclTEzgTsLrcA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=D8olPbgM; arc=none smtp.client-ip=68.232.139.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="D8olPbgM" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720958; x=1741256958; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XdN3aG00u/QsuyGD6b2X8W2/qtDpU1h/uB9UBsmVuQc=; b=D8olPbgMSPhINkwiQSpfLpO/MdhvR8OAA2heUs4lMMgNSaWDZDAaKrBs uuIS1xXN7EANMwngfKrRf9Nl9psk1BKF0310GFfwzJOgVb3F9tOyH9Re0 SWCApwMV9eMFH4xyJEvdkfAKHAK2qmt50hn0ERFc4JYpDJRqotrkG/lij JJwYjjohgnV3vDiQBksVDl2sD0kkHKh8qxWkVInqrAMy59e3bYDkU++H0 65m28OGSzdfW3JgzWfKUsQweykkav9LiSHEmES8n4yRPlUdooQd9aDMyG iUAWrLZ1vRbRdgao6h6FaXlHwkwNavvwG3r8WPnBqlN4ImfNSfItqVh03 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="153205397" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="153205397" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:16 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id ACC009D91F for ; Wed, 6 Mar 2024 19:29:11 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id E27CDFDA06 for ; Wed, 6 Mar 2024 19:29:10 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 69C36202CB587 for ; Wed, 6 Mar 2024 19:29:10 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 782981A006D; Wed, 6 Mar 2024 18:29:09 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: y-goto@fujitsu.com, Alison Schofield , Andrew Morton , Baoquan He , Borislav Petkov , Dan Williams , Dave Hansen , Dave Jiang , Greg Kroah-Hartman , hpa@zytor.com, Ingo Molnar , Ira Weiny , Thomas Gleixner , Vishal Verma , linux-cxl@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org, kexec@lists.infradead.org, Li Zhijian Subject: [PATCH v3 5/7] resource: Introduce walk device_backed_vmemmap res() helper Date: Wed, 6 Mar 2024 18:28:44 +0800 Message-Id: <20240306102846.1020868-6-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240306102846.1020868-1-lizhijian@fujitsu.com> References: <20240306102846.1020868-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28234.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28234.006 X-TMASE-Result: 10--2.753200-10.000000 X-TMASE-MatchedRID: VGeBglENKylzKOD0ULzeCRFbgtHjUWLyPeYVUCg2LRwBLwIiWDU8ay15 IFUNL+ETjx5X3FdI4UDmn3xyPJAJoh2P280ZiGmRcFEiuPxHjsXDCscXmnDN79P7VmP7Drr66us OKvlQZawRYCju0yIRX4Ay6p60ZV62Mhe627A+8aHdB/CxWTRRu+rAZ8KTspSzZ9zg/iRwE4LkAQ bstzNuLM5Iu+GqAiaI4D/GW2/5ILcxeNB9x03X8fQFNK0GDkNxsoGRy2pyHXLNTBw2qqp0+A7H6 7Vl1o7oIcmnZRhVxyrE4HwnSlEuHInEpJmLAFfpC1FNc6oqYVV+3BndfXUhXQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 It walks resources registered with flags (IORESOURCE_DEVICE_BACKED_VMEMMAP | IORESOURCE_BUSY), usually used by device backed vmemmap region. currently, it only sticks to the persistent memory type since it is only one user. CC: Andrew Morton CC: Baoquan He CC: Greg Kroah-Hartman CC: Alison Schofield CC: Dave Jiang CC: Dan Williams Signed-off-by: Li Zhijian --- include/linux/ioport.h | 3 +++ kernel/resource.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 3b59e924f531..10a60227d6c2 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -332,6 +332,9 @@ extern int walk_system_ram_res(u64 start, u64 end, void *arg, int (*func)(struct resource *, void *)); extern int +walk_device_backed_vmemmap_res(u64 start, u64 end, void *arg, + int (*func)(struct resource *, void *)); +extern int walk_system_ram_res_rev(u64 start, u64 end, void *arg, int (*func)(struct resource *, void *)); extern int diff --git a/kernel/resource.c b/kernel/resource.c index fcbca39dbc45..5f484266af07 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -431,6 +431,19 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, func); } +/* + * This function calls the @func callback against all memory ranges, which + * are ranges marked as (IORESOURCE_DEVICE_BACKED_VMEMMAP | IORESOURCE_BUSY) + * and IORES_DESC_PERSISTENT_MEMORY. + */ +int walk_device_backed_vmemmap_res(u64 start, u64 end, void *arg, + int (*func)(struct resource *, void *)) +{ + return __walk_iomem_res_desc(start, end, + IORESOURCE_DEVICE_BACKED_VMEMMAP | IORESOURCE_BUSY, + IORES_DESC_PERSISTENT_MEMORY, arg, func); +} + /* * This function, being a variant of walk_system_ram_res(), calls the @func * callback against all memory ranges of type System RAM which are marked as From patchwork Wed Mar 6 10:28:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13583829 X-Patchwork-Delegate: iweiny@gmail.com Received: from esa12.hc1455-7.c3s2.iphmx.com (esa12.hc1455-7.c3s2.iphmx.com [139.138.37.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84BB260BBB for ; Wed, 6 Mar 2024 10:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.138.37.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721032; cv=none; b=D/HFYWqnLbXrMnlPO3uU5L0ylyFm7j6oWnCHLDodkgPfrL7R5JUAp14jPLQFs3FOs0doQavwUcOzwTBzQCbNiJbuU3yCrN6ga6ykXCc0As7NK4O37Kx82DCHHCCkoeD7zKbSPA4BsinMfENHhzl1ip8pTFY6ATmQxbc5IgA0Pgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721032; c=relaxed/simple; bh=Nq7SMqNBqa42A9Gw9it0V4iEBEk255GCXGK0EU8r0Nc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ILO4zbjo8+ylHnZpeZ6S47AJZv5b5jmXjzwAhGyFl7aTOJo84iRvU8NUdCr6PAoMtgUNXgKSRKF2cGPJHRPV7fUF8vWbP7Pyq5Q2U3XJj7uxa59M9JiinFCKk85vOtz5Rznwlwe3apPdYM01zD0RddafFV6/tcXJ9pV0xBC7IVE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=XCRrjxiS; arc=none smtp.client-ip=139.138.37.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="XCRrjxiS" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709721030; x=1741257030; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nq7SMqNBqa42A9Gw9it0V4iEBEk255GCXGK0EU8r0Nc=; b=XCRrjxiSIeXxmUi3QHdV1aE4qlSYSjWA75CQ1Vi31I/GoCQ/ICrGVgDH 9uBUq5xVMehxqCw7wlF7kU837CdTnkm5tlcMfSFofk4Ji2oTY28LJk8Jl 493ptmBiczT/tF4ugAXzIuGdCj4Uh5JDFT/VKDtzGB1BdNH1iNWea1qk/ XGmu71VonYPL5T0vWWEiD7a69k4S8JMmejPyGz04bnNUh6m8rzWZgzWvW OdEmcQ9ddOAdfbVgiwDlDxy5rD7dFZRze7Bkk2RGGWbez1Ft0YNIEE8jH 6JaPsWxIWf6KCxElEN4gxMrS0lVEVNZAUxIN4EGdkYbepPascXCJSe5cU g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="130699037" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="130699037" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:17 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id DF814A31CE for ; Wed, 6 Mar 2024 19:29:12 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 224D4D5E8C for ; Wed, 6 Mar 2024 19:29:12 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 421402030C7E9 for ; Wed, 6 Mar 2024 19:29:11 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 4A1AE1A006A; Wed, 6 Mar 2024 18:29:10 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: y-goto@fujitsu.com, Alison Schofield , Andrew Morton , Baoquan He , Borislav Petkov , Dan Williams , Dave Hansen , Dave Jiang , Greg Kroah-Hartman , hpa@zytor.com, Ingo Molnar , Ira Weiny , Thomas Gleixner , Vishal Verma , linux-cxl@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org, kexec@lists.infradead.org, Li Zhijian Subject: [PATCH v3 6/7] x86/crash: make device backed vmemmap dumpable for kexec_file_load Date: Wed, 6 Mar 2024 18:28:45 +0800 Message-Id: <20240306102846.1020868-7-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240306102846.1020868-1-lizhijian@fujitsu.com> References: <20240306102846.1020868-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28234.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28234.006 X-TMASE-Result: 10--8.255800-10.000000 X-TMASE-MatchedRID: Eprm7pA/VZ5ZxhI5bGrNsjiEPRj9j9rvSdIdCi8Ba4AiqRodPpseIRwE EIVsM/kp/lneBjailE5V00+whwxVQy/7QU2czuUNA9lly13c/gH4uJ1REX4MHbs3Yh2IOCYzJti zbkLGoS92PULLZTziuytFAV6Sdl32oFf+7ciBzQpYKMMlFh4BncnlJe2gk8vIMzT8XBPSpdajxY yRBa/qJXcsDK2xBHh7jaPj0W1qn0Q7AFczfjr/7LEnb/1qBW++QLtrZDNFv46p+VAyfOE7vP5i9 RGEpFvIT2g+olvABKw= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Add resources with specific flags to PT_LOADs of the elfcorehdr so that these resources can be dumpable. This change is for kexec_file_load(2) while kexec_load(2) setups the PT_LOADs according to its parameters by the callers which usually rely on resources' name from /proc/iomem CC: Thomas Gleixner CC: Ingo Molnar CC: Borislav Petkov CC: Dave Hansen CC: Baoquan He CC: Andrew Morton CC: "H. Peter Anvin" CC: x86@kernel.org Signed-off-by: Li Zhijian --- arch/x86/kernel/crash.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index b6b044356f1b..b8426fedd2cd 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -146,6 +146,8 @@ static struct crash_mem *fill_up_crash_elf_data(void) if (!nr_ranges) return NULL; + walk_device_backed_vmemmap_res(0, -1, &nr_ranges, + get_nr_ram_ranges_callback); /* * Exclusion of crash region and/or crashk_low_res may cause * another range split. So add extra two slots here. @@ -212,6 +214,9 @@ static int prepare_elf_headers(void **addr, unsigned long *sz, if (ret) goto out; + walk_device_backed_vmemmap_res(0, -1, cmem, + prepare_elf64_ram_headers_callback); + /* Exclude unwanted mem ranges */ ret = elf_header_exclude_ranges(cmem); if (ret) From patchwork Wed Mar 6 10:28:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13583828 X-Patchwork-Delegate: iweiny@gmail.com Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55FEB60B8C for ; Wed, 6 Mar 2024 10:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.138.61.252 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721031; cv=none; b=s87qWudjHrYyeJYxbfgYw2ifQdk4clFVX2TlxILESh2gew7qsH7yKExX0qOSINqPu9of8azqjz7VsFNrW+0XDwwN9aEK6pyQxsxwsscsLMlYN0KNvOBULLQldBpY26QTDG2FYLIfnQf10VSjI+RK4U0DxSCsAxk2mlWmjLWolpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721031; c=relaxed/simple; bh=cfFr9yDzIDYGuhO0ed+4EUdT/tYXSwMTNGM6ftOGOr0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pXwRGxHOleEX9bQoVmqF2edxoSroCmk18CN122McYGAk7d4dUkk8niFG5WlCfZig4TOh4D+SDmD1BFKraCRsTsgSc/Vxp+Y/3mhgWTXOxQMSmLhyZAzxBl5u6NPUmm8ANdu3f+JF97nF/HTiVbXZXELjHH90LYALIEw7bGhqyRE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=t6MRrG+I; arc=none smtp.client-ip=139.138.61.252 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="t6MRrG+I" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709721029; x=1741257029; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cfFr9yDzIDYGuhO0ed+4EUdT/tYXSwMTNGM6ftOGOr0=; b=t6MRrG+ILIbQcfC81LTnJpvHK7NuuRVz+Gww++FIofNQ5bSyxqs22UyH 8hzC2luLvas7yCPQ6NgB96FQhfZHLIoprv763j/VMOxKPUyAJMxC3BxVr RELUwj6MgdiZkJse+EjKhLll7uu6y2O7vWRurO4hZr/jSIhdaRmPeC00N 49CqnBwpqQ1tiIV+Jq8p4kjFv/phzrIzH9zPcNaisJn5Ep87Jw9uPPSIv 4KPB21t2zQdeyz6G6+pyjtZ6ahfPLCK8/OscOtzN3n3yTZvRjb0lm+yMw UYZEO8TOX8bJJYgPxDkhkuaOcjV4i1CMlu/bmETvhTEStOLmO6TW1HMIM g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="130208884" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="130208884" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:17 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 52BAB9CCB6 for ; Wed, 6 Mar 2024 19:29:13 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 802F0E6182 for ; Wed, 6 Mar 2024 19:29:12 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 1207F202CB587 for ; Wed, 6 Mar 2024 19:29:12 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 1E80D1A006D; Wed, 6 Mar 2024 18:29:11 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: y-goto@fujitsu.com, Alison Schofield , Andrew Morton , Baoquan He , Borislav Petkov , Dan Williams , Dave Hansen , Dave Jiang , Greg Kroah-Hartman , hpa@zytor.com, Ingo Molnar , Ira Weiny , Thomas Gleixner , Vishal Verma , linux-cxl@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, x86@kernel.org, kexec@lists.infradead.org, Li Zhijian Subject: [PATCH v3 7/7] nvdimm: set force_raw=1 in kdump kernel Date: Wed, 6 Mar 2024 18:28:46 +0800 Message-Id: <20240306102846.1020868-8-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240306102846.1020868-1-lizhijian@fujitsu.com> References: <20240306102846.1020868-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28234.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28234.006 X-TMASE-Result: 10-2.938000-10.000000 X-TMASE-MatchedRID: MGSvkkc+rOj7w6uw5pqYnoOlbll4OMtk9LMB0hXFSeg6Zx3YUNQTG+Wh NKYuM7eN4QRvjxz49tHS7j6TEIEt1D3TQfUpAv1sPkILbTHNp5vYUDvAr2Y/17fYIuZsOQ0sOXB 2cqV0mCIre4xpX839SBGJgBWjZYF4x7Pq8adLcfrum6Nvy6t3NlK6+0HOVoSowLkNMQzGl5B+Kr WCPbERP80Age9hS2jaRMoI0qlZNIJF28kU6TjvF869emDs42ddfS0Ip2eEHnz3IzXlXlpamPoLR 4+zsDTtqrM46JQnL8hECPUxiiiZOrOyZvt4D+xsOs3xt1PQttJyHuAILm2j36P9W6TbIoRbP/Sq eQCjGYXssHsZ3G5ixlOiTS2pFc4fpGuqGtYITgaGk+xUaqdMDwHEKwHwYevbwUSxXh+jiUgkww/ gwY7hMA== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 The virtually mapped memory map allows storing struct page objects for persistent memory devices in pre-allocated storage on those devices. These 'struct page objects' on devices are also known as metadata. During libnvdimm/nd_pmem are loading, the previous metadata will be re-constructed to fit the current running kernel. For kdump purpose, these metadata should not be touched until the dumping is done so that the metadata is identical. To achieve this, we have some options 1. Don't provide libnvdimm driver in kdump kernel rootfs/initramfs 2. Disable libnvdimm driver by specific comline parameters: (initcall_blacklist=libnvdimm_init libnvdimm.blacklist=1 rd.driver.blacklist=libnvdimm) 3. Enforce force_raw=1 for nvdimm namespace, because when force_raw=1, metadata will not be re-constructed again. This may also result in the pmem doesn't work before a few extra configurations. Here apply the 3rd option. CC: Dan Williams CC: Vishal Verma CC: Dave Jiang CC: Ira Weiny CC: nvdimm@lists.linux.dev Signed-off-by: Li Zhijian --- drivers/nvdimm/namespace_devs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index d6d558f94d6b..04f855c7f0b1 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "nd-core.h" #include "pmem.h" #include "pfn.h" @@ -1513,6 +1514,8 @@ struct nd_namespace_common *nvdimm_namespace_common_probe(struct device *dev) return ERR_PTR(-ENODEV); } + if (is_kdump_kernel()) + ndns->force_raw = true; return ndns; } EXPORT_SYMBOL(nvdimm_namespace_common_probe);