Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'libnvdimm-fixes-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm

Pull libnvdimm fixes from Dan Williams:
"A fix for an issue that could causes users to inadvertantly reserve
too much capacity when debugging the KMSAN and persistent memory
namespace, a lockdep fix, and a kernel-doc build warning:

- Resolve the conflict between KMSAN and NVDIMM with respect to
reserving pmem namespace / volume capacity for larger sizeof(struct
page)

- Fix a lockdep warning in the the NFIT code

- Fix a kernel-doc build warning"

* tag 'libnvdimm-fixes-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
nvdimm: Support sizeof(struct page) > MAX_STRUCT_PAGE_SIZE
ACPI: NFIT: fix a potential deadlock during NFIT teardown
dax: super.c: fix kernel-doc bad line warning

+49 -18
+1 -1
drivers/acpi/nfit/core.c
··· 3297 3297 3298 3298 mutex_lock(&acpi_desc->init_mutex); 3299 3299 set_bit(ARS_CANCEL, &acpi_desc->scrub_flags); 3300 - cancel_delayed_work_sync(&acpi_desc->dwork); 3301 3300 mutex_unlock(&acpi_desc->init_mutex); 3301 + cancel_delayed_work_sync(&acpi_desc->dwork); 3302 3302 3303 3303 /* 3304 3304 * Bounce the nvdimm bus lock to make sure any in-flight
+1 -1
drivers/dax/super.c
··· 475 475 /** 476 476 * dax_holder() - obtain the holder of a dax device 477 477 * @dax_dev: a dax_device instance 478 - 478 + * 479 479 * Return: the holder's data which represents the holder if registered, 480 480 * otherwize NULL. 481 481 */
+19
drivers/nvdimm/Kconfig
··· 102 102 depends on ENCRYPTED_KEYS 103 103 depends on (LIBNVDIMM=ENCRYPTED_KEYS) || LIBNVDIMM=m 104 104 105 + config NVDIMM_KMSAN 106 + bool 107 + depends on KMSAN 108 + help 109 + KMSAN, and other memory debug facilities, increase the size of 110 + 'struct page' to contain extra metadata. This collides with 111 + the NVDIMM capability to store a potentially 112 + larger-than-"System RAM" size 'struct page' array in a 113 + reservation of persistent memory rather than limited / 114 + precious DRAM. However, that reservation needs to persist for 115 + the life of the given NVDIMM namespace. If you are using KMSAN 116 + to debug an issue unrelated to NVDIMMs or DAX then say N to this 117 + option. Otherwise, say Y but understand that any namespaces 118 + (with the page array stored pmem) created with this build of 119 + the kernel will permanently reserve and strand excess 120 + capacity compared to the CONFIG_KMSAN=n case. 121 + 122 + Select N if unsure. 123 + 105 124 config NVDIMM_TEST_BUILD 106 125 tristate "Build the unit test core" 107 126 depends on m
+1 -1
drivers/nvdimm/nd.h
··· 652 652 struct nd_namespace_common *ndns); 653 653 #if IS_ENABLED(CONFIG_ND_CLAIM) 654 654 /* max struct page size independent of kernel config */ 655 - #define MAX_STRUCT_PAGE_SIZE 128 655 + #define MAX_STRUCT_PAGE_SIZE 64 656 656 int nvdimm_setup_pfn(struct nd_pfn *nd_pfn, struct dev_pagemap *pgmap); 657 657 #else 658 658 static inline int nvdimm_setup_pfn(struct nd_pfn *nd_pfn,
+27 -15
drivers/nvdimm/pfn_devs.c
··· 13 13 #include "pfn.h" 14 14 #include "nd.h" 15 15 16 + static const bool page_struct_override = IS_ENABLED(CONFIG_NVDIMM_KMSAN); 17 + 16 18 static void nd_pfn_release(struct device *dev) 17 19 { 18 20 struct nd_region *nd_region = to_nd_region(dev->parent); ··· 760 758 return -ENXIO; 761 759 } 762 760 763 - /* 764 - * Note, we use 64 here for the standard size of struct page, 765 - * debugging options may cause it to be larger in which case the 766 - * implementation will limit the pfns advertised through 767 - * ->direct_access() to those that are included in the memmap. 768 - */ 769 761 start = nsio->res.start; 770 762 size = resource_size(&nsio->res); 771 763 npfns = PHYS_PFN(size - SZ_8K); ··· 778 782 } 779 783 end_trunc = start + size - ALIGN_DOWN(start + size, align); 780 784 if (nd_pfn->mode == PFN_MODE_PMEM) { 785 + unsigned long page_map_size = MAX_STRUCT_PAGE_SIZE * npfns; 786 + 781 787 /* 782 788 * The altmap should be padded out to the block size used 783 789 * when populating the vmemmap. This *should* be equal to 784 790 * PMD_SIZE for most architectures. 785 791 * 786 - * Also make sure size of struct page is less than 128. We 787 - * want to make sure we use large enough size here so that 788 - * we don't have a dynamic reserve space depending on 789 - * struct page size. But we also want to make sure we notice 790 - * when we end up adding new elements to struct page. 792 + * Also make sure size of struct page is less than 793 + * MAX_STRUCT_PAGE_SIZE. The goal here is compatibility in the 794 + * face of production kernel configurations that reduce the 795 + * 'struct page' size below MAX_STRUCT_PAGE_SIZE. For debug 796 + * kernel configurations that increase the 'struct page' size 797 + * above MAX_STRUCT_PAGE_SIZE, the page_struct_override allows 798 + * for continuing with the capacity that will be wasted when 799 + * reverting to a production kernel configuration. Otherwise, 800 + * those configurations are blocked by default. 791 801 */ 792 - BUILD_BUG_ON(sizeof(struct page) > MAX_STRUCT_PAGE_SIZE); 793 - offset = ALIGN(start + SZ_8K + MAX_STRUCT_PAGE_SIZE * npfns, align) 794 - - start; 802 + if (sizeof(struct page) > MAX_STRUCT_PAGE_SIZE) { 803 + if (page_struct_override) 804 + page_map_size = sizeof(struct page) * npfns; 805 + else { 806 + dev_err(&nd_pfn->dev, 807 + "Memory debug options prevent using pmem for the page map\n"); 808 + return -EINVAL; 809 + } 810 + } 811 + offset = ALIGN(start + SZ_8K + page_map_size, align) - start; 795 812 } else if (nd_pfn->mode == PFN_MODE_RAM) 796 813 offset = ALIGN(start + SZ_8K, align) - start; 797 814 else ··· 827 818 pfn_sb->version_minor = cpu_to_le16(4); 828 819 pfn_sb->end_trunc = cpu_to_le32(end_trunc); 829 820 pfn_sb->align = cpu_to_le32(nd_pfn->align); 830 - pfn_sb->page_struct_size = cpu_to_le16(MAX_STRUCT_PAGE_SIZE); 821 + if (sizeof(struct page) > MAX_STRUCT_PAGE_SIZE && page_struct_override) 822 + pfn_sb->page_struct_size = cpu_to_le16(sizeof(struct page)); 823 + else 824 + pfn_sb->page_struct_size = cpu_to_le16(MAX_STRUCT_PAGE_SIZE); 831 825 pfn_sb->page_size = cpu_to_le32(PAGE_SIZE); 832 826 checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); 833 827 pfn_sb->checksum = cpu_to_le64(checksum);