The patch titled Subject: memremap: Fix reference count for pgmap in devm_memremap_pages has been added to the -mm tree. Its filename is mm-defer-zone_device-page-initialization-to-the-point-where-we-init-pgmap-fix.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-defer-zone_device-page-initialization-to-the-point-where-we-init-pgmap-fix.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-defer-zone_device-page-initialization-to-the-point-where-we-init-pgmap-fix.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Alexander Duyck <alexander.h.duyck@xxxxxxxxxxxxxxx> Subject: memremap: Fix reference count for pgmap in devm_memremap_pages In the earlier patch "mm: defer ZONE_DEVICE page initialization to the point where we init pgmap" I had overlooked the reference count that was being held per page on the pgmap. As a result on running the ndctl test "create.sh" we would call into devm_memremap_pages_release and encounter the following percpu reference count error and hang: WARNING: CPU: 30 PID: 0 at lib/percpu-refcount.c:155 percpu_ref_switch_to_atomic_rcu+0xf3/0x120 This patch addresses that by performing an update for all of the device PFNs in a single call. In my testing this seems to resolve the issue while still allowing us to retain the improvements seen in memory initialization. Link: http://lkml.kernel.org/r/20181008233404.1909.37302.stgit@localhost.localdomain Signed-off-by: Alexander Duyck <alexander.h.duyck@xxxxxxxxxxxxxxx> Reported-by: Dan Williams <dan.j.williams@xxxxxxxxx> Tested-by: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/memremap.c | 1 + 1 file changed, 1 insertion(+) --- a/kernel/memremap.c~mm-defer-zone_device-page-initialization-to-the-point-where-we-init-pgmap-fix +++ a/kernel/memremap.c @@ -263,6 +263,7 @@ void *devm_memremap_pages(struct device memmap_init_zone_device(&NODE_DATA(nid)->node_zones[ZONE_DEVICE], align_start >> PAGE_SHIFT, align_size >> PAGE_SHIFT, pgmap); + percpu_ref_get_many(pgmap->ref, pfn_end(pgmap) - pfn_first(pgmap)); devm_add_action(dev, devm_memremap_pages_release, pgmap); _ Patches currently in -mm which might be from alexander.h.duyck@xxxxxxxxxxxxxxx are mm-provide-kernel-parameter-to-allow-disabling-page-init-poisoning.patch mm-create-non-atomic-version-of-setpagereserved-for-init-use.patch mm-defer-zone_device-page-initialization-to-the-point-where-we-init-pgmap.patch mm-defer-zone_device-page-initialization-to-the-point-where-we-init-pgmap-fix.patch mm-remove-config_no_bootmem-fix.patch