From: Dan Williams <dan.j.williams@intel.com> To: akpm@linux-foundation.org Cc: "Rafael J. Wysocki" <rafael@kernel.org>, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Jérôme Glisse" <jglisse@redhat.com>, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, "Bjorn Helgaas" <bhelgaas@google.com>, "Christoph Hellwig" <hch@lst.de> Subject: [PATCH v2 0/6] mm/devm_memremap_pages: Fix page release race Date: Tue, 07 May 2019 16:55:59 -0700 [thread overview] Message-ID: <155727335978.292046.12068191395005445711.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) Changes since v1 [1]: - Fix a NULL-pointer deref crash in pci_p2pdma_release() (Logan) - Refresh the p2pdma patch headers to match the format of other p2pdma patches (Bjorn) - Collect Ira's reviewed-by [1]: https://lore.kernel.org/lkml/155387324370.2443841.574715745262628837.stgit@dwillia2-desk3.amr.corp.intel.com/ --- Logan audited the devm_memremap_pages() shutdown path and noticed that it was possible to proceed to arch_remove_memory() before all potential page references have been reaped. Introduce a new ->cleanup() callback to do the work of waiting for any straggling page references and then perform the percpu_ref_exit() in devm_memremap_pages_release() context. For p2pdma this involves some deeper reworks to reference count resources on a per-instance basis rather than a per pci-device basis. A modified genalloc api is introduced to convey a driver-private pointer through gen_pool_{alloc,free}() interfaces. Also, a devm_memunmap_pages() api is introduced since p2pdma does not auto-release resources on a setup failure. The dax and pmem changes pass the nvdimm unit tests, and the p2pdma changes should now pass testing with the pci_p2pdma_release() fix. Jérôme, how does this look for HMM? In general, I think these patches / fixes are suitable for v5.2-rc1 or v5.2-rc2, and since they touch kernel/memremap.c, and other various pieces of the core, they should go through the -mm tree. These patches merge cleanly with the current state of -next, pass the nvdimm unit tests, and are exposed to the 0day robot with no issues reported (https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git/log/?h=libnvdimm-pending). --- Dan Williams (6): drivers/base/devres: Introduce devm_release_action() mm/devm_memremap_pages: Introduce devm_memunmap_pages PCI/P2PDMA: Fix the gen_pool_add_virt() failure path lib/genalloc: Introduce chunk owners PCI/P2PDMA: Track pgmap references per resource, not globally mm/devm_memremap_pages: Fix final page put race drivers/base/devres.c | 24 +++++++- drivers/dax/device.c | 13 +--- drivers/nvdimm/pmem.c | 17 ++++- drivers/pci/p2pdma.c | 115 +++++++++++++++++++++++-------------- include/linux/device.h | 1 include/linux/genalloc.h | 55 ++++++++++++++++-- include/linux/memremap.h | 8 +++ kernel/memremap.c | 23 ++++++- lib/genalloc.c | 51 ++++++++-------- mm/hmm.c | 14 +---- tools/testing/nvdimm/test/iomap.c | 2 + 11 files changed, 217 insertions(+), 106 deletions(-) _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com> To: akpm@linux-foundation.org Cc: "Ira Weiny" <ira.weiny@intel.com>, "Bjorn Helgaas" <bhelgaas@google.com>, "Logan Gunthorpe" <logang@deltatee.com>, "Christoph Hellwig" <hch@lst.de>, "Jérôme Glisse" <jglisse@redhat.com>, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, "Rafael J. Wysocki" <rafael@kernel.org>, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org Subject: [PATCH v2 0/6] mm/devm_memremap_pages: Fix page release race Date: Tue, 07 May 2019 16:55:59 -0700 [thread overview] Message-ID: <155727335978.292046.12068191395005445711.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) Changes since v1 [1]: - Fix a NULL-pointer deref crash in pci_p2pdma_release() (Logan) - Refresh the p2pdma patch headers to match the format of other p2pdma patches (Bjorn) - Collect Ira's reviewed-by [1]: https://lore.kernel.org/lkml/155387324370.2443841.574715745262628837.stgit@dwillia2-desk3.amr.corp.intel.com/ --- Logan audited the devm_memremap_pages() shutdown path and noticed that it was possible to proceed to arch_remove_memory() before all potential page references have been reaped. Introduce a new ->cleanup() callback to do the work of waiting for any straggling page references and then perform the percpu_ref_exit() in devm_memremap_pages_release() context. For p2pdma this involves some deeper reworks to reference count resources on a per-instance basis rather than a per pci-device basis. A modified genalloc api is introduced to convey a driver-private pointer through gen_pool_{alloc,free}() interfaces. Also, a devm_memunmap_pages() api is introduced since p2pdma does not auto-release resources on a setup failure. The dax and pmem changes pass the nvdimm unit tests, and the p2pdma changes should now pass testing with the pci_p2pdma_release() fix. Jérôme, how does this look for HMM? In general, I think these patches / fixes are suitable for v5.2-rc1 or v5.2-rc2, and since they touch kernel/memremap.c, and other various pieces of the core, they should go through the -mm tree. These patches merge cleanly with the current state of -next, pass the nvdimm unit tests, and are exposed to the 0day robot with no issues reported (https://git.kernel.org/pub/scm/linux/kernel/git/djbw/nvdimm.git/log/?h=libnvdimm-pending). --- Dan Williams (6): drivers/base/devres: Introduce devm_release_action() mm/devm_memremap_pages: Introduce devm_memunmap_pages PCI/P2PDMA: Fix the gen_pool_add_virt() failure path lib/genalloc: Introduce chunk owners PCI/P2PDMA: Track pgmap references per resource, not globally mm/devm_memremap_pages: Fix final page put race drivers/base/devres.c | 24 +++++++- drivers/dax/device.c | 13 +--- drivers/nvdimm/pmem.c | 17 ++++- drivers/pci/p2pdma.c | 115 +++++++++++++++++++++++-------------- include/linux/device.h | 1 include/linux/genalloc.h | 55 ++++++++++++++++-- include/linux/memremap.h | 8 +++ kernel/memremap.c | 23 ++++++- lib/genalloc.c | 51 ++++++++-------- mm/hmm.c | 14 +---- tools/testing/nvdimm/test/iomap.c | 2 + 11 files changed, 217 insertions(+), 106 deletions(-)
next reply other threads:[~2019-05-08 0:09 UTC|newest] Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-07 23:55 Dan Williams [this message] 2019-05-07 23:55 ` [PATCH v2 0/6] mm/devm_memremap_pages: Fix page release race Dan Williams 2019-05-07 23:56 ` [PATCH v2 1/6] drivers/base/devres: Introduce devm_release_action() Dan Williams 2019-05-07 23:56 ` Dan Williams 2019-05-14 19:12 ` Greg Kroah-Hartman 2019-05-14 19:12 ` Greg Kroah-Hartman 2019-05-14 19:24 ` Dan Williams 2019-05-14 19:24 ` Dan Williams 2019-05-14 19:24 ` Dan Williams 2019-05-07 23:56 ` [PATCH v2 2/6] mm/devm_memremap_pages: Introduce devm_memunmap_pages Dan Williams 2019-05-07 23:56 ` Dan Williams 2019-05-07 23:56 ` [PATCH v2 3/6] PCI/P2PDMA: Fix the gen_pool_add_virt() failure path Dan Williams 2019-05-07 23:56 ` Dan Williams 2019-05-07 23:56 ` [PATCH v2 4/6] lib/genalloc: Introduce chunk owners Dan Williams 2019-05-07 23:56 ` Dan Williams 2019-05-07 23:56 ` [PATCH v2 5/6] PCI/P2PDMA: Track pgmap references per resource, not globally Dan Williams 2019-05-07 23:56 ` Dan Williams 2019-05-07 23:56 ` [PATCH v2 6/6] mm/devm_memremap_pages: Fix final page put race Dan Williams 2019-05-07 23:56 ` Dan Williams 2019-05-08 17:05 ` [PATCH v2 0/6] mm/devm_memremap_pages: Fix page release race Logan Gunthorpe 2019-05-08 17:05 ` Logan Gunthorpe 2019-05-13 19:22 ` Logan Gunthorpe 2019-05-13 19:22 ` Logan Gunthorpe 2019-05-14 18:51 ` Jane Chu 2019-05-14 18:51 ` Jane Chu 2019-05-14 19:04 ` Dan Williams 2019-05-14 19:04 ` Dan Williams 2019-05-14 21:18 ` Jane Chu 2019-05-16 16:45 ` Jane Chu 2019-05-16 21:42 ` jane.chu 2019-05-16 21:42 ` jane.chu 2019-05-16 21:51 ` Dan Williams 2019-05-16 21:51 ` Dan Williams 2019-05-17 0:01 ` Jane Chu 2019-05-17 0:01 ` Jane Chu 2019-05-31 4:17 ` Dan Williams 2019-05-31 4:17 ` Dan Williams
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=155727335978.292046.12068191395005445711.stgit@dwillia2-desk3.amr.corp.intel.com \ --to=dan.j.williams@intel.com \ --cc=akpm@linux-foundation.org \ --cc=bhelgaas@google.com \ --cc=gregkh@linuxfoundation.org \ --cc=hch@lst.de \ --cc=jglisse@redhat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-nvdimm@lists.01.org \ --cc=rafael@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.