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: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13583834 Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (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 78E4D604C2; Wed, 6 Mar 2024 10:30:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721024; cv=none; b=gHliEaZJ/rr35btcAzrSJvs5mGebURzeFaKEGYvcy/YRga8S0JJq8Acd0u5cTddxnjZXE0OayOZSwc5bn5Vc4o7lpnfbJnF1peFKLt2N+ifbmYpSlHrwNyacNnZg5pykRBI4sQQOTPEar4k4Dv/j7zT2irkhK80bsWlufhC+8Gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721024; c=relaxed/simple; bh=ZoN1+liG2Aek8I+8vh1JTxN3rQPUF7ESoET6QRxJG2I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hj3SgXZ24Aj5PxGB4S8PShFfJGrTsVGtqYhtED2W3r88NPIs5SuV/+mdZL0ZU+cht/bUDBcPcVMeOUwHDhbsWA/qTzzVqmhQHZrvk1wL4wM1sk/cqbVGD8lPNZhAiaaK5fB0hOYo4R0Z5CT3vOKj5QjgpBGYgLsKBBqH9tc2s5o= 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=FNcbo/gn; arc=none smtp.client-ip=207.54.90.49 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="FNcbo/gn" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709721023; x=1741257023; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZoN1+liG2Aek8I+8vh1JTxN3rQPUF7ESoET6QRxJG2I=; b=FNcbo/gnlu+YvRUAcpFeynbZMsdJexcpoJCrOPDLk47ZUsK8eXXBIKxT 5dpYMMQSPRgAB3x+/E03PjWlrCxvQjiBUJQc5mLwcrjFgJAZb/Pk6TDFl qdvcTilBWSzrfs2rnf+9baXwiOYWaaSiDM0j40V/1nX4MAR0lEiECC1Ud 704erywYU4yfZckuKJFP871cq3R9onmpdjzGOMzYkBcNH4LNZfK+4KykN nnq9HPRGUeWv6yAd3ehh/eSXzZvAaPy5BkqF2r57DN/37kZbM05DHl1l6 PCQFsp9YoZbYFtxo96FxrN3RiHJeFO6MKqNkMSNRMSo8hG5/gsKi9LCoc A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="151395780" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="151395780" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:12 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 81CAADD92F; Wed, 6 Mar 2024 19:29:08 +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 9D2FDD5D18; 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-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 2501621735C; 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: linux-cxl@vger.kernel.org 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: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13583830 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 7E5415F875; Wed, 6 Mar 2024 10:29:14 +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=1709720957; cv=none; b=KRntji8LtN93TTIHrBwK4Yu8BzGCs2dlKKQoYOpJNfU1RprruJx91bQ+WL8rbhaYjKD83UUECoh2ft9c9S+avbu05ETPUTan5XvEEs/ohA94syZpz78FpbfhlLxQ8YHR6O839670PTSFanQOunqzgiDuWYU/McVNuOWy9UXe0e0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720957; c=relaxed/simple; bh=qPTXg1j60dmCKgrUxhmFd4z9be0Rjp54MJE3FLxdEQM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ASgwX8xLQ5MfPzaynZbnKYHoCxdbu+ItAPj0cwxpA3PontLamlbDfCGx7R1Fqo4hJ5Wl67oy42Qt/ToG7nYydWBYiFB1mhhhU9IvJjZ4XG7Wx5L/CxhWrWowg2lJ4VCKGlCk8jUg+Qr+ODUJ7ax/sJHoHVpSCS3x2QpJMsZWVns= 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=rAs/UTvt; 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="rAs/UTvt" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720954; x=1741256954; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qPTXg1j60dmCKgrUxhmFd4z9be0Rjp54MJE3FLxdEQM=; b=rAs/UTvtVtevHStPZqS/hThfRsybHUjXma0pC78BDFINNhebZIlrPoZL +PcnyrHNx6Um3ww2tV+uf1paGze/kb6YMj/jjcBiHBtbmDHNtZjy2FZZf RQqH+5Ph2k2I+lKZNqwD6xsgHkq+Orqwot3ViXIf/t5bgR8CdRIleRYfl aRjAaJlEONXcpm1Fs2Ut+No96KD8HJU4NpzBWrPbzVJzj4NnivU25OKqZ HbEMOK0bDFm+8F+Sr9+4aWzle9Jk2TWSYidEoSxofsLLhLYfZx7zR4Xl3 ZzSS6vPKIcCqf96z6vCcqh4DkAVrtrAOEwkXLyjjPH9XKAuRyM4D5HrsH g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="153205386" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="153205386" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:11 +0900 Received: from yto-m1.gw.nic.fujitsu.com (yto-nat-yto-m1.gw.nic.fujitsu.com [192.168.83.64]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 3D3AEC68A0; Wed, 6 Mar 2024 19:29:09 +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 7DCD642613; 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-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id EE62B6BED0; 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: linux-cxl@vger.kernel.org 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: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13583833 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 2EFC5604C5; Wed, 6 Mar 2024 10:29:25 +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=1709720967; cv=none; b=ujL9mGF61/sUSdD2b+cgLZTSJSq3rld3fTyg6Eh0A05/o2bjN7LkR53ZGoekzqHC6WD3t1YSkdW3PuFfTzRHsQ0Qeyph3v4sA89LPkrtfxw5q9LTfE6YgdBG69FlkA8yKjogbcDbSHxuEAJPX14GSNUxa8SNT0Mv9RDmM9tBJdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720967; c=relaxed/simple; bh=8m938ej88oP8CU4LRmFGqeZ2eI8zznrXHFjHuzUAi80=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kEiY1pyPc1IpLkrZrv9sLZ2DQCa72ay7nGpSTuq7/PYI2i07nPAKO98E7VC+YI6dmien3dcde0O6I/+hS1LvsSQ3X1TxtuqU8ymh/gcVuCeT0KPhfIjhMhGVVRS0yoIeWelSdFMW99dJ/cgQnqU86PxqDgjW0n5+BCaKJud9jO8= 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=CJxeW3SQ; 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="CJxeW3SQ" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720965; x=1741256965; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8m938ej88oP8CU4LRmFGqeZ2eI8zznrXHFjHuzUAi80=; b=CJxeW3SQNa0MAFqvZuu+siIYO1wx7FE+itbOPaeNf+8jkPGH5GmUPS/E SvfVOiUyrI/C2IebW1Uv777CuWKsBdzMOcOmsp9RzzO456TeVZLfvRC44 jeHFMqOk/c8eMTghEot5sWqVkHMGk+lyPM6CDgObytK3jlfJUID0lkKBt +4iSK2Qsf/ABF5Xd78KtbnTdQJk1gG2Q701lbunUG4QlaKZOdHKAEAtV2 t423y561TRLfKo6Ir2KHCuGiQeYHrkRf3rTyhv8Fofapvk0THoyiSIt3r 7uf/BTV0KWuz8oU0ANQfXQgZckeWa3+cW9QQv0VPTMh7mF8bGzqhJuMSv g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="151260039" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="151260039" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:15 +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 130605EA65; Wed, 6 Mar 2024 19:29:10 +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 52A3ED561A; 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-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id C51992030C7E2; 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: linux-cxl@vger.kernel.org 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: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13583836 Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) (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 AC1B26086E; Wed, 6 Mar 2024 10:30:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.139.117 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721028; cv=none; b=VfxgMsqLeYTuUT+S3YWUi3rH7zgRxVZQIdsTXvrpOF2J8H6KT+ASKBkMVzWL6WUq4jKa2aYJOIU93+XOqT6+Qx2MxRT84RekScPazdiMO6NtGu86Il1ePnDPvLlC8FootHC1pwxS58cM+9mZzOQVUtmMqFUu6CFYHHKuolTaEsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721028; c=relaxed/simple; bh=ZZY/OmJnWGlv4sXJ9ctR7zLIBkL6jlFxWOynKDfrnCI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B8+1lryIPDqSL5mClX5lNhuprzmp0Y0nfRo3Uqrlk62U58d58/Uuge5qxVTgO4GUKAQAiU3FTzcxrKtqDqFQ/2lrjeHz4VFTXuHjwhcllRjgW/1MmBgRu5VQ13+VxWl3/RxtoLDhkAeDA79oJTqqDgNwTj8bivgb97nGAKOXILs= 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=T2B9GnSe; arc=none smtp.client-ip=68.232.139.117 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="T2B9GnSe" 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=ZZY/OmJnWGlv4sXJ9ctR7zLIBkL6jlFxWOynKDfrnCI=; b=T2B9GnSeb85UdGtzWKDyox6Dtkl+rX8uFeJKgr9LtGFandWmQzdRG2PW vv/1C7vCqx5cXXfifQi4FXmnsheFdCJL4qRdgVGC883DKvJJmsaN70QlU VnzCq8z3nq3oYoAWCXg6mr7M3smvrAYZ0YsanQ0L8qHDKCSgrRPq75Jj9 M8ObLQ8gjOPe0yDrGukkhDZ/012StW7yjU3e6oOI4rlrhyazbJTasXfXj WWprqB9yA/z+en5Du5dYS9TfbrkFWk7DkBy9JiRyM/nY6eJyYrrqecbrA r2irn/0XHnaIe8JxFE45UatpG0yGlgWKd3yURHyLbdVh7lLk4Mz39wvjH A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="151690186" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="151690186" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:14 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 111A5EB462; 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-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 3D8F5BF3C9; 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 9BBCD2030C7E9; 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: linux-cxl@vger.kernel.org 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: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13583832 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 DFBB35FDBD; 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=iiksO6Vd1QM00nVNyTWEUBcIR0se5tl/Hbcq1xo4TpDGSC/+IYX/f7UqJ2XtIm//3yNOphF/QMTgNCknXOF4fMVeOpGmhUZG02D8Fj2kuAzPTBSZWBHuz4gTyjpnjMUjBNoyhspWOyphn+dAR9FPiyx054jjmnSy8fQsYvZ+vgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709720964; c=relaxed/simple; bh=XdN3aG00u/QsuyGD6b2X8W2/qtDpU1h/uB9UBsmVuQc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xbkq6fbB8Zf5IpvlZCu+DqBQxKsIvU26AYdgwq/OeXp272AKkdph34EIr/ZKQP6jmPHXvLHwCHiW0jjRTqEKv4wwlPTFNTDkmALbv7zxaF7DpJDjkB+kmZG24YdOVblTk4TLXmhopAj0aRoknqEPWQBhokx7zO1d0vHAaGCMC5Q= 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=i7oIz5Ow; 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="i7oIz5Ow" 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=XdN3aG00u/QsuyGD6b2X8W2/qtDpU1h/uB9UBsmVuQc=; b=i7oIz5OwHcZcjmSc67Vln7VqltmBwUy9CDi9vzDDyeQKzAVZQpnHo4q5 Fel2EmdL2U5G4tLpuJQDXV73NqoUd+gfgXq9GwvEqTNbJYrTGBSGHh3DB 7JmM1Tf8cQsEnj0f1IoZyGbBDB3BkJLv+0NbGhZWO3BvvwNZ0ZRV7ifHy TX43EA1E0OrZEOav8olPtPSDv5qQyWS1uGwnFOV9Al7ltVjMoFYQEpN8U 3iB96TmrZtp3hBausy/DonrcQPhbO1I6XyOAHY3yWvwZK+8DKyqiG/1Fh 5a4boo8S4tQgRYLabbiLcudJSozgNX75vZJcOnWNLdFuQ4CwLs+ZBdmlk g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="151260035" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="151260035" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:14 +0900 Received: from yto-m2.gw.nic.fujitsu.com (yto-nat-yto-m2.gw.nic.fujitsu.com [192.168.83.65]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id B1867A345D; Wed, 6 Mar 2024 19:29:11 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id E2DABD5603; 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 66630401D3; 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: linux-cxl@vger.kernel.org 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: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13583837 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 A0BE06089F; 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=1709721030; cv=none; b=AY5Pzk5Vc9Yg1Qk7kGLt7h/Ii5A9ub9+XAy4K3ESNXqS/Y/bSIzQTi7Li+W7Aayj8EI2n30wWF8dsjieklQ1/eW9Zo8egbmU51GPlpHt7C7v4aLQBlAo1mjyUFR3Pp+dDhio6Dg8wJAGfGOgmmvFUXnFcx2lq/G/327YGTmuTEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721030; c=relaxed/simple; bh=Nq7SMqNBqa42A9Gw9it0V4iEBEk255GCXGK0EU8r0Nc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l1vVJHVNM5LNn/5XND9Y0gZbLMBdbifNrsN7ivC8YFxgR8sljqpeZtIsluCNROY6kR2rreXpwdr4O7wFiiQZmRpdIzcaviDQVvBTx3DCIafpyjVLXNWHFwFw4/MNRyJYlFmbAUSKNJRwylUAJzxe0ydnZ+B7igXzjKeOH0F5yEs= 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=X++/zVCQ; 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="X++/zVCQ" 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=Nq7SMqNBqa42A9Gw9it0V4iEBEk255GCXGK0EU8r0Nc=; b=X++/zVCQWbD3RwO4sV0R5jBoWm59aunLFlpz3wvSj7tUIUr1+QIcfxcw rUs51YTB9zQ4GsEFyK7E9vjQzv0Au7y/DHG9M/IIFiCx7tL2jEhH7HUXZ chdvdHYTFqV6pzIBWj11H5sAtkQ/5VztBHXXiORyfbehxUOTV2ZPhDbbo 0/vGrLBods4ZHkPHoHSMHz4JikXFb9z6EalEfAX2XZhSG7SsF8+yNrddq j3yL4Pimm6h3PUI9+zXPNs6wxWMi1QvXj5go7YYDTGpjexIN++Vqqfss8 zIrxwjNOuKfwNc4iyucLrPUjbkzprpGv7peddPfybMqsSH0zoBMZYiYI5 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="130699036" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="130699036" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:16 +0900 Received: from yto-m1.gw.nic.fujitsu.com (yto-nat-yto-m1.gw.nic.fujitsu.com [192.168.83.64]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id C7383E5EA4; 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-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 06543D21CB; 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 3D7B22030C7E0; 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: linux-cxl@vger.kernel.org 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: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13583835 Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (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 0A1D460884; Wed, 6 Mar 2024 10:30:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721027; cv=none; b=O1SuDqs3FGC1wblVnvsezjRJlYNX+W4XoKMhtFXaK9Z2yUI6HL1ehUE4NWkRBoaYqcT/oUjO66m+/pdPxMSsodnR++kXGDUkvRZ33ImzQ28Y4Dbx0lBnw0Pa+laW/EwRGHLH+3+bfCFE/EZCXXSJ7uq7ye7WE6bTH7nIk26oW6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721027; c=relaxed/simple; bh=cfFr9yDzIDYGuhO0ed+4EUdT/tYXSwMTNGM6ftOGOr0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KiHnaRAvmceLB8lQ7r6w0VqCPLYmLOlOa3Ew8zZLsen3wIXhsNtOAtbpQ444tWWfqUME/qzdkN0u2FyhgGgrYVggk8Vqgi5dFHOtCosJJERRfP+7wUCXf3tWc71MbB93IvyD77aXx4Z7xdTU4pBxt1j1aOBBe7hpjynFF4SFPeY= 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=iPICOJf1; arc=none smtp.client-ip=207.54.90.49 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="iPICOJf1" 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=cfFr9yDzIDYGuhO0ed+4EUdT/tYXSwMTNGM6ftOGOr0=; b=iPICOJf1fqp4Wfpct96UMCXzc8EOcm2ntWhK3uNMb5/CTf0R8orAGyCZ Wy5z3B7TvEVSha5jD1jPhwH75Ei6e72IGhUT/6H38+iIPBu7qNI+ur+ip aNWcrGigNH7elrIcEya5Gz3WvSR6h03a5xKFyC9mn+YQvvARQDEhjCG7W Dd8K9bHohlbl+hdP66IGYxAM6nkCm8Qh88SDnnkmk+b9LH7GbMp3BftLJ Q57/giUxjdIbe16sNsncpMyC07Zg18coRq2BX5Ji4c05Uzux7p7VcTEQ5 Q/dkqn9bjL2daeNRD0tVr1l9PXfDJb8Dh5BOv8lob4JxkDLVwyfK82pqN A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="151395784" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="151395784" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:16 +0900 Received: from yto-m1.gw.nic.fujitsu.com (yto-nat-yto-m1.gw.nic.fujitsu.com [192.168.83.64]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 56AE2C691A; 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-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 802A8575BF; 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 1676D2030C7E9; 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: linux-cxl@vger.kernel.org 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);