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: 13583814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99AD1C54E41 for ; Wed, 6 Mar 2024 10:29:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CBDC6B006E; Wed, 6 Mar 2024 05:29:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 17C366B0071; Wed, 6 Mar 2024 05:29:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F12396B007E; Wed, 6 Mar 2024 05:29:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D63DB6B006E for ; Wed, 6 Mar 2024 05:29:15 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7E6611C0E32 for ; Wed, 6 Mar 2024 10:29:15 +0000 (UTC) X-FDA: 81866241870.09.C228919 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by imf01.hostedemail.com (Postfix) with ESMTP id 0C48940005 for ; Wed, 6 Mar 2024 10:29:12 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=P6wvBAAJ; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.223 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709720953; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UVszu2iJVL2KRjF7BNNEY0JqjDiAR4U4cF+zAd3qOPw=; b=Q5Oz6oBZhkDIlaBykWg2M3wmn8njr3GWxJSRmp2NoqZyTPODQdNZAZOkSg260/To99+Y7J S2wwR26xnVvJTh84HwKLkwVfbnHFYFs5HLguBVJoOMYZpRi0ogqudcC2BN5PY9C7gTjEPM nQt7qVV0+wWxUMt57DL0rLtOR3xbub8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=P6wvBAAJ; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.223 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709720953; a=rsa-sha256; cv=none; b=guYCZcJezueOS70CGb/BY+e2a6X4YIAGE6QbY5+uwlBPY13/XWA06qRZZGBc0Gsp6/tPfx ++59C7uI5KYdBqtZAj5P9UmoRkDTu/hyqeaBSZJesvcEcMyENeQxtzKED790ziiobBj1yR wfb4i1xKVlgS64IDk9FwlSRbH/4bNpQ= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720953; x=1741256953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZoN1+liG2Aek8I+8vh1JTxN3rQPUF7ESoET6QRxJG2I=; b=P6wvBAAJ0xOawVOsKoCNMSiJ7M8YDru9mzKGE3q/HbcEgMlJKI5zJhD5 0TqcgRFNhJom7VSa8RBCOdDG/8Oc6XLAOiqts8br1l+dA2DP0NS30Xh0N fPPsjj4ynmF68iQAvCTS+inZdtiJNUYssa+Q2+5qwzcNnEwF2RDPSAGPi PXyvzazz4FNTsL097NSnmYDkDUX/gSRBlarW2IanQkIEMBMpBt12d6TpO 2oMBMA6bnt2/RlmSWhPoJsIZFvYmdYqcRcNJljMdCO325tB9kI1bdwj82 q1KcYOVImLY3xLSIFjJzFkVMe8bxUw4pzDblTvH+J69UyIU9vrFnJ9emt g==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="139869802" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="139869802" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:10 +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 72DB0E8CE9 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 9CC40D626D 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 25B2C2030C7E0 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> 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 X-Rspamd-Queue-Id: 0C48940005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: nx4mudt7d6k5m7uy554sbcg5sa85me4b X-HE-Tag: 1709720952-118639 X-HE-Meta: U2FsdGVkX1/NVUP3HwAcjsPp/qEWU46jT7jTWmjLCoNu/oPuqzk2FFMBTkLERYIjtpgmCQE6nzqlRVaq396R3U6KydIcgrT8IPzY3VmMV6iy6DYjsxD8MZDkmK9TTmjYtXzzi8rgfkEUadN5VppCYzSNq2zStVYfJdkJUYiHlG1CbO+Jx3Rfe5mZh3EEsG/o2nDuj1DiDUzAxWODQv22yin/8bzPHJ5WuTxMC3U5L4aqrZ/ZJNMD5fvnhI+zizLLlumGobaWjr9yEhcFJZthLEBkX6U2KqshYiYA5pjwH0ihsl0u11zkvdc5xwnc4zJGFrXytJ5aCFKUyUDzHF2SFaqGz8bAbDXqD967LC9iIcS73+fDhQF1iK/mEOJixKytIgUWbyGJ3JNvPIXYKBAspddfzTXli/XpsCDUJkEIyvc8grHXRyscQpTFbPDRKnrrvVuqivpoHE9yEul2RK0fWpAHWfCCBh2l3wJ9MvRq6bLYkMW4xtVEXhkQ7U3L4+YuFX4HZMX8cWnZWUTdr2VI1UqIIQXwoNsxkc/8jzKLBYyLeVjWtW4Ynot4cgZAHmE+HbQ823nuMRsFmVfLXI5mtbCmmEFgXshgHXg8xDoxAq/YQokwi5YehksIS/2F12yf/zA2ZODJ/3d0uYT4xJ1E3ytzU+oGKrae4unj9QAy+FXGgcflcmBc9/RAHhOkC1kzph0TSAea234fqhuGIW9YnRTHgk+JIn2TPw2dvhuBUxwlLWplf/f2yna4OcV/lizn2rDGq9OpIFgc/yzjTS4/CGVll9LHFtsl0kvBIqgeQdyET0HnHz0+r0rM2pJ5lznEOJk5MmCv2HbmVrVz9IGwXu9g3Z9J2SwFGRIy57PReX+1GJQsBzYkEU74xeywIMke+rY8P5eZG/6cXtffE0/qp/XTPjiRhU2N6fafV784AzaR2mMV8H0ldiJD3XxeQyEmHmM+8gRxaHGh6WRWDQk E1w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13583818 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51AFBC54E5C for ; Wed, 6 Mar 2024 10:29:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 083EC6B0089; Wed, 6 Mar 2024 05:29:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DD8926B008A; Wed, 6 Mar 2024 05:29:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE0786B008C; Wed, 6 Mar 2024 05:29:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A31546B0089 for ; Wed, 6 Mar 2024 05:29:20 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 742A6140BF5 for ; Wed, 6 Mar 2024 10:29:20 +0000 (UTC) X-FDA: 81866242080.17.94C20A8 Received: from esa5.hc1455-7.c3s2.iphmx.com (esa5.hc1455-7.c3s2.iphmx.com [68.232.139.130]) by imf10.hostedemail.com (Postfix) with ESMTP id 2AAF9C000D for ; Wed, 6 Mar 2024 10:29:17 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=gQ6gfUro; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf10.hostedemail.com: domain of lizhijian@fujitsu.com designates 68.232.139.130 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709720958; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wg423God+C8SkCwIZt0kbQSq6lgqTTeY957x3wueu/w=; b=QWMQYg6CyvksEp0dRFWv1HdEB39SoZfvsY7IbketfMqAbNjsOLZl7aeKf037LA7wy1UCNV +ZVTFr8E0+/HUY3ptcMOdWQ/x3Mv1FJ8VL2fbEryR6LIEfC5vWLln4wF38IzILbSHFQ/RJ 9IhBA7OPKiZhCjrUiNUFKpNTeittzsI= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=gQ6gfUro; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf10.hostedemail.com: domain of lizhijian@fujitsu.com designates 68.232.139.130 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709720958; a=rsa-sha256; cv=none; b=yekwSnOMJ4vVxxVqG5my5aw9MuadinqbZ9VvQmaLtZRLUKCly24+RkI8ZlRXodRgA4//pV rOElV8UtGLobc6MpP7D0DXMSubVYKvHJdF/kB6oTLedyR8BNLfv4jzU+ACiAmAuyy7UBJn IvZW/IykLFk8Kvyk8hx4HjAMKNBXoo8= 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=qPTXg1j60dmCKgrUxhmFd4z9be0Rjp54MJE3FLxdEQM=; b=gQ6gfUroeJ4Bo4C+L3qvHWQXtnTq1ISL+C+jpR6MMLp9VB1aUfiIHbPG y61aRAe1y4KBDITQU/pPJDNlLQtO6VRHMPuECAqeGbS6z2Vu12gzx2z4q uy603uqVdnV8o/VJRDqwxV4s+JPJvD/H1VBM0tKqRRev8/tiSYdsYbJvE 8s215aICDBCTUm0lp8J7INbP2jUmwzS8eb6jo1mnGZ9BgFFH4jDlMSbgJ 5udFoMGHyl8ztGJgWbpqq/88EQLIr0/uWjHyADZW3/WpRHCEYiIFVsTu2 RxToThyIWdr7RM9lTk294bf2sUp2B+slhxVPEvfK4kOE/+CVdCtaSafa7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="150857726" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="150857726" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa5.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-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 63186DD92F 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-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 92DC6FDA0B 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 041652030C7E9 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 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> 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 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2AAF9C000D X-Stat-Signature: kyrtttca1mz1ej64d5r79w51synopnu7 X-HE-Tag: 1709720957-290680 X-HE-Meta: U2FsdGVkX182zM2noL2noWqCEx5Cee4q/zrkkh17kBvzHRksN1ZsoF63Vo/xS73xBdpPO9cb/PsYfXa24LJpxH51FFzUt1v2BxB6XWx1dCh077P1bhueWTNNnhp6Yg6Cxcsq9CSz+yB4IWSKaZXp0vGLt3ohw2N8TyAJ8BdkecL5m3QQHcKInfidIoXyx3Z0OqIAAbf9YN+ZvUROcpQJxiv6QaE4yrmI8ugXPO76AF7y6dXIJAB8KviIVLTf/QLHC0FOmTMYUOXMS3D47WxM5C6X87zOrU+7eNgwev70l2LXdAs1cWsPTxbGw0S44Iiht0euJW/R0O1sMQ8Al7jS/b+Bgufeg9TpaxiN8W/D+saHeILVRBYEQrCzwbKcZnNpyBwAiUAppJWXvqowVkKN6s20/NevSCONJnR3S+ITZOkHQVbjun6uQ89HdlmHvK84FamRkbP+NWdfpd8W9TwngzNflY8dYYcm8Xq66tk2sgKaKSDmenFRYmiwXlk9hFGEnZXMPng8mrGezWPRyk/9dSNmdYcsgb1MxFIWx1JqWp+LIGGqGziV0TLwsdksy5KuamyICX/UCQDe4Tgz3INF/5D+HcLR+U+7bDkGpd5HjIFkmo7FCYUSOeCyVSuSBvOhJzYnLdOc7VJb6nE/8e53mmtLXHzJ5XpXx3Iai1zVyR1Ou42oK7DQ0TdzBPy8nIlLaEXd7AXM7ltTpGOEjKekcLXoeeWt1UEl7HL+NGoio1ABxNe3U53pf55r+T9xrfXtLV+1xlGNcFegEWPTGEloglsgDfM5HXReQAdZ++wi6r42dwnrAFmzQnPBTb+eUCc1renx+a10i0ROFJk5Ku/Z0tx2b42xPfusWNH9xpiOZwvp1gSEuW8Llx6AzXk48PsrWLCHh2GpRgYnTCD9DsIFCjHxac2bdIwVskQ4IBVUET1My802PPINAj2JyBQyVUQ2wSBpt1jF+eWa8EaSDW5 JEh7cdfx ZY71YSEp8M4XwvxtzK5voJVFzuztMpd1sVJZv X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13583817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2D16C5475B for ; Wed, 6 Mar 2024 10:29:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48D2A6B0088; Wed, 6 Mar 2024 05:29:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C80C6B0089; Wed, 6 Mar 2024 05:29:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CCA66B008A; Wed, 6 Mar 2024 05:29:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 04B586B0088 for ; Wed, 6 Mar 2024 05:29:20 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D239E1402DD for ; Wed, 6 Mar 2024 10:29:19 +0000 (UTC) X-FDA: 81866242038.15.BB63AAA Received: from esa1.hc1455-7.c3s2.iphmx.com (esa1.hc1455-7.c3s2.iphmx.com [207.54.90.47]) by imf10.hostedemail.com (Postfix) with ESMTP id 8857CC0007 for ; Wed, 6 Mar 2024 10:29:17 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=RIqetOi6; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf10.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.47 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709720957; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=N4fPy9O32HWXOLWELOHx74LJrJKVRpVaZoQKDGw+uY0=; b=c4gp0f3DMalb9GpPPVjLqEW9eoZvOWvmicyeoyFcf0NpVTSlPxvQXjKStjwwc8i2/ilBYI MF6ic+oa8GH1toRN2OgQpnSSTLrDrmjqk4jWUq1iCFSmyPXa01Wit5P18fAuSX+bchA35X u4MrfYsZlUa7LRu/DykWJhQGFl4weAY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=RIqetOi6; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf10.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.47 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709720957; a=rsa-sha256; cv=none; b=IwJfNkN8i3PsbSVZZqqhKHG6T90l93xJD/nDQNICvolM0tRPqiryqb29K+Qgcm+abmGfUN miadUTCnKvORyW8OkH3ZJxj4Nfs5VyL2Zsw9byNPBKvPTMRBnfU6jCL6PbS5iC2T6qo460 q1jY2my0S/7CGGIfaLiaGW127gFTR70= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720957; x=1741256957; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8m938ej88oP8CU4LRmFGqeZ2eI8zznrXHFjHuzUAi80=; b=RIqetOi6rtPZ1SoTQflNwiNwVgUtbt9AYbs1rCE/RTAFuQp18ouWajdA KbSdUqqYEM/Ak+w/ARjaPcpmb/GSlCKCXB5Elbomz2PLt2+4vq45SAgju zm408zVvuB9mPuiW9omlzH2n/MRVutxEF4zxGsSgxdE/mz7BxUFazbEul TXD3fA8/g3CLOpk5LuZmejs/1kaFdNzqY0kx/BVEpRkuZ8bPnnHJA2rmU V/cLMk9tBPt4Ahe4UAn5w9rzjYSwOWIMWU1tdrATkPnlm/CLHLL09Hb22 aLvDtWtTUmz0K0SXA4UYrbzEQ3ia2KAWzCwGbSGOACuzA7lkxzLfPCWuv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="151260037" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="151260037" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) 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-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 1D752C68AC for ; 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-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 52C5AD2BA6 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-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id C4B93202CB587 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> 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 X-Rspamd-Queue-Id: 8857CC0007 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 1fmq3aozfi5b6mgp9z65wi1e5emo8f9b X-HE-Tag: 1709720957-565614 X-HE-Meta: U2FsdGVkX19QzCwntlbzKfXcCwwa3nr6/QjAB4ztFtGluHSOPkq5laWMV3Muja9tYTft9GbIL0VAhNtMOKZi2QAvDh6rr1nOQcfznF/MH4VVu+UntxuaJ3dlaIWA3hL0f9qIWmGZosq5nyc4zgiGtzWFNLfGJms6hwDi6JSvmqRbBT8st2yCwtg+wrgoPj42OuxjR2U8LdJtMuYd94Dhf/mciMZ7bME9/wbwGnRBefIWbDaamIq/AiEKg88OaNZ1z6ruo8a8f6j8ZpxBSOIZ8WEZaTX5Up8k2LX2vwe5lNusEktux4d2D/76eicTqenJAwquikHPmZbSQe+tY1FHKdpx5TG25QbcsUExrrPQo3iw32TITDvOa7h8eaZLrRk2n4xhAVRVpDNcRxsFzIScnqUBL2Otg2M9X/TphmZqQ30Ne8v5a/BPnud6vLCU2u/GeX8rJwoLwF38MHAWi8Am+9/PvVppMbWI5ilPkzJXC22lcIUPKHw171SyZ/++Z8iXtX+uAWX1EdjaK5D2EJ3O1fComnUKlz9bWNIO/NGeUc7TGXMkZ1x/lUNRtcSIXn9/XK6oBbVlYEgbvkhl9GpM1+MkCcAM6fkjFsORzI6bCZWdSsT+HDRLFz9qH1rv/AXz0RSPfKvBR/bkJpxeRG9dow/paTfNgRYLDJ6121JKpdHAIfPgJXbVZ+44bZoQRh2z9SRSpQL7VCVISYomRmb3hJH7fB7UCjt5lU2esdSWa7/fThF/PZmHgR5Uq9MI/eSB63SZBCV/1xcF223dxcTueWjOZna6CirY5N8cUM7cwaYbYqJ+wRYdEahzOrkl2o82PVfdWng6xxxdcyLyUT9URXzHfU09+AfAwd/G2QLFt2o2NqFukZqt1Q78v1eoy9ubnJpPcqpvpXrRs5avA7fNemaLe6Gj9fNAuybtN3c1cnEh3Ei6lSrwBV4utVLlAGaxXWLxd4DsfKI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13583819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDDD6C54E5D for ; Wed, 6 Mar 2024 10:29:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57C7D6B008A; Wed, 6 Mar 2024 05:29:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5016D6B008C; Wed, 6 Mar 2024 05:29:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 272346B0095; Wed, 6 Mar 2024 05:29:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E7A5D6B008C for ; Wed, 6 Mar 2024 05:29:20 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C687DC04F1 for ; Wed, 6 Mar 2024 10:29:20 +0000 (UTC) X-FDA: 81866242080.14.33733B2 Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) by imf14.hostedemail.com (Postfix) with ESMTP id 5F0AF10000B for ; Wed, 6 Mar 2024 10:29:18 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=r9nH0COm; spf=pass (imf14.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.137 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com; dmarc=pass (policy=quarantine) header.from=fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709720958; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=y5BbRNkr/KdSy9UgwxOtt4RHBFENlawQJP+9F0EibOE=; b=51YDC05U1mDcxE83NAJKoH9Y11xC9kCFFGdke5AKyirF/rYSpsvEy5X5e6nsduIxSsERoz 5DIXVRQ25b2z3+hEmAbExqrsIhaU4muXL8O77r0RxLj/VYmD6ctD2Ulh4C5pafg++gh7qy Cn5yEolhDzIIw+br3/eIKDkx6dyy/eg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=r9nH0COm; spf=pass (imf14.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.137 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com; dmarc=pass (policy=quarantine) header.from=fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709720958; a=rsa-sha256; cv=none; b=k2bCLtq/5uqwX/JL1HEM6JTkdDMRuUFl8ek4Hnifbh822QjE3iPSH4u0h6W4Np9GSuKssS yP0R9sx9uMaTF6loIkXQsBYxCBIptKw7runN1gCx0VJn+14sYndbb8RKQviV32abCIzJU8 dO0wBTnhg7g1ddR/vDC4o3fPx/xhWO0= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720959; x=1741256959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZZY/OmJnWGlv4sXJ9ctR7zLIBkL6jlFxWOynKDfrnCI=; b=r9nH0COmNp3bZYlgnErxZCO+esBdafH5wuDmO/mbCPXPhTOWN6rB+5Mw AlGJZ/TdnG2ZFMmqzkLWUwXuYDWUPD8lG88I73/4QMTVhNg7X8OSlT5dz vUDwNDphei6wx9OZ2trSyutU2pL+GgSkHL+0lskTLt3LiAnOkr2ucMWjb JM40C6/dXTUV+dTODajl2cbmaoeFCKGbsQQ/fhwyzNUJVZ0f5Q9pr6R30 1thyQPrIvd7YmDVGaMRbWP3J2SKYjLGae7u8cUWxtlsT7pLR+SrKmU7Tu CK8MkWpSTtblsxBJoMNFY8Ml8w9Fb/L7x8KQ1Ww4cl0N1EyHix0jbx+0j w==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="130783557" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="130783557" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:16 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 296E9D4801 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-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 1F13DD5D17 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 96F09202CB587 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> 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 X-Rspamd-Queue-Id: 5F0AF10000B X-Rspam-User: X-Stat-Signature: j9iyn8mtzix51q68pbk8ch4ohzui1u8g X-Rspamd-Server: rspam01 X-HE-Tag: 1709720958-779410 X-HE-Meta: U2FsdGVkX1+Sl1Qzpm5inVpbr6PacZKru8T40BrK/BE4kQWoFoYpcv2yqAl3Hp8J2NBnxuJYO25X47GArAm4gvbud5ImIvKPKn2ke9cRaQpx3gyHX2xCjhdHOFm9ID65dqmTqYpj3TRVtaOvv5mZ8CLHjyeUzDeuLJyME4l4HNCdoWGCZjjQtjPLcIvdq9PJuIAPc/NF4om0SjvF2CzMCoUqFoHtFczUkCskLauxRaYTO4ONSP9ZPY/RzfXfVMI9+qtRNV45HeUdind+Cx1lBjFWxZ34tLga6LEGTUMAiBE1wZZjSoDYPfDcZYiHXregh5mZRQP2p4IcTVfQRSBuMNoxERSLA894tg8yO+xWbTngggIDnYiNvKwxyVPFX3Dk0rtFfyZuzGdGfIHfuz6aHjhnGskC2RHOhJ7pGsT4iYmQ+ohhEUO4Q0qUUWUJLvOLjJ80stc0xfMlqy22f5xWYbFvfJ3kd8/pP2/0+XzY+LooFUgEfV8KvysrqT+PJQ4Z0Yv70S0NzBp7zwXFp7ivz5wIaGzgPlE/TzYWRW4/KPEVJ9bZNFeFFhoJ3bLZ2qy+tsnvWY15sRy436zaGQUk2QCXsU01S+VuT4ubgtqHEXeuKAegNtbxLfKxnLvUOclvkeeMEcsbs/UrwOoJTnF7HtQX67VFwRRZohbDuA+A/MkEoD4WNYReNvN32i4x7+Ht0d/EVsgpGw7Ild0jhjFDr/jsbbv65/vYXjyRFaG4nQxXZMGviTqNK34qnm1MoFnL+HgMNkTQzfjhyhVRRCNBxBF5+W5cIpepXwWo/fU/3gEhA4YOeWJthASeFIgprK+ivMr1bHJ+Ou++jnB1z0CVRWseHgU6ly2wWvNZFH17O4Lj7NYAHJ4edmXH3HEF+PZKxLTrLXNRL3Lr0jQKiH5N2j4DqStgTZT8QDrsHm3n0RMkoxvyE8FQZqPX+YEEiB1uuCJWbtVZC88+YzQ6ehU fVdHrdoZ pOpIIk+oWmGHtnf+7r3mrc4ioZd2R2RE/umLyCw7TCtKSVJyFjkNG95kXlhHvmMIfOM/q/y3Iyuu7MO5wsJtRs+zEZikZF2cCQx84HVmWQVgqKLwFS63cIZusY8k9cPL/8La7/N9uXcPMUWemMn3SfsobgXSJlOQwM9yUsTD3BeG6Bak5C0bTfzmIy5XVAGYZ5yNNx1tk6CtgdeDVbvBz8NJpKHmgcSfV4Xs0sWuCz7AWsZ3a7M7X4/J1ZyXFIx7Jjs2PCjGCM2c9iUSt+rER3z+uqo2kDDziYS5GdKJZCEWgFzzMcqDA8bqmx+6JgXOJPCOJIPT3c4WWFa5N68ZMPucMAixfdr9TpOoV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13583820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64077C5475B for ; Wed, 6 Mar 2024 10:29:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A82046B008C; Wed, 6 Mar 2024 05:29:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0E036B0092; Wed, 6 Mar 2024 05:29:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BFA86B0096; Wed, 6 Mar 2024 05:29:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 599086B0092 for ; Wed, 6 Mar 2024 05:29:21 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3B41D1C0EF6 for ; Wed, 6 Mar 2024 10:29:21 +0000 (UTC) X-FDA: 81866242122.12.F75CC60 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by imf01.hostedemail.com (Postfix) with ESMTP id 00E4740002 for ; Wed, 6 Mar 2024 10:29:18 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=O7huPLry; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.223 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709720959; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kf+dqckNIPa+VIzI7/vfMs0S0JsrUqEwDfy3Alr0qO0=; b=MpySzzvmCMCrmHK31saMDnOmuBQsFVcRjT+8jng7tJ//X/OxScqtB2vB7LAv3NDuikgOzx zjFEvOALxnKJ4Ps9zk4coeYIQqbzKhFT/fbD9RkhIR2auwFk6sMgZHvkId47WqsnU5udjN Gjro3WLzGK901wFx26FEEs+5/dLQM+4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=O7huPLry; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.223 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709720959; a=rsa-sha256; cv=none; b=SlNoik3eaYI77ABSDM6IjhxU0gICowfAGzt/CYY8zAXmRa7POd2vXCPlRaqSKU27j0xupE femSk6CQSzQJCRs40w5SPKxUKRD3npQAMlWokAsW41wvoAhTD/q1tjijWTUlB19XcZUO5C TTr9Nq8QMmoa715BVCLtj1sTGddzi5U= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720959; x=1741256959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XdN3aG00u/QsuyGD6b2X8W2/qtDpU1h/uB9UBsmVuQc=; b=O7huPLryOmxMjE+QAIPqs23PchrhoijR7lzzy0rKqG8Ig23YkNp8iD4b Nj5c7ZVvDiemyyXlB9WIMZosCeLcXc2hE//t2w289EdbbH1V7VWkG9Z0u Me6qnZdLt3qkHJHnOqWGb1zLAO8V2SuM+WoFHFk6BfemV1jzoUDHUtZEE WGc6/fN/ogvP74iA1X7EWi4zmtXwqKO5OSyoA4xu3JZd+89412tbI+v9r pG2+iF09Y3dlKbkvgVBUYLUxsrWnU0dWrE+u7Gkjcky+vjzeSi4B7LQiE icNgZyNlxSfYmHp/14LkxEZYPRYnylHZBd8pY/0vJdyEUW2apBbBjSzL+ w==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="139869814" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="139869814" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 19:29:16 +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 A4079B62EE 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 yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id E98D2E6181 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 6969220097BE1 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> 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 X-Rspamd-Queue-Id: 00E4740002 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 6pmfjb6ytzngoomcjn7at9u6gnc71map X-HE-Tag: 1709720958-852751 X-HE-Meta: U2FsdGVkX19MAQuYwyPvefdIz9QzHg/0Q8Nf9asMi3XXGUql6s/klaVnROcHaX5YAgG7Hkz1JmGNpKsplf+Dalio1G8aZKetNb23fdOQ4amOJkOb9l0+4WukKDJWM/temNcp2LwQs3Yz0KQWs2E7Pm3ZCSxvqz/bOMnQSg9j78bRpIyqRon8uUoqbALQ8zn4FVjSdF2wnOigXfqQBWzcrdwCe6+wr9N//dH80eGzY/ZNBs6vfQLvjbBLj4UpvN5JMik9+3RDMNAHpXOzxovGjAiw39KTVlW7xPVcBxqDtP6LNWykM9C045orfnr7Ejh0VY/yh4KirDxMPCm8iZ4n7p4jDTrQQE6AolOUFxdPnpNlEWFVO7TdsEFbyapj/1Vxv92wI5WLhyvG/EAsZOO5zhlDBAxDWrm7GOy7OZSsZJuH0TSDWfjcRv8PZbc3+ZMIZ38Gef4PpHizK+UY9xzCce+6s0AyINjStTcumlgGK+yGLuiGmwnl/daDcuSwSNuN6blVn71F4Yil/cnw/BkpnsWnNPb71Tpqe/0N42NgLoKJfv1cVtRfIhZWyjgKMqJ7q816ibR7zEK0JTVUSlXKQ7j7JDwg0Kef8QoukUzq3biZpM578qS0mznI9XUwJBIvHh7rHG0Lw7aMgrajX8PFdDc/FaQivYI5lJB1FsfRYzoTBp+WT2JveQuPqWxrnxObVLTyv/XXMaLCM51fh5Gxzqhl1SlP+kUaKHQStF72RiqN5LsvwiMNOe6Cbxjg2ogBhCXoB9r8tRzUlROoPgIabisaXLMWZ1ei/vguGNM/56Opxwp4Z2K53gSN3DnS69rrCG0o6QsQ89xmy2Gthmk/oEPLouw35SLYYk6w5LQo3V6bd28EXoH41LNcENBI7kYvF9+ZyOe9CHppkBdrq4hId8P8gvFg7fDo61B6c35gUxro1Dolj1NxRHg47KYV6vc7HBch0Cj9o0/GFpBDG38 iKo2LMYq 9rIb1nc0DRHlFOE4sIUPEKUBzpVjXNx5jh157 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13583816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03B4AC54E49 for ; Wed, 6 Mar 2024 10:29:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F88D6B0081; Wed, 6 Mar 2024 05:29:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85DFB6B0088; Wed, 6 Mar 2024 05:29:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AD1E6B0089; Wed, 6 Mar 2024 05:29:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 54D656B0081 for ; Wed, 6 Mar 2024 05:29:19 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D1AAA120862 for ; Wed, 6 Mar 2024 10:29:18 +0000 (UTC) X-FDA: 81866241996.27.66D9623 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by imf01.hostedemail.com (Postfix) with ESMTP id 8161B4000F for ; Wed, 6 Mar 2024 10:29:16 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=uNCHmnhd; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.223 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709720956; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bmWUdbMXm6xto0M0EQsTATXArvbNpLtVOFoS8B10h8Y=; b=MfVoHV+fS5CMZDEX6AHlXuLk6FNXtZxlEmf5g6AuKPKPs0KSgpuKWVasSy9Ta4I/RzdLtQ zA+yKskNoVATXUxx5Mf1G8cVk4bdvTYX7Tnqyc22dEy76Aloi7blt+x/Q1xLW4DwxfIgFr Z89bULJ8fiz/p/uUZ+7I+SBLr/koilg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=uNCHmnhd; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf01.hostedemail.com: domain of lizhijian@fujitsu.com designates 139.138.36.223 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709720956; a=rsa-sha256; cv=none; b=0FjKYM6l5tfi7PfrYpTZYN2m9ZeVAJp6ygVHet2nTYG7ZIQUBuJl8ai3gNkC8wlVHLCXt1 3iSNitCKamtQHytTG5v69tIDJi0Sd33GOtHjgSqBqFh31IrZg+rij8x8YRKRQYYVcefz5k XwvZIyvLJ5nByKbDwzKpb5RCpQQA0kg= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720956; x=1741256956; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nq7SMqNBqa42A9Gw9it0V4iEBEk255GCXGK0EU8r0Nc=; b=uNCHmnhdUAbDeCX6uXUHBxJ9jl5/EvEooVcAJpjiSMdKY4SK82W1D4fy OoGLD9OKYhFeVb5yhERQ/Y9mH3KkE5IBbGfG5CFnYmmGlH+6Ys5MmsaaE +gATHIpXVMmjrdAKO5raxHdtlcg/0JHOe1f2HmE20Hhfdt0YLYGe3te2q Dke5OLWnjtoR2sngbEJsfDdxQItEIvBa4NA2xOXN5REPYpTQVXSwW2sRe WQ/AMSPyDdVWdp1XAc0zXHiY3sE2k2Y5RVEH456WQ/11LhXfLTe/GVOVd 1rMWWRuQwwKFCt5igWT//NBmfb6YMNzU93mq98OjwpXYh8Oc9bjOQhb78 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="139869811" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="139869811" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa9.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-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id C723BC6909 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 047B2D5EBC 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 39F0B2008FF9A 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> 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 X-Rspamd-Queue-Id: 8161B4000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: gphc9etofyt9n5wjtw73br16qprb7fhq X-HE-Tag: 1709720956-119671 X-HE-Meta: U2FsdGVkX1/dKznsp56pSnMooxwD7FqCjBPgBbERtztUz5KuCmHYQCx5w5t2UqNrkQs1Lhff+JPKUooyUPL3l9LU2qrdgHwCohV7YTbtGeEZvYxO0aMd/TU2Vv/sco1FWavKpPefN18D3eT9srcCfh4rjrDHBDlJqfpfOycI04gPfAYxi7NuQ9QIk4hSVx47KqPDnoxmKLSYWyzIrfviij25mgpRkkiBimoyL/BS43LgaZN0ZBd9e5lq8JEatMSA5Ixo56TBAUb0Uj2vnqRRE78xzZyoKw4/yWmbltgxzhLr+uHX+i65VQW7m3HIsS99aJt1A8tSmqeFIMjo4N8CJIqFB4acVl0BhBrLW+7KAj3mLtmEAa6GoHTyiTYu965IAHU+QMMPe8Y+9npLf3OaSxoCS1/GSI5NE8rNdmZy+W9lQeJys3CwFumjt+dNcvzetDK2L8ANy/POHVge/S+7zT4bSD5wmZJIGNkw3uXjOR8FGKXDqkOm61fItejDOIcAwVvEPrJzLFVpq4U2ElHtmT94ssXWnO8RNH0qoZH4sjcDFOLMx74pfS9aWYxVPDMcrUsYqcTQA4+2d6yONeGuBGrPugoalLX/EUTDDiutaHJuQUmV/qgPmWiGkOnkzAUO7kZAquRQmcxWG39GEt3pwD9/d2DJTAeeijrs8rIYUILRZwfHDf6xD8G8qWjJg/rR8PEuvfAnklTfEgxLSSAmzmf0Mot1mtae8WAtUvv8OKzzKiip+LT7k4UULKFepjd/Ke+WsUy7oAmH+eAW/7h8tAYdsabQBE+Jnitdgpa7YUt158sPkisXux4ZFofDXpw7a+NTYm2eYEqyBsTC8VWSCICoWspAc1rm5OjuWicGN6qrijW8dxra9Rx3DKdM3TMtgHZXIAjOBKy5WDEtFD93ctXU+lJ1RqeXuUlNWQF+az7JzouS32LELeMsu7Uf9g1zUxscl8PWOQmKpGtImg7 48CPHb4m svIW+H4E7txgtDUvPzFJa5G5yr/6MfqY0HFRO X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: 13583821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00F72C5475B for ; Wed, 6 Mar 2024 10:29:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FDEE6B0092; Wed, 6 Mar 2024 05:29:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 835EB6B0095; Wed, 6 Mar 2024 05:29:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 612336B0096; Wed, 6 Mar 2024 05:29:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 488466B0092 for ; Wed, 6 Mar 2024 05:29:22 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2648B160BB6 for ; Wed, 6 Mar 2024 10:29:22 +0000 (UTC) X-FDA: 81866242164.08.1B44877 Received: from esa1.hc1455-7.c3s2.iphmx.com (esa1.hc1455-7.c3s2.iphmx.com [207.54.90.47]) by imf24.hostedemail.com (Postfix) with ESMTP id B6AE4180004 for ; Wed, 6 Mar 2024 10:29:19 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=SDZkQN7J; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf24.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.47 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709720960; a=rsa-sha256; cv=none; b=OgvxJeMPm/R6aZ0GBHw3sEURjdTK8SRoo8JN3G8uVeeJWKo0qn/CvJaIeuPK7Uiv5Td2OK VOxGSe9DRJlIyuBnahnpHaISQib/ml1Ab/MuEyYTHRjKCnvm5UXQSj8iR4FaefJw5wcIHs b987zrN/xcyEdR+Hu9hPvuVFCwyqhJw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=fujitsu.com header.s=fj2 header.b=SDZkQN7J; dmarc=pass (policy=quarantine) header.from=fujitsu.com; spf=pass (imf24.hostedemail.com: domain of lizhijian@fujitsu.com designates 207.54.90.47 as permitted sender) smtp.mailfrom=lizhijian@fujitsu.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709720960; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2PX/7oEshLYBEnPu1DpfJYRcBCZOOjFvxfe1NNP9G6w=; b=aNIJYfQvtyb+JjNnGajzNiIcq2Ie7pjeAIdeqdZ14Kj+yN/jQc6cEiKwe5kgz5gNLNddc/ w7T6pEfNE1q0mSQi8a73UKHbiqqPpdDuNMdDK7Ec0Fkvtyx/zX8LvVAk2a96rIgzmwamwW BLuzkg/j2oQL19Jm55YncJ0Rd3ug3IM= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1709720960; x=1741256960; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cfFr9yDzIDYGuhO0ed+4EUdT/tYXSwMTNGM6ftOGOr0=; b=SDZkQN7JlwIl7HCyzxxUYCgto0LlRQDOGXHqgsYFhQdZ7ZnhSt/bhnpL bmd1b3HesMav69VQWxSacovGLN7X8NRejNgjciFffAh1GDWjwq8QlRu0U qDyWsozf3qnT4N63iM2Vk6OWPsyxcpY6xLo9H3PIYkfZ2+Iz9iODHEcfN dpfPJwpM47MirKwCS8Ya+Dpf4XIf5O/FVpZeU4NMWeilNbuWdzaFIxOcN 7zOBeHVBr/ttN4kF9j3TAhhTotpjzAl4tFlE9cvSsqMXIAC9y4JIczJdW WGH0EJgDrqmdSSCRug+a6yQl89fLlE0T+b5pQHsGK8uB8espNLdTG1Zl+ w==; X-IronPort-AV: E=McAfee;i="6600,9927,11004"; a="151260041" X-IronPort-AV: E=Sophos;i="6.06,208,1705330800"; d="scan'208";a="151260041" 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:17 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 4294D12E239 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 oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 794A6D5628 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 1543D2030C7E0 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> 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 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B6AE4180004 X-Stat-Signature: a8dubg4ismob87trwf3op3cmhcnb8or6 X-HE-Tag: 1709720959-896476 X-HE-Meta: U2FsdGVkX1/3+l0qL/s5qHNSAGqwmUV8q/vr0TK7Pty0UNYYtuuRecvVwHpAIa4cSmZwthDo4te+drtCdqXjiSoPX0JyIAbIZ5jD4e3gU7x5UnkJ84kXiY/rl5oTnAMDADy5OKgy8uSKoONaMSBSj/z6cWA4zuqHbe5CWHgesxmD1r/WPzbFoVnUY7FuZYpiuuxLa7MZlu2GuM05D+5nCK2wBaNvLzQA2pNrzkYwi+QrYbmhXjDSC4EElkWla0AMW7PwvC7UFVFeY67qnYCvuyr1Pbcn6MJs5xy865B1F0DLEhbzxHPtBWSE5jprqC6+6UJALJyrTQE+LUgTJHMSN6aAuXe60g9Y5IX0uaWp4OS+aTv469xuozEupDk6TJ1yzCI3yV6pE2YhB9/DIOWA8Ga1l8HzEtix1gAGbh695SuaWYR9sC+iK8YrtUXr1aJcq0pVaUHOFbgeWTfot9Xr3C6kNvQkR5/GLbzRKz+9Cv2E5jPl8sQqH2O3op4COyuQKECsIOE1gw38KxnT3E0llA7eefSgjjR5ucthni/5W0YbWgEKZhHt397mlpKtXuJwWOjv9ng3UFIWoJqJ1dyE7VIBNPukt88Jp+D5osNzj2OpMKzkm0XZpRS5MPps+dLoaiO4NvkFixc/SmN3jLQEYmOlIhnUlxghOhGZDc4iWMYzAOsrgqBzbF4hpqoU6CJgWwVrxMotiCqaCbvWOrkMVcZ8II92V5fweZAlSW7keyVPBHKJ39zjj/AoUjbsN9i0VPgXIwsV61Efv7b/j4PTXoyB3VrELrVHkwMfJIdPQnXyc/1HpgU3Uukf3UxDRisVzItKW2Yo2boPPHh3REotzvmg/fNATOstCRkgTFJNZ6gzU2TQ138yADkEOdgCBD+1p/vnxdq3z87h/WEJRJ2Oh01RKwSg1tlSxiRQCPy/VmStgSZUIGU6bFWwRW3Sx17sdNggeYQh0McJ8mRRL8Y 9hXr7UtE h58Il/K1w3wkJkWxt8TNpdR0pMb8N6Dx2+eyAR/SSst0ibYbtWYabGx0AHmQPCi0aX5Wym6haEvwsyYmpX3j2y4U6jH9y3FdVOiSxi9zfR6OI7QEyjTcwS7uy4SeljGCloWgnIVNSlxehp1DwP8liy1TW0JNQW1LJ/1gKXqAts+JhpaFQ1EY04gm2WO3vDQX/7juAim/0zJ92Y9fGRgxPmK/fxAHsmQeRVWb6iJOP4VaalPwGOikQUDDqIQ84d8ENBvF1PrxRn3F5kL+WUhrF1e3+iye3OfVqvIwnlCV1/u1PowdgQZYCT9FKLA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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);