]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/nvdimm/pfn_devs.c
libnvdimm/pfn_dev: Add a build check to make sure we notice when struct page size change
[linux.git] / drivers / nvdimm / pfn_devs.c
index 3e7b11cf1aaec67f69ed4faf7d3a7b3c48215d5e..cd120feb9213bddab8a08ca0f91af958ae5cb6ee 100644 (file)
@@ -701,8 +701,16 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn)
                 * The altmap should be padded out to the block size used
                 * when populating the vmemmap. This *should* be equal to
                 * PMD_SIZE for most architectures.
+                *
+                * Also make sure size of struct page is less than 64. We
+                * want to make sure we use large enough size here so that
+                * we don't have a dynamic reserve space depending on
+                * struct page size. But we also want to make sure we notice
+                * when we end up adding new elements to struct page.
                 */
-               offset = ALIGN(start + SZ_8K + 64 * npfns, align) - start;
+               BUILD_BUG_ON(sizeof(struct page) > MAX_STRUCT_PAGE_SIZE);
+               offset = ALIGN(start + SZ_8K + MAX_STRUCT_PAGE_SIZE * npfns, align)
+                       - start;
        } else if (nd_pfn->mode == PFN_MODE_RAM)
                offset = ALIGN(start + SZ_8K, align) - start;
        else