From patchwork Fri Jun 2 10:26:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13265060 Received: from esa8.hc1455-7.c3s2.iphmx.com (esa8.hc1455-7.c3s2.iphmx.com [139.138.61.253]) (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 0B37217FFE for ; Fri, 2 Jun 2023 10:27:16 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="107288425" X-IronPort-AV: E=Sophos;i="6.00,212,1681138800"; d="scan'208";a="107288425" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 19:27:08 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 08433DDC65 for ; Fri, 2 Jun 2023 19:27:06 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 35E4DD9A89 for ; Fri, 2 Jun 2023 19:27:05 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.234.230]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 1DB03E4AAF; Fri, 2 Jun 2023 19:27:04 +0900 (JST) From: Li Zhijian To: kexec@lists.infradead.org, nvdimm@lists.linux.dev Cc: linux-kernel@vger.kernel.org, dan.j.williams@intel.com, bhe@redhat.com, ruansy.fnst@fujitsu.com, y-goto@fujitsu.com, yangx.jy@fujitsu.com, Li Zhijian , Vishal Verma , Dave Jiang , Ira Weiny Subject: [RFC PATCH v3 1/3] nvdimm: set force_raw=1 in kdump kernel Date: Fri, 2 Jun 2023 18:26:50 +0800 Message-Id: <20230602102656.131654-2-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230602102656.131654-1-lizhijian@fujitsu.com> References: <20230602102656.131654-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-27666.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-27666.006 X-TMASE-Result: 10-0.974000-10.000000 X-TMASE-MatchedRID: t1Iw0ML99//7w6uw5pqYnoOlbll4OMtk9LMB0hXFSeg6Zx3YUNQTG+Wh NKYuM7eN4QRvjxz49tHS7j6TEIEt1D3TQfUpAv1sPkILbTHNp5vYUDvAr2Y/17fYIuZsOQ0sOXB 2cqV0mCIre4xpX839SFAz81vtOOYiZ4F2TwmYmEDum6Nvy6t3NlK6+0HOVoSoWAuSz3ewb22AI+ pLfk3sByL637QCIVpi8vc3EUpCmrV9Y/vlKk76U9splnBzc8xMTFQnI+epPIaRo95rkBSGU6PFj JEFr+olwXCBO/GKkVqOhzOa6g8KrW2CLRXivi3wNhkKY/nNBRst5qYpMkBetMsgyaJj+IZ28rnl FWxtjwA8cpbtw5mTmssX0GOwKpO0i+7bNO++4Qw50ytg9FCbQRXBt/mUREyAj/ZFF9Wfm7hNy7p pG0IjcFQqk0j7vLVUewMSBDreIdk= 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 we choose the 3rd one because the kdump application in this RFC relies on some /sys interfaces exported by libnvdimm and nd_pmem etc. CC: Dan Williams CC: Vishal Verma CC: Dave Jiang CC: Ira Weiny CC: nvdimm@lists.linux.dev Signed-off-by: Li Zhijian --- V3: new patch --- 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 c60ec0b373c5..2e59be8b9c78 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "nd-core.h" #include "pmem.h" #include "pfn.h" @@ -1504,6 +1505,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); From patchwork Fri Jun 2 10:26:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13265062 Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68E8D18AE5 for ; Fri, 2 Jun 2023 10:27:18 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="97964625" X-IronPort-AV: E=Sophos;i="6.00,212,1681138800"; d="scan'208";a="97964625" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 19:27:08 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 98E4CC3F94 for ; Fri, 2 Jun 2023 19:27:06 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id E5BF4C4A15 for ; Fri, 2 Jun 2023 19:27:05 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.234.230]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id DD90630C425; Fri, 2 Jun 2023 19:27:04 +0900 (JST) From: Li Zhijian To: kexec@lists.infradead.org, nvdimm@lists.linux.dev Cc: linux-kernel@vger.kernel.org, dan.j.williams@intel.com, bhe@redhat.com, ruansy.fnst@fujitsu.com, y-goto@fujitsu.com, yangx.jy@fujitsu.com, Li Zhijian , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org Subject: [RFC PATCH v3 2/3] x86/crash: Add pmem region into PT_LOADs of vmcore Date: Fri, 2 Jun 2023 18:26:51 +0800 Message-Id: <20230602102656.131654-3-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230602102656.131654-1-lizhijian@fujitsu.com> References: <20230602102656.131654-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-27666.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-27666.006 X-TMASE-Result: 10--8.329300-10.000000 X-TMASE-MatchedRID: SzbEz7SZt2uKi1hWqQY8Ws7ggHewVGq2wwrHF5pwze+fHrjLA9DhZkop D+RCCRBkWW2Dmwvfm8fHs1P4pGN3CkKry8ky4RfFrMZ+BqQt2NqDnmblFLAswsC5DTEMxpeQfiq 1gj2xET/kizndBEr04aS6UDs/n0a68yMI2JjGZ9a628cXbnOhTxgff28UuvITQmw1cPfvj6kgfJ 3S34h6EV+3LSA0WzRX64sVlliWKx8fE8yM4pjsDwtuKBGekqUpI/NGWt0UYPBTsAAS6F7IXbxSS Tr43YbG2CTYFQRbaau5CD61Mvm0FlqwxgxViRpo X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Only the region described by PT_LOADs of /proc/vmcore are dumpable/readble by dumping applications. Previously, on x86/x86_64 only system ram resources will be injected into PT_LOADs. So in order to make the entire pmem resource is dumpable/readable, we need to add pmem region into the PT_LOADs of /proc/vmcore. Here we introduce a new API walk_pmem_res() to sort out the pmem region. Note that, unlike other walk_xxx_res() API in resource.c, we walk through pmem resources without IORESOUCE_BUSY flag. This is kexec_file_load() specific, for kexec_load(), kexec-tools will have a similar change. CC: Thomas Gleixner CC: Ingo Molnar CC: Borislav Petkov CC: Dave Hansen CC: "H. Peter Anvin" CC: Baoquan He CC: x86@kernel.org Signed-off-by: Li Zhijian --- arch/x86/kernel/crash.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index cdd92ab43cda..97763ea804c6 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -168,6 +168,17 @@ static int get_nr_ram_ranges_callback(struct resource *res, void *arg) return 0; } +/* + * This function calls the @func callback against all memory ranges, which + * are ranges marked as IORESOURCE_MEM and IORES_DESC_PERSISTENT_MEMORY. + */ +static int walk_pmem_res(u64 start, u64 end, void *arg, + int (*func)(struct resource *, void *)) +{ + return walk_iomem_res_desc(IORES_DESC_PERSISTENT_MEMORY, IORESOURCE_MEM, + start, end, arg, func); +} + /* Gather all the required information to prepare elf headers for ram regions */ static struct crash_mem *fill_up_crash_elf_data(void) { @@ -178,6 +189,7 @@ static struct crash_mem *fill_up_crash_elf_data(void) if (!nr_ranges) return NULL; + walk_pmem_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. @@ -243,6 +255,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr, ret = walk_system_ram_res(0, -1, cmem, prepare_elf64_ram_headers_callback); if (ret) goto out; + walk_pmem_res(0, -1, cmem, prepare_elf64_ram_headers_callback); /* Exclude unwanted mem ranges */ ret = elf_header_exclude_ranges(cmem); From patchwork Fri Jun 2 10:26:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13265063 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) (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 701D318AEF for ; Fri, 2 Jun 2023 10:27:21 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="107447917" X-IronPort-AV: E=Sophos;i="6.00,212,1681138800"; d="scan'208";a="107447917" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 19:27:12 +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 6877DCA1E8 for ; Fri, 2 Jun 2023 19:27:10 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 91E0FD9A89 for ; Fri, 2 Jun 2023 19:27:09 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.234.230]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 89B3840FE2; Fri, 2 Jun 2023 19:27:08 +0900 (JST) From: Li Zhijian To: kexec@lists.infradead.org, nvdimm@lists.linux.dev Cc: linux-kernel@vger.kernel.org, dan.j.williams@intel.com, bhe@redhat.com, ruansy.fnst@fujitsu.com, y-goto@fujitsu.com, yangx.jy@fujitsu.com, Li Zhijian , Vivek Goyal , Dave Young Subject: [RFC PATCH makedumpfile v3 3/3] makedumpfile: get metadata boundaries from pmem's infoblock Date: Fri, 2 Jun 2023 18:26:56 +0800 Message-Id: <20230602102656.131654-8-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230602102656.131654-1-lizhijian@fujitsu.com> References: <20230602102656.131654-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-27666.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-27666.006 X-TMASE-Result: 10--22.341900-10.000000 X-TMASE-MatchedRID: 44XoofGiUa/SFChHF48gQTiEPRj9j9rvUh4weWPqOWS638ZUY6gSd1YI HeJwbhUqNmVYIPY+Gy2YlVLttZCaEDBF7stuNMMxEVuC0eNRYvLxKR2kbb+f1wYkj8pwyAod12k t5HuVFgCbKneFtGQ4N1LlTv2kQ2/LP06ke90qDvPum6Nvy6t3NgmWvXEqQTm5wLkNMQzGl5B+Kr WCPbERP2XM/1LvxbWDZva/ER92lB2cfX6Ug1yFMM36paW7ZnFoGB9/bxS68hPk6Qbi+9i6Dz/zI kvUoSsdD7X3CqobQahpM4uQJ+eFBvdZ3f2rISMmfOaYwP8dcX6BiLDUCsch2+uLH9BII+4qlfC3 WuSrCNRwmg9/GN+fyAQTZYEbCLsYrJKo/rFyHQGVOwZbcOalSxZSD+Gbjz3IWH7Bxw4ADCPmKXL lUHkJC+EjtnMuJXJurgv6vPEWDp7YsZWA4GRU5h1qGr6sYOf/wJjn8yqLU6I1Y73PdzvXZKKJ8y eXnfHAZZ1LvVb67BW23YOnZxHtRsOrmarpjDAkngIgpj8eDcAZ1CdBJOsoY8RB0bsfrpPI6T/LT DsmJmg= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 some code are copied from ndctl. This change requires libndctl which provides interface to walk through all existing namespaces. This also requires the namespace entered the force_raw mode(the kernel will ensure that). The resource interface provides the start of namespace, and device's superblock provides the usedata's offset of namespace. According to this information, we can caculate the scope of metadata. A new dump level(-d 63) is introduced to skip the metadata as well in this patch. CC: Baoquan He CC: Vivek Goyal CC: Dave Young CC: kexec@lists.infradead.org Signed-off-by: Li Zhijian --- Makefile | 2 +- makedumpfile.c | 196 +++++++++++++++++++++++++++++++++++++++++++++++-- makedumpfile.h | 3 +- 3 files changed, 192 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 0608035e913f..fd0a792c5647 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c arch/mips64.c arch/loongarch64.c OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) -LIBS = -ldw -lbz2 -ldl -lelf -lz +LIBS = -ldw -lbz2 -ldl -lelf -lz -lndctl ifneq ($(LINKTYPE), dynamic) LIBS := -static $(LIBS) -llzma endif diff --git a/makedumpfile.c b/makedumpfile.c index f304f752b0ec..b68d261f3d1e 100644 --- a/makedumpfile.c +++ b/makedumpfile.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include struct symbol_table symbol_table; struct size_table size_table; @@ -100,6 +102,7 @@ mdf_pfn_t pfn_user; mdf_pfn_t pfn_free; mdf_pfn_t pfn_hwpoison; mdf_pfn_t pfn_offline; +mdf_pfn_t pfn_pmem_metadata; mdf_pfn_t pfn_pmem_userdata; mdf_pfn_t pfn_elf_excluded; @@ -6374,6 +6377,173 @@ exclude_range(mdf_pfn_t *counter, mdf_pfn_t pfn, mdf_pfn_t endpfn, } } +struct pmem_metadata_node { + unsigned long long start; + unsigned long long end; + struct pmem_metadata_node *next; +} pmem_metadata_head; + +struct pmem_metadata_node *pmem_head = NULL; + +static void pmem_add_next(unsigned long long start, unsigned long long dataoff) +{ + struct pmem_metadata_node *tail = pmem_head, *node; + + node = calloc(1, sizeof(*node)); + if (!node) + return; + + node->start = start >> info->page_shift; + node->end = (start + dataoff) >> info->page_shift; + node->next = NULL; + + if (!pmem_head) { + pmem_head = node; + return; + } + while (tail->next) + tail = tail->next; + tail->next = node; +} + +static void cleanup_pmem_metadata(void) +{ + struct pmem_metadata_node *head = pmem_head; + while (head) { + struct pmem_metadata_node *next = head->next; + free(head); + head = next; + } +} + +static int is_pmem_metadata_range(unsigned long long start, unsigned long long end) +{ + struct pmem_metadata_node *head = pmem_head; + while (head) { + if (head->start <= start && head->end > end) + return TRUE; + head = head->next; + } + + return FALSE; +} + +static void dump_pmem_range(void) +{ + int i = 0; + struct pmem_metadata_node *node= pmem_head; + + fprintf(stderr, "dump_pmem_range start......\n\n\n"); + while (node) { + fprintf(stderr, "namespace[%d]: metadata[%llx, %llx]\n", i++, node->start, node->end); + node = node->next; + } + fprintf(stderr, "dump_pmem_range end........\n\n\n"); +} + +#define INFOBLOCK_SZ (8192) +#define SZ_4K (4096) +#define PFN_SIG_LEN 16 + +typedef uint64_t u64; +typedef int64_t s64; +typedef uint32_t u32; +typedef int32_t s32; +typedef uint16_t u16; +typedef int16_t s16; +typedef uint8_t u8; +typedef int8_t s8; + +typedef int64_t le64; +typedef int32_t le32; +typedef int16_t le16; + +struct pfn_sb { + u8 signature[PFN_SIG_LEN]; + u8 uuid[16]; + u8 parent_uuid[16]; + le32 flags; + le16 version_major; + le16 version_minor; + le64 dataoff; /* relative to namespace_base + start_pad */ + le64 npfns; + le32 mode; + /* minor-version-1 additions for section alignment */ + le32 start_pad; + le32 end_trunc; + /* minor-version-2 record the base alignment of the mapping */ + le32 align; + /* minor-version-3 guarantee the padding and flags are zero */ + /* minor-version-4 record the page size and struct page size */ + le32 page_size; + le16 page_struct_size; + u8 padding[3994]; + le64 checksum; +}; + +static int nd_read_infoblock_dataoff(struct ndctl_namespace *ndns) +{ + int fd, rc; + char path[50]; + char buf[INFOBLOCK_SZ + 1]; + struct pfn_sb *pfn_sb = (struct pfn_sb *)(buf + SZ_4K); + + sprintf(path, "/dev/%s", ndctl_namespace_get_block_device(ndns)); + + fd = open(path, O_RDONLY|O_EXCL); + if (fd < 0) + return -1; + + rc = read(fd, buf, INFOBLOCK_SZ); + if (rc < INFOBLOCK_SZ) { + return -1; + } + + return pfn_sb->dataoff; +} + +int inspect_pmem_namespace(void) +{ + struct ndctl_ctx *ctx; + struct ndctl_bus *bus; + int rc = -1; + + fprintf(stderr, "\n\ninspect_pmem_namespace!!\n\n"); + rc = ndctl_new(&ctx); + if (rc) + return -1; + + ndctl_bus_foreach(ctx, bus) { + struct ndctl_region *region; + + ndctl_region_foreach(bus, region) { + struct ndctl_namespace *ndns; + + ndctl_namespace_foreach(region, ndns) { + enum ndctl_namespace_mode mode; + long long start, end_metadata; + + mode = ndctl_namespace_get_mode(ndns); + /* kdump kernel should set force_raw, mode become *safe* */ + if (mode == NDCTL_NS_MODE_SAFE) { + fprintf(stderr, "Only raw can be dumpable\n"); + continue; + } + + start = ndctl_namespace_get_resource(ndns); + end_metadata = nd_read_infoblock_dataoff(ndns); + + /* metadata really starts from 2M alignment */ + if (start != ULLONG_MAX && end_metadata > 2 * 1024 * 1024) // 2M + pmem_add_next(start, end_metadata); + } + } + } + + ndctl_unref(ctx); + return 0; +} + int __exclude_unnecessary_pages(unsigned long mem_map, mdf_pfn_t pfn_start, mdf_pfn_t pfn_end, struct cycle *cycle) @@ -6447,9 +6617,17 @@ __exclude_unnecessary_pages(unsigned long mem_map, is_pmem = is_pmem_pt_load_range(pfn << PAGESHIFT(), (pfn + 1) << PAGESHIFT()); if (is_pmem) { - pfn_pmem_userdata++; - clear_bit_on_2nd_bitmap_for_kernel(pfn, cycle); - continue; + if (is_pmem_metadata_range(pfn, pfn + 1)) { + if (info->dump_level & DL_EXCLUDE_PMEM_META) { + pfn_pmem_metadata++; + clear_bit_on_2nd_bitmap_for_kernel(pfn, cycle); + continue; + } + } else { + pfn_pmem_userdata++; + clear_bit_on_2nd_bitmap_for_kernel(pfn, cycle); + continue; + } } index_pg = pfn % PGMM_CACHED; @@ -8130,7 +8308,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page) * Reset counter for debug message. */ if (info->flag_cyclic) { - pfn_zero = pfn_cache = pfn_cache_private = 0; + pfn_zero = pfn_cache = pfn_cache_private = pfn_pmem_metadata = 0; pfn_user = pfn_free = pfn_hwpoison = pfn_offline = pfn_pmem_userdata = 0; pfn_memhole = info->max_mapnr; } @@ -9468,7 +9646,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d /* * Reset counter for debug message. */ - pfn_zero = pfn_cache = pfn_cache_private = 0; + pfn_zero = pfn_cache = pfn_cache_private = pfn_pmem_metadata = 0; pfn_user = pfn_free = pfn_hwpoison = pfn_offline = pfn_pmem_userdata = 0; pfn_memhole = info->max_mapnr; @@ -10418,7 +10596,7 @@ print_report(void) pfn_original = info->max_mapnr - pfn_memhole; pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private + pfn_pmem_userdata - + pfn_user + pfn_free + pfn_hwpoison + pfn_offline; + + pfn_user + pfn_free + pfn_hwpoison + pfn_offline + pfn_pmem_metadata; REPORT_MSG("\n"); REPORT_MSG("Original pages : 0x%016llx\n", pfn_original); @@ -10434,6 +10612,7 @@ print_report(void) REPORT_MSG(" Free pages : 0x%016llx\n", pfn_free); REPORT_MSG(" Hwpoison pages : 0x%016llx\n", pfn_hwpoison); REPORT_MSG(" Offline pages : 0x%016llx\n", pfn_offline); + REPORT_MSG(" pmem metadata pages : 0x%016llx\n", pfn_pmem_metadata); REPORT_MSG(" pmem userdata pages : 0x%016llx\n", pfn_pmem_userdata); REPORT_MSG(" Remaining pages : 0x%016llx\n", pfn_original - pfn_excluded); @@ -10475,7 +10654,7 @@ print_mem_usage(void) pfn_original = info->max_mapnr - pfn_memhole; pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private + pfn_pmem_userdata - + pfn_user + pfn_free + pfn_hwpoison + pfn_offline; + + pfn_user + pfn_free + pfn_hwpoison + pfn_offline + pfn_pmem_metadata; shrinking = (pfn_original - pfn_excluded) * 100; shrinking = shrinking / pfn_original; total_size = info->page_size * pfn_original; @@ -10768,6 +10947,8 @@ create_dumpfile(void) } } + inspect_pmem_namespace(); + dump_pmem_range(); print_vtop(); num_retry = 0; @@ -12441,6 +12622,7 @@ out: } } free_elf_info(); + cleanup_pmem_metadata(); return retcd; } diff --git a/makedumpfile.h b/makedumpfile.h index 85e5a4932983..ecb2fb4d7a4c 100644 --- a/makedumpfile.h +++ b/makedumpfile.h @@ -206,7 +206,7 @@ test_bit(int nr, unsigned long addr) * Dump Level */ #define MIN_DUMP_LEVEL (0) -#define MAX_DUMP_LEVEL (31) +#define MAX_DUMP_LEVEL (63) #define NUM_ARRAY_DUMP_LEVEL (MAX_DUMP_LEVEL + 1) /* enough to allocate all the dump_level */ #define DL_EXCLUDE_ZERO (0x001) /* Exclude Pages filled with Zeros */ @@ -216,6 +216,7 @@ test_bit(int nr, unsigned long addr) with Private Pages */ #define DL_EXCLUDE_USER_DATA (0x008) /* Exclude UserProcessData Pages */ #define DL_EXCLUDE_FREE (0x010) /* Exclude Free Pages */ +#define DL_EXCLUDE_PMEM_META (0x020) /* Exclude pmem metadata Pages */ /*